Home | History | Annotate | Download | only in BootMonFs
      1 /** @file
      2 *
      3 *  Copyright (c) 2012-2014, ARM Limited. All rights reserved.
      4 *
      5 *  This program and the accompanying materials
      6 *  are licensed and made available under the terms and conditions of the BSD License
      7 *  which accompanies this distribution.  The full text of the license may be found at
      8 *  http://opensource.org/licenses/bsd-license.php
      9 *
     10 *  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     11 *  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     12 *
     13 **/
     14 
     15 #ifndef __BOOTMONFS_INTERNAL_H__
     16 #define __BOOTMONFS_INTERNAL_H__
     17 
     18 #include <PiDxe.h>
     19 #include <Library/UefiLib.h>
     20 #include <Library/DebugLib.h>
     21 #include <Library/BaseMemoryLib.h>
     22 #include <Library/MemoryAllocationLib.h>
     23 
     24 #include <Protocol/BlockIo.h>
     25 #include <Protocol/DiskIo.h>
     26 #include <Protocol/FirmwareVolumeBlock.h>
     27 #include <Protocol/SimpleFileSystem.h>
     28 
     29 #include <Guid/BootMonFsFileInfo.h>
     30 #include <Guid/FileInfo.h>
     31 #include <Guid/FileSystemInfo.h>
     32 #include <Guid/FileSystemVolumeLabelInfo.h>
     33 
     34 #include "BootMonFsHw.h"
     35 
     36 #define BOOTMON_FS_VOLUME_LABEL   L"NOR Flash"
     37 
     38 typedef struct _BOOTMON_FS_INSTANCE BOOTMON_FS_INSTANCE;
     39 
     40 typedef struct {
     41   LIST_ENTRY            Link;
     42   VOID*                 Buffer;
     43   UINTN                 Size;
     44   UINT64                Offset; // Offset from the start of the file
     45 } BOOTMON_FS_FILE_REGION;
     46 
     47 typedef struct {
     48   UINT32                Signature;
     49   LIST_ENTRY            Link;
     50   BOOTMON_FS_INSTANCE   *Instance;
     51 
     52   UINTN                 HwDescAddress;
     53   HW_IMAGE_DESCRIPTION  HwDescription;
     54 
     55   EFI_FILE_PROTOCOL     File;
     56 
     57   //
     58   // The following fields are relevant only if the file is open.
     59   //
     60 
     61   EFI_FILE_INFO         *Info;
     62   UINT64                Position;
     63   // If the file needs to be flushed then this list contain the memory
     64   // buffer that creates this file
     65   LIST_ENTRY            RegionToFlushLink;
     66   UINT64                OpenMode;
     67 } BOOTMON_FS_FILE;
     68 
     69 #define BOOTMON_FS_FILE_SIGNATURE              SIGNATURE_32('b', 'o', 't', 'f')
     70 #define BOOTMON_FS_FILE_FROM_FILE_THIS(a)      CR (a, BOOTMON_FS_FILE, File, BOOTMON_FS_FILE_SIGNATURE)
     71 #define BOOTMON_FS_FILE_FROM_LINK_THIS(a)      CR (a, BOOTMON_FS_FILE, Link, BOOTMON_FS_FILE_SIGNATURE)
     72 
     73 struct _BOOTMON_FS_INSTANCE {
     74   UINT32                               Signature;
     75   EFI_HANDLE                           ControllerHandle;
     76 
     77   LIST_ENTRY                           Link;
     78 
     79   EFI_DRIVER_BINDING_PROTOCOL         *Binding;
     80   EFI_DISK_IO_PROTOCOL                *DiskIo;
     81   EFI_BLOCK_IO_PROTOCOL               *BlockIo;
     82   EFI_BLOCK_IO_MEDIA                  *Media;
     83   EFI_DEVICE_PATH_PROTOCOL            *DevicePath;
     84 
     85   EFI_SIMPLE_FILE_SYSTEM_PROTOCOL      Fs;
     86 
     87   EFI_FILE_SYSTEM_INFO                 FsInfo;
     88   CHAR16                               Label[20];
     89 
     90   BOOTMON_FS_FILE                     *RootFile; // All the other files are linked to this root
     91   BOOLEAN                              Initialized;
     92 };
     93 
     94 #define BOOTMON_FS_SIGNATURE            SIGNATURE_32('b', 'o', 't', 'm')
     95 #define BOOTMON_FS_FROM_FS_THIS(a)      CR (a, BOOTMON_FS_INSTANCE, Fs, BOOTMON_FS_SIGNATURE)
     96 #define BOOTMON_FS_FROM_LINK(a)         CR (a, BOOTMON_FS_INSTANCE, Link, BOOTMON_FS_SIGNATURE)
     97 
     98 #include "BootMonFsApi.h"
     99 
    100 #endif
    101 
    102