1 /*- 2 * Copyright (c) 2012 Andriy Gapon <avg@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms are freely 6 * permitted provided that the above copyright notice and this 7 * paragraph and the following disclaimer are duplicated in all 8 * such forms. 9 * 10 * This software is provided "AS IS" and without any express or 11 * implied warranties, including, without limitation, the implied 12 * warranties of merchantability and fitness for a particular 13 * purpose. 14 * 15 * $FreeBSD$ 16 */ 17 18 #ifndef _BOOT_I386_ARGS_H_ 19 #define _BOOT_I386_ARGS_H_ 20 21 #define KARGS_FLAGS_CD 0x1 22 #define KARGS_FLAGS_PXE 0x2 23 #define KARGS_FLAGS_ZFS 0x4 24 #define KARGS_FLAGS_EXTARG 0x8 /* variably sized extended argument */ 25 26 #define BOOTARGS_SIZE 24 /* sizeof(struct bootargs) */ 27 #define BA_BOOTFLAGS 8 /* offsetof(struct bootargs, bootflags) */ 28 #define BA_BOOTINFO 20 /* offsetof(struct bootargs, bootinfo) */ 29 #define BI_SIZE 48 /* offsetof(struct bootinfo, bi_size) */ 30 31 /* 32 * We reserve some space above BTX allocated stack for the arguments 33 * and certain data that could hang off them. Currently only struct bootinfo 34 * is supported in that category. The bootinfo is placed at the top 35 * of the arguments area and the actual arguments are placed at ARGOFF offset 36 * from the top and grow towards the top. Hopefully we have enough space 37 * for bootinfo and the arguments to not run into each other. 38 * Arguments area below ARGOFF is reserved for future use. 39 */ 40 #define ARGSPACE 0x1000 /* total size of the BTX args area */ 41 #define ARGOFF 0x800 /* actual args offset within the args area */ 42 #define ARGADJ (ARGSPACE - ARGOFF) 43 44 #ifndef __ASSEMBLER__ 45 46 /* 47 * This struct describes the contents of the stack on entry to btxldr.S. This 48 * is the data that follows the return address, so it begins at 4(%esp). On 49 * the sending side, this data is passed as individual args to __exec(). On the 50 * receiving side, code in btxldr.S copies the data from the entry stack to a 51 * known fixed location in the new address space. Then, btxcsu.S sets the 52 * global variable __args to point to that known fixed location before calling 53 * main(), which casts __args to a struct bootargs pointer to access the data. 54 * The btxldr.S code is aware of KARGS_FLAGS_EXTARG, and if it's set, the extra 55 * args data is copied along with the other bootargs from the entry stack to the 56 * fixed location in the new address space. 57 * 58 * The bootinfo field is actually a pointer to a bootinfo struct that has been 59 * converted to uint32_t using VTOP(). On the receiving side it must be 60 * converted back to a pointer using PTOV(). Code in btxldr.S is aware of this 61 * field and if it's non-NULL it copies the data it points to into another known 62 * fixed location, and adjusts the bootinfo field to point to that new location. 63 */ 64 struct bootargs 65 { 66 uint32_t howto; 67 uint32_t bootdev; 68 uint32_t bootflags; 69 union { 70 struct { 71 uint32_t pxeinfo; 72 uint32_t reserved; 73 }; 74 uint64_t zfspool; 75 }; 76 uint32_t bootinfo; 77 78 /* 79 * If KARGS_FLAGS_EXTARG is set in bootflags, then the above fields 80 * are followed by a uint32_t field that specifies a size of the 81 * extended arguments (including the size field). 82 */ 83 }; 84 85 #ifdef LOADER_GELI_SUPPORT 86 #include <crypto/intake.h> 87 #endif 88 89 struct geli_boot_args 90 { 91 uint32_t size; 92 union { 93 char gelipw[256]; 94 struct { 95 char notapw; /* 96 * single null byte to stop keybuf 97 * being interpreted as a password 98 */ 99 uint32_t keybuf_sentinel; 100 #ifdef LOADER_GELI_SUPPORT 101 struct keybuf *keybuf; 102 #else 103 void *keybuf; 104 #endif 105 }; 106 }; 107 }; 108 109 #endif /*__ASSEMBLER__*/ 110 111 #endif /* !_BOOT_I386_ARGS_H_ */ 112