sconf.h 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  1. /*++
  2. Copyright (c) 2015 Minoca Corp.
  3. This file is licensed under the terms of the GNU General Public License
  4. version 3. Alternative licensing terms are available. Contact
  5. info@minocacorp.com for details. See the LICENSE file at the root of this
  6. project for complete licensing information.
  7. Module Name:
  8. sconf.h
  9. Abstract:
  10. This header contains definitions for setup configuration structures.
  11. Author:
  12. Evan Green 20-Oct-2015
  13. --*/
  14. //
  15. // ------------------------------------------------------------------- Includes
  16. //
  17. #include <minoca/lib/bconf.h>
  18. //
  19. // ---------------------------------------------------------------- Definitions
  20. //
  21. //
  22. // Define flags for a particular partition configuration.
  23. //
  24. #define SETUP_PARTITION_FLAG_BOOT 0x00000001
  25. #define SETUP_PARTITION_FLAG_SYSTEM 0x00000002
  26. #define SETUP_PARTITION_FLAG_COMPATIBILITY_MODE 0x00000004
  27. #define SETUP_PARTITION_FLAG_WRITE_VBR_LBA 0x00000008
  28. #define SETUP_PARTITION_FLAG_MERGE_VBR 0x00000010
  29. #define SETUP_COPY_FLAG_UPDATE 0x00000001
  30. #define SETUP_COPY_FLAG_OPTIONAL 0x00000002
  31. //
  32. // ------------------------------------------------------ Data Type Definitions
  33. //
  34. /*++
  35. Structure Description:
  36. This structure describes a setup copy command.
  37. Members:
  38. Destination - Stores the destination path. Directories should end in a
  39. slash.
  40. Offset - Stores the destination offset in bytes from the beginning of the
  41. disk or partition. This is used for MBR and VBR copies.
  42. Source - Stores the source path. Directories should end in a slash.
  43. SourceVolume - Stores the source volume, usually zero for the primary
  44. image. Supply -1 to use the host file system.
  45. Files - Stores a pointer to an array of files to be copied if the source
  46. and destination are directories.
  47. Flags - Stores a bitfield of flags governing the copy command. See
  48. SETUP_COPY_FLAG_* definitions.
  49. --*/
  50. typedef struct _SETUP_COPY {
  51. PCSTR Destination;
  52. ULONG Offset;
  53. PCSTR Source;
  54. LONG SourceVolume;
  55. PCSTR *Files;
  56. ULONG Flags;
  57. } SETUP_COPY, *PSETUP_COPY;
  58. /*++
  59. Structure Description:
  60. This structure contains the information coming out of a partition
  61. configuration dictionary.
  62. Members:
  63. Index - Stores the partition index.
  64. Alignment - Stores the alignment requirement for the partition.
  65. Offset - Stores the partition offset in bytes.
  66. Size - Stores the partition size in bytes. Set to -1 to expand to fill
  67. the remaining size.
  68. PartitionType - Stores the GPT partition type identifier.
  69. MbrType - Stores the MBR partition type.
  70. Attributes - Stores the partition attributes for GPT partitions.
  71. Vbr - Stores the file to add as the volume boot record.
  72. Flags - Stores a bitfield of flags describing this partition. See
  73. SETUP_PARTITION_FLAG_* definitions.
  74. CopyCommands - Stores a pointer to an array of copy commands describing
  75. files to be installed on the partition.
  76. CopyCommandCount - Stores the number of copy commands in the array.
  77. --*/
  78. typedef struct _SETUP_PARTITION_CONFIGURATION {
  79. ULONG Index;
  80. ULONGLONG Alignment;
  81. ULONGLONG Offset;
  82. ULONGLONG Size;
  83. UCHAR PartitionId[PARTITION_IDENTIFIER_SIZE];
  84. UCHAR PartitionType[PARTITION_TYPE_SIZE];
  85. UCHAR MbrType;
  86. ULONGLONG Attributes;
  87. SETUP_COPY Vbr;
  88. ULONG Flags;
  89. PSETUP_COPY CopyCommands;
  90. ULONG CopyCommandCount;
  91. } SETUP_PARTITION_CONFIGURATION, *PSETUP_PARTITION_CONFIGURATION;
  92. /*++
  93. Structure Description:
  94. This structure contains the disk formatting information coming out a
  95. partitioning data dictionary.
  96. Members:
  97. PartitionFormat - Stores the partitioning scheme for this disk. This is of
  98. type PARTITION_FORMAT, but is specified with an explicit size because
  99. it interacts with the interpreter as a 32-bit value.
  100. PartitionList - Stores the head of the list of partitions.
  101. Mbr - Stores the optional MBR to put at the head of the disk.
  102. --*/
  103. typedef struct _SETUP_DISK_CONFIGURATION {
  104. ULONG PartitionFormat;
  105. SETUP_COPY Mbr;
  106. PSETUP_PARTITION_CONFIGURATION Partitions;
  107. ULONG PartitionCount;
  108. } SETUP_DISK_CONFIGURATION, *PSETUP_DISK_CONFIGURATION;
  109. /*++
  110. Structure Description:
  111. This structure contains the configuration information for a setup
  112. installation.
  113. Members:
  114. Disk - Stores the disk and partition configuration, including the list of
  115. files to copy.
  116. GlobalBootConfiguration - Stores the global boot configuration.
  117. BootEntries - Stores the boot entries for the new installation.
  118. BootEntryCount - Stores the number of valid boot entries.
  119. BootDrivers - Stores an array of strings describing the boot drivers.
  120. BootDriversPath - Stores a pointer to the path where the boot drivers file
  121. should be written out.
  122. BootDataPath - Stores a pointer to the path on the boot partition where
  123. the boot configuration data resides.
  124. --*/
  125. struct _SETUP_CONFIGURATION {
  126. SETUP_DISK_CONFIGURATION Disk;
  127. BOOT_CONFIGURATION_GLOBAL GlobalBootConfiguration;
  128. PBOOT_ENTRY BootEntries;
  129. ULONG BootEntryCount;
  130. PCSTR *BootDrivers;
  131. PCSTR BootDriversPath;
  132. PCSTR BootDataPath;
  133. };
  134. //
  135. // -------------------------------------------------------------------- Globals
  136. //
  137. //
  138. // -------------------------------------------------------- Function Prototypes
  139. //
  140. INT
  141. SetupLoadConfiguration (
  142. PSETUP_CONTEXT Context
  143. );
  144. /*++
  145. Routine Description:
  146. This routine prepares to run the configuration specialization script.
  147. Arguments:
  148. Context - Supplies a pointer to the application context.
  149. Return Value:
  150. 0 on success.
  151. Returns a non-zero value on failure.
  152. --*/
  153. INT
  154. SetupLoadUserScript (
  155. PSETUP_CONTEXT Context,
  156. PCSTR Path
  157. );
  158. /*++
  159. Routine Description:
  160. This routine loads and runs a user customization script in the setup app.
  161. Arguments:
  162. Context - Supplies a pointer to the application context.
  163. Path - Supplies a pointer to the path of the custom script to run.
  164. Return Value:
  165. 0 on success.
  166. Returns a non-zero value on failure.
  167. --*/
  168. INT
  169. SetupLoadUserExpression (
  170. PSETUP_CONTEXT Context,
  171. PCSTR Expression
  172. );
  173. /*++
  174. Routine Description:
  175. This routine runs a user customization script expression in the setup app.
  176. Arguments:
  177. Context - Supplies a pointer to the application context.
  178. Expression - Supplies a pointer to the script fragment to evaluate.
  179. Return Value:
  180. 0 on success.
  181. Returns a non-zero value on failure.
  182. --*/
  183. INT
  184. SetupReadConfiguration (
  185. PCK_VM Vm,
  186. PSETUP_CONFIGURATION *NewConfiguration
  187. );
  188. /*++
  189. Routine Description:
  190. This routine reads the configuration into the given setup context after the
  191. interpreter has finished running.
  192. Arguments:
  193. Vm - Supplies a pointer to the Chalk virtual machine.
  194. NewConfiguration - Supplies a pointer where a pointer to the new
  195. configuration will be returned on success.
  196. Return Value:
  197. 0 on success.
  198. EINVAL on configuration errors.
  199. Other errors on other failures.
  200. --*/
  201. VOID
  202. SetupDestroyConfiguration (
  203. PSETUP_CONFIGURATION Configuration
  204. );
  205. /*++
  206. Routine Description:
  207. This routine destroys a setup configuration.
  208. Arguments:
  209. Configuration - Supplies a pointer to the configuration to destroy.
  210. Return Value:
  211. None.
  212. --*/
  213. //
  214. // Setup execution steps
  215. //
  216. INT
  217. SetupInstallToDisk (
  218. PSETUP_CONTEXT Context
  219. );
  220. /*++
  221. Routine Description:
  222. This routine installs the OS onto an open disk.
  223. Arguments:
  224. Context - Supplies a pointer to the application context.
  225. Return Value:
  226. 0 on success.
  227. Non-zero on failure.
  228. --*/
  229. INT
  230. SetupInstallToPartition (
  231. PSETUP_CONTEXT Context,
  232. PSETUP_PARTITION_CONFIGURATION PartitionConfiguration
  233. );
  234. /*++
  235. Routine Description:
  236. This routine perform the required installation steps for a particular
  237. partition.
  238. Arguments:
  239. Context - Supplies a pointer to the application context.
  240. PartitionConfiguration - Supplies a pointer to the partition data to
  241. install.
  242. Return Value:
  243. 0 on success.
  244. Non-zero on failure.
  245. --*/
  246. INT
  247. SetupInstallToDirectory (
  248. PSETUP_CONTEXT Context
  249. );
  250. /*++
  251. Routine Description:
  252. This routine installs the OS onto a directory, copying only system
  253. partition files.
  254. Arguments:
  255. Context - Supplies a pointer to the application context.
  256. Return Value:
  257. 0 on success.
  258. Non-zero on failure.
  259. --*/
  260. INT
  261. SetupInstallFiles (
  262. PSETUP_CONTEXT Context,
  263. PVOID DestinationVolume,
  264. PSETUP_PARTITION_CONFIGURATION Partition
  265. );
  266. /*++
  267. Routine Description:
  268. This routine installs to the given volume.
  269. Arguments:
  270. Context - Supplies a pointer to the applicaton context.
  271. DestinationVolume - Supplies a pointer to the open destination volume
  272. handle.
  273. Partition - Supplies a pointer to the partition configuration, which
  274. contains the files to copy.
  275. Return Value:
  276. 0 on success.
  277. Non-zero on failure.
  278. --*/
  279. INT
  280. SetupUpdateBootVolume (
  281. PSETUP_CONTEXT Context,
  282. PVOID BootVolume
  283. );
  284. /*++
  285. Routine Description:
  286. This routine updates the boot volume, copying the boot files and updating
  287. the boot entries.
  288. Arguments:
  289. Context - Supplies a pointer to the applicaton context.
  290. BootVolume - Supplies a pointer to the open boot volume handle.
  291. Return Value:
  292. 0 on success.
  293. Non-zero on failure.
  294. --*/
  295. INT
  296. SetupUpdateBootEntries (
  297. PSETUP_CONTEXT Context,
  298. PVOID BootVolume
  299. );
  300. /*++
  301. Routine Description:
  302. This routine writes out the new boot entries for the installed image.
  303. Arguments:
  304. Context - Supplies a pointer to the applicaton context.
  305. BootVolume - Supplies a pointer to the open boot volume handle.
  306. Return Value:
  307. 0 on success.
  308. Non-zero on failure.
  309. --*/