]> git.proxmox.com Git - mirror_edk2.git/blobdiff - StdLibPrivateInternalFiles/Include/kfile.h
SecurityPkg: Add TPM PTP support in TPM2 device lib.
[mirror_edk2.git] / StdLibPrivateInternalFiles / Include / kfile.h
index 845b7d908e845d994ce2d458210c859863ef6bbd..67bff56cc67483b6e7eaa1b2ba50b728942bf3d3 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   The EFI kernel's interpretation of a "file".\r
 \r
-  Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials are licensed and made available\r
   under the terms and conditions of the BSD License which accompanies this\r
   distribution.  The full text of the license may be found at\r
@@ -48,6 +48,7 @@
 #include  <Protocol/SimpleFileSystem.h>\r
 \r
 #include  <wchar.h>\r
+#include  <stdarg.h>\r
 #include  <sys/fcntl.h>\r
 #include  <sys/unistd.h>\r
 \r
@@ -79,21 +80,35 @@ struct _Device_Node;
     This structure must be a multiple of 8 bytes in length.\r
 */\r
 struct __filedes {\r
+  off_t                   f_offset;     /* current position in file */\r
   const struct fileops   *f_ops;\r
+\r
+  /*  The devdata member has different meanings depending upon whether\r
+      a block oriented or character oriented device is being accessed.\r
+      For block devices, devdata holds an EFI handle to the open file or directory.\r
+      For character devices, devdata points to the device's IIO structure,\r
+      if it has one.  It may be NULL indicating a non-interactive character\r
+      device.\r
+  */\r
   void                   *devdata;      /* Device-specific data */\r
-  off_t                   f_offset;     /* current position in file */\r
-  UINT32                  f_flag;       /* see fcntl.h */\r
-  UINT32                  f_iflags;     // In use if non-zero\r
-  int                     Oflags;       // From the open call\r
+  int                     Oflags;       // From the open call, see fcntl.h\r
   int                     Omode;        // From the open call\r
   int                     RefCount;     // Reference count of opens\r
+  UINT32                  f_flag;       /* see fcntl.h */\r
+  UINT32                  f_iflags;     // In use if non-zero\r
   UINT16                  MyFD;         // Which FD this is.\r
   UINT16                  Reserved_1;   // Force this structure to be a multiple of 8-bytes in length\r
 };\r
 \r
 struct fileops {\r
   /* These functions must always be implemented. */\r
+\r
+  /** Perform device specific operations for closing the device.\r
+      It is the responsibility of this function to flush or discard\r
+      buffer contents.\r
+  **/\r
   int     (EFIAPI *fo_close)    (struct __filedes *filp);\r
+\r
   ssize_t (EFIAPI *fo_read)     (struct __filedes *filp, off_t *Offset, size_t Len, void *Buf);\r
   ssize_t (EFIAPI *fo_write)    (struct __filedes *filp, off_t *Offset, size_t Len, const void *Buf);\r
 \r
@@ -104,7 +119,7 @@ struct fileops {
 \r
   /* Call the fbadop_* version of these functions if not implemented by the device. */\r
   int     (EFIAPI *fo_stat)     (struct __filedes *filp, struct stat *StatBuf, void *Buf);\r
-  int     (EFIAPI *fo_ioctl)    (struct __filedes *filp, ULONGN Cmd, void *argp);\r
+  int     (EFIAPI *fo_ioctl)    (struct __filedes *filp, ULONGN Cmd, va_list argp);\r
   int     (EFIAPI *fo_delete)   (struct __filedes *filp);\r
   int     (EFIAPI *fo_rmdir)    (struct __filedes *filp);\r
   int     (EFIAPI *fo_mkdir)    (const char *path, __mode_t perms);\r
@@ -114,7 +129,7 @@ struct fileops {
   off_t   (EFIAPI *fo_lseek)    (struct __filedes *filp, off_t, int);\r
 };\r
 \r
-/*  A generic instance structure which is valid for\r
+/*  A generic instance structure which is valid\r
     for all device instance structures.\r
 \r
     All device instance structures MUST be a multiple of 8-bytes in length.\r
@@ -130,7 +145,8 @@ typedef struct {
 \r
 /* Type of all Device-specific handler's open routines. */\r
 typedef\r
-  int     (EFIAPI *FO_OPEN)    (struct __filedes *FD, void *IP, wchar_t *Path, wchar_t *Flags);\r
+  int     (EFIAPI *FO_OPEN)    (struct _Device_Node *This, struct __filedes *FD,\r
+                                int Instance, wchar_t *Path, wchar_t *MPath);\r
 \r
 #define FILE_IS_USABLE(fp)  (((fp)->f_iflags &      \\r
           (FIF_WANTCLOSE|FIF_LARVAL)) == 0)\r
@@ -153,16 +169,16 @@ int   fdcreate    (CHAR16 *, UINT32, UINT32, BOOLEAN, VOID *, const struct fileo
       fnullop_*   Does nothing and returns success.\r
       fbadop_*    Does nothing and returns EPERM\r
 */\r
-int     fnullop_fcntl (struct __filedes *filp, UINT32 Cmd, void *p3, void *p4);\r
-short   fnullop_poll  (struct __filedes *filp, short Events);\r
-int     fnullop_flush (struct __filedes *filp);\r
-\r
-int     fbadop_stat   (struct __filedes *filp, struct stat *StatBuf, void *Buf);\r
-int     fbadop_ioctl  (struct __filedes *filp, ULONGN Cmd, void *argp);\r
-int     fbadop_delete (struct __filedes *filp);\r
-int     fbadop_rmdir  (struct __filedes *filp);\r
-int     fbadop_mkdir  (const char *path, __mode_t perms);\r
-int     fbadop_rename (const char *from, const char *to);\r
+int     EFIAPI fnullop_fcntl (struct __filedes *filp, UINT32 Cmd, void *p3, void *p4);\r
+short   EFIAPI fnullop_poll  (struct __filedes *filp, short Events);\r
+int     EFIAPI fnullop_flush (struct __filedes *filp);\r
+\r
+int     EFIAPI fbadop_stat   (struct __filedes *filp, struct stat *StatBuf, void *Buf);\r
+int     EFIAPI fbadop_ioctl  (struct __filedes *filp, ULONGN Cmd, va_list argp);\r
+int     EFIAPI fbadop_delete (struct __filedes *filp);\r
+int     EFIAPI fbadop_rmdir  (struct __filedes *filp);\r
+int     EFIAPI fbadop_mkdir  (const char *path, __mode_t perms);\r
+int     EFIAPI fbadop_rename (const char *from, const char *to);\r
 \r
 __END_DECLS\r
 \r