main.c (67136) | main.c (68358) |
---|---|
1/*- 2 * Copyright (c) 1998 Michael Smith <msmith@freebsd.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * | 1/*- 2 * Copyright (c) 1998 Michael Smith <msmith@freebsd.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * |
26 * $FreeBSD: head/sys/boot/pc98/loader/main.c 67136 2000-10-15 02:56:48Z nyan $ | 26 * $FreeBSD: head/sys/boot/pc98/loader/main.c 68358 2000-11-05 12:35:41Z nyan $ |
27 */ 28 29/* 30 * MD bootstrap main() and assorted miscellaneous 31 * commands. 32 */ 33 34#include <stand.h> --- 23 unchanged lines hidden (view full) --- 58static u_int32_t initial_bootdev; 59static struct bootinfo *initial_bootinfo; 60 61struct arch_switch archsw; /* MI/MD interface boundary */ 62 63static void extract_currdev(void); 64static int isa_inb(int port); 65static void isa_outb(int port, int value); | 27 */ 28 29/* 30 * MD bootstrap main() and assorted miscellaneous 31 * commands. 32 */ 33 34#include <stand.h> --- 23 unchanged lines hidden (view full) --- 58static u_int32_t initial_bootdev; 59static struct bootinfo *initial_bootinfo; 60 61struct arch_switch archsw; /* MI/MD interface boundary */ 62 63static void extract_currdev(void); 64static int isa_inb(int port); 65static void isa_outb(int port, int value); |
66void exit(int code); |
|
66 67/* from vers.c */ 68extern char bootprog_name[], bootprog_rev[], bootprog_date[], bootprog_maker[]; 69 70/* XXX debugging */ 71extern char end[]; 72 | 67 68/* from vers.c */ 69extern char bootprog_name[], bootprog_rev[], bootprog_date[], bootprog_maker[]; 70 71/* XXX debugging */ 72extern char end[]; 73 |
73void | 74int |
74main(void) 75{ 76 int i; 77 78 /* Pick up arguments */ 79 kargs = (void *)__args; 80 initial_howto = kargs->howto; 81 initial_bootdev = kargs->bootdev; --- 53 unchanged lines hidden (view full) --- 135 archsw.arch_getdev = i386_getdev; 136 archsw.arch_copyin = i386_copyin; 137 archsw.arch_copyout = i386_copyout; 138 archsw.arch_readin = i386_readin; 139 archsw.arch_isainb = isa_inb; 140 archsw.arch_isaoutb = isa_outb; 141 142 interact(); /* doesn't return */ | 75main(void) 76{ 77 int i; 78 79 /* Pick up arguments */ 80 kargs = (void *)__args; 81 initial_howto = kargs->howto; 82 initial_bootdev = kargs->bootdev; --- 53 unchanged lines hidden (view full) --- 136 archsw.arch_getdev = i386_getdev; 137 archsw.arch_copyin = i386_copyin; 138 archsw.arch_copyout = i386_copyout; 139 archsw.arch_readin = i386_readin; 140 archsw.arch_isainb = isa_inb; 141 archsw.arch_isaoutb = isa_outb; 142 143 interact(); /* doesn't return */ |
144 145 /* if we ever get here, it is an error */ 146 return (1); |
|
143} 144 145/* 146 * Set the 'current device' by (if possible) recovering the boot device as 147 * supplied by the initial bootstrap. 148 * 149 * XXX should be extended for netbooting. 150 */ 151static void 152extract_currdev(void) 153{ | 147} 148 149/* 150 * Set the 'current device' by (if possible) recovering the boot device as 151 * supplied by the initial bootstrap. 152 * 153 * XXX should be extended for netbooting. 154 */ 155static void 156extract_currdev(void) 157{ |
154 struct i386_devdesc currdev; | 158 struct i386_devdesc new_currdev; |
155 int major, biosdev; 156 157 /* Assume we are booting from a BIOS disk by default */ | 159 int major, biosdev; 160 161 /* Assume we are booting from a BIOS disk by default */ |
158 currdev.d_dev = &biosdisk; 159 currdev.d_type = currdev.d_dev->dv_type; | 162 new_currdev.d_dev = &biosdisk; 163 new_currdev.d_type = new_currdev.d_dev->dv_type; |
160 161 /* new-style boot loaders such as pxeldr and cdldr */ 162 if (kargs->bootinfo == NULL) { 163 if ((kargs->bootflags & KARGS_FLAGS_CD) != 0) { 164 /* we are booting from a CD with cdldr */ | 164 165 /* new-style boot loaders such as pxeldr and cdldr */ 166 if (kargs->bootinfo == NULL) { 167 if ((kargs->bootflags & KARGS_FLAGS_CD) != 0) { 168 /* we are booting from a CD with cdldr */ |
165 currdev.d_kind.biosdisk.slice = -1; 166 currdev.d_kind.biosdisk.partition = 0; | 169 new_currdev.d_kind.biosdisk.slice = -1; 170 new_currdev.d_kind.biosdisk.partition = 0; |
167 biosdev = initial_bootdev; 168 } else if ((kargs->bootflags & KARGS_FLAGS_PXE) != 0) { 169 /* we are booting from pxeldr */ | 171 biosdev = initial_bootdev; 172 } else if ((kargs->bootflags & KARGS_FLAGS_PXE) != 0) { 173 /* we are booting from pxeldr */ |
170 currdev.d_dev = &pxedisk; 171 currdev.d_type = currdev.d_dev->dv_type; 172 currdev.d_kind.netif.unit = 0; | 174 new_currdev.d_dev = &pxedisk; 175 new_currdev.d_type = new_currdev.d_dev->dv_type; 176 new_currdev.d_kind.netif.unit = 0; 177 biosdev = -1; |
173 } else { 174 /* we don't know what our boot device is */ | 178 } else { 179 /* we don't know what our boot device is */ |
175 currdev.d_kind.biosdisk.slice = -1; 176 currdev.d_kind.biosdisk.partition = 0; | 180 new_currdev.d_kind.biosdisk.slice = -1; 181 new_currdev.d_kind.biosdisk.partition = 0; |
177 biosdev = -1; 178 } 179 } else if ((initial_bootdev & B_MAGICMASK) != B_DEVMAGIC) { 180 /* The passed-in boot device is bad */ | 182 biosdev = -1; 183 } 184 } else if ((initial_bootdev & B_MAGICMASK) != B_DEVMAGIC) { 185 /* The passed-in boot device is bad */ |
181 currdev.d_kind.biosdisk.slice = -1; 182 currdev.d_kind.biosdisk.partition = 0; | 186 new_currdev.d_kind.biosdisk.slice = -1; 187 new_currdev.d_kind.biosdisk.partition = 0; |
183 biosdev = -1; 184 } else { | 188 biosdev = -1; 189 } else { |
185 currdev.d_kind.biosdisk.slice = (B_ADAPTOR(initial_bootdev) << 4) + 186 B_CONTROLLER(initial_bootdev) - 1; 187 currdev.d_kind.biosdisk.partition = B_PARTITION(initial_bootdev); | 190 new_currdev.d_kind.biosdisk.slice = (B_ADAPTOR(initial_bootdev) << 4) + 191 B_CONTROLLER(initial_bootdev) - 1; 192 new_currdev.d_kind.biosdisk.partition = B_PARTITION(initial_bootdev); |
188 biosdev = initial_bootinfo->bi_bios_dev; 189 major = B_TYPE(initial_bootdev); 190 191 /* 192 * If we are booted by an old bootstrap, we have to guess at the BIOS 193 * unit number. We will loose if there is more than one disk type 194 * and we are not booting from the lowest-numbered disk type 195 * (ie. SCSI when IDE also exists). --- 10 unchanged lines hidden (view full) --- 206 biosdev = 0x80 + B_UNIT(initial_bootdev); /* assume harddisk */ 207#endif 208 } 209 210 /* 211 * If we are booting off of a BIOS disk and we didn't succeed in determining 212 * which one we booted off of, just use disk0: as a reasonable default. 213 */ | 193 biosdev = initial_bootinfo->bi_bios_dev; 194 major = B_TYPE(initial_bootdev); 195 196 /* 197 * If we are booted by an old bootstrap, we have to guess at the BIOS 198 * unit number. We will loose if there is more than one disk type 199 * and we are not booting from the lowest-numbered disk type 200 * (ie. SCSI when IDE also exists). --- 10 unchanged lines hidden (view full) --- 211 biosdev = 0x80 + B_UNIT(initial_bootdev); /* assume harddisk */ 212#endif 213 } 214 215 /* 216 * If we are booting off of a BIOS disk and we didn't succeed in determining 217 * which one we booted off of, just use disk0: as a reasonable default. 218 */ |
214 if ((currdev.d_type == devsw[0]->dv_type) && 215 ((currdev.d_kind.biosdisk.unit = bd_bios2unit(biosdev)) == -1)) { | 219 if ((new_currdev.d_type == devsw[0]->dv_type) && 220 ((new_currdev.d_kind.biosdisk.unit = bd_bios2unit(biosdev)) == -1)) { |
216 printf("Can't work out which disk we are booting from.\n" 217 "Guessed BIOS device 0x%x not found by probes, defaulting to disk0:\n", biosdev); | 221 printf("Can't work out which disk we are booting from.\n" 222 "Guessed BIOS device 0x%x not found by probes, defaulting to disk0:\n", biosdev); |
218 currdev.d_kind.biosdisk.unit = 0; | 223 new_currdev.d_kind.biosdisk.unit = 0; |
219 } | 224 } |
220 env_setenv("currdev", EV_VOLATILE, i386_fmtdev(&currdev), i386_setcurrdev, env_nounset); 221 env_setenv("loaddev", EV_VOLATILE, i386_fmtdev(&currdev), env_noset, env_nounset); | 225 env_setenv("currdev", EV_VOLATILE, i386_fmtdev(&new_currdev), 226 i386_setcurrdev, env_nounset); 227 env_setenv("loaddev", EV_VOLATILE, i386_fmtdev(&new_currdev), env_noset, 228 env_nounset); |
222} 223 224COMMAND_SET(reboot, "reboot", "reboot the system", command_reboot); 225 226static int 227command_reboot(int argc, char *argv[]) 228{ 229 int i; --- 57 unchanged lines hidden --- | 229} 230 231COMMAND_SET(reboot, "reboot", "reboot the system", command_reboot); 232 233static int 234command_reboot(int argc, char *argv[]) 235{ 236 int i; --- 57 unchanged lines hidden --- |