More work on the FAT driver, more messy, but more complete
[tpg/acess2.git] / Kernel / include / binary.h
index ed163bd..77ccdd7 100644 (file)
@@ -7,6 +7,40 @@
 #define _BINARY_H
 
 // === TYPES ===
+/**
+ * \brief Representation of a page in a binary file
+ * 
+ * Tells the binary loader where the page data resides on disk and where
+ * to load it to (relative to the binary base). Once the data is read,
+ * the \a Physical field contains the physical address of the page.
+ */
+typedef struct sBinaryPage
+{
+       /**
+        * \brief Physical address, or file offset
+        * 
+        * Physical address of this page or, when the file is not yet
+        * loaded, this is a file offset (or -1 for uninitialised data)
+        */
+       tPAddr  Physical;
+       tVAddr  Virtual;        //!< Virtual load address
+       Uint16  Size;   //!< Number of bytes to load from the file
+       Uint16  Flags;  //!< Load Flags
+} __attribute__ ((packed))     tBinaryPage;
+
+/**
+ * \brief Flags for ::tBinaryPage.Flags
+ * \name Binary Page Flags
+ * \{
+ */
+//! \brief Read-only
+#define BIN_PAGEFLAG_RO                0x0001
+//! \brief Executable
+#define BIN_PAGEFLAG_EXEC      0x0002
+/**
+ * \}
+ */
+
 /**
  * \brief Defines a binary file
  * 
@@ -57,18 +91,7 @@ typedef struct sBinary
         * \brief Array of pages defined by this binary
         * \note Contains \a NumPages entries
         */
-       struct {
-               /**
-                * \brief Physical address, or file offset
-                * 
-                * Physical address of this page or, when the file is not yet
-                * loaded, this is a file offset (or -1 for uninitialised data)
-                */
-               tPAddr  Physical;
-               tVAddr  Virtual;        //!< Virtual load address
-               Uint16  Size;   //!< Number of bytes to load from the file
-               Uint16  Flags;  //!< Load Flags
-       }       Pages[];
+       tBinaryPage     Pages[];
 }      tBinary;
 
 /**
@@ -141,4 +164,17 @@ typedef struct sBinaryType
  */
 extern char    *Binary_RegInterp(char *Path);
 
+/**
+ * \brief Registers a binary type with the kernel's loader
+ * \param Type Pointer to the loader's type structure
+ * \return Boolean success
+ * \note The structure \a Type must be persistant (usually it will be a
+ *       constant global variable)
+ * 
+ * This function tells the binary loader about a new file type, and gives
+ * it the functions to read the type into a ::tBinary structure, relocate
+ * it and to find the value of symbols defined within the binary.
+ */
+extern  int    Binary_RegisterType(tBinaryType *Type);
+
 #endif

UCC git Repository :: git.ucc.asn.au