main.c (39450) | main.c (39664) |
---|---|
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 * $Id: main.c,v 1.5 1998/09/17 23:52:15 msmith Exp $ | 26 * $Id: main.c,v 1.6 1998/09/18 02:03:30 msmith Exp $ |
27 */ 28 29/* 30 * MD bootstrap main() and assorted miscellaneous 31 * commands. 32 */ 33 34#include <stand.h> 35#include <string.h> | 27 */ 28 29/* 30 * MD bootstrap main() and assorted miscellaneous 31 * commands. 32 */ 33 34#include <stand.h> 35#include <string.h> |
36#include <machine/bootinfo.h> 37#include <sys/reboot.h> |
|
36 37#include "bootstrap.h" 38#include "libi386/libi386.h" 39#include "btxv86.h" 40 | 38 39#include "bootstrap.h" 40#include "libi386/libi386.h" 41#include "btxv86.h" 42 |
43/* Arguments passed in from the boot1/boot2 loader */ 44static struct 45{ 46 u_int32_t howto; 47 u_int32_t bootdev; 48 u_int32_t res0; 49 u_int32_t res1; 50 u_int32_t res2; 51 u_int32_t bootinfo; 52} *kargs; 53 54struct bootinfo *initial_bootinfo; 55 |
|
41struct arch_switch archsw; /* MI/MD interface boundary */ 42 43/* from vers.c */ 44extern char bootprog_name[], bootprog_rev[], bootprog_date[], bootprog_maker[]; 45 46/* XXX debugging */ 47extern char end[]; 48 49void 50main(void) 51{ 52 struct i386_devdesc currdev; 53 int i; 54 | 56struct arch_switch archsw; /* MI/MD interface boundary */ 57 58/* from vers.c */ 59extern char bootprog_name[], bootprog_rev[], bootprog_date[], bootprog_maker[]; 60 61/* XXX debugging */ 62extern char end[]; 63 64void 65main(void) 66{ 67 struct i386_devdesc currdev; 68 int i; 69 |
70 /* Pick up arguments */ 71 kargs = (void *)__args; 72 initial_bootinfo = (struct bootinfo *)PTOV(kargs->bootinfo); 73 |
|
55 /* 56 * Initialise the heap as early as possible. Once this is done, malloc() is usable. 57 * 58 * XXX better to locate end of memory and use that 59 */ 60 setheap((void *)end, (void *)(end + (384 * 1024))); 61 62 /* 63 * XXX Chicken-and-egg problem; we want to have console output early, but some 64 * console attributes may depend on reading from eg. the boot device, which we 65 * can't do yet. 66 * 67 * We can use printf() etc. once this is done. | 74 /* 75 * Initialise the heap as early as possible. Once this is done, malloc() is usable. 76 * 77 * XXX better to locate end of memory and use that 78 */ 79 setheap((void *)end, (void *)(end + (384 * 1024))); 80 81 /* 82 * XXX Chicken-and-egg problem; we want to have console output early, but some 83 * console attributes may depend on reading from eg. the boot device, which we 84 * can't do yet. 85 * 86 * We can use printf() etc. once this is done. |
87 * If the previous boot stage has requested a serial console, prefer that. |
|
68 */ | 88 */ |
89 if (kargs->howto & RB_SERIAL) 90 setenv("console", "com", 1); |
|
69 cons_probe(); 70 71 /* 72 * March through the device switch probing for things. 73 */ 74 for (i = 0; devsw[i] != NULL; i++) 75 if (devsw[i]->dv_init != NULL) 76 (devsw[i]->dv_init)(); --- 72 unchanged lines hidden (view full) --- 149} 150#endif 151 152COMMAND_SET(heap, "heap", "show heap usage", command_heap); 153 154static int 155command_heap(int argc, char *argv[]) 156{ | 91 cons_probe(); 92 93 /* 94 * March through the device switch probing for things. 95 */ 96 for (i = 0; devsw[i] != NULL; i++) 97 if (devsw[i]->dv_init != NULL) 98 (devsw[i]->dv_init)(); --- 72 unchanged lines hidden (view full) --- 171} 172#endif 173 174COMMAND_SET(heap, "heap", "show heap usage", command_heap); 175 176static int 177command_heap(int argc, char *argv[]) 178{ |
157 printf("heap base at %p, top at %p, used %d\n", end, sbrk(0), sbrk(0) - end); | 179 mallocstats(); 180 printf("heap base at %p, top at %p", end, sbrk(0)); |
158 return(CMD_OK); 159} | 181 return(CMD_OK); 182} |