Deleted Added
full compact
main.c (39178) main.c (39441)
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.3 1998/09/03 02:10:09 msmith Exp $
26 * $Id: main.c,v 1.4 1998/09/14 18:27:06 msmith Exp $
27 */
28
29/*
30 * MD bootstrap main() and assorted miscellaneous
31 * commands.
32 */
33
34#include <stand.h>
35#include <string.h>
36
37#include "bootstrap.h"
38#include "libi386/libi386.h"
27 */
28
29/*
30 * MD bootstrap main() and assorted miscellaneous
31 * commands.
32 */
33
34#include <stand.h>
35#include <string.h>
36
37#include "bootstrap.h"
38#include "libi386/libi386.h"
39#include "btxv86.h"
39
40
40extern int boot_biosdev; /* from runtime startup */
41
42struct arch_switch archsw; /* MI/MD interface boundary */
43
44/* from vers.c */
45extern char bootprog_name[], bootprog_rev[], bootprog_date[], bootprog_maker[];
46
47/* XXX debugging */
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 */
48#include "libi386/crt/diskbuf.h"
49extern char stackbase, stacktop;
50extern char end[];
51
52void
53main(void)
54{
55 struct i386_devdesc currdev;
56 int i;
57
58 /*
47extern char end[];
48
49void
50main(void)
51{
52 struct i386_devdesc currdev;
53 int i;
54
55 /*
59 * Initialise the heap as early as possible. Once this is done, alloc() is usable.
60 * The stack is buried inside us, so this is safe
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
61 */
59 */
62 setheap((void *)end, (void *)(end + 0x80000));
60 setheap((void *)end, (void *)(end + (384 * 1024)));
63
64 /*
65 * XXX Chicken-and-egg problem; we want to have console output early, but some
66 * console attributes may depend on reading from eg. the boot device, which we
67 * can't do yet.
68 *
69 * We can use printf() etc. once this is done.
70 */

--- 13 unchanged lines hidden (view full) ---

84#if 0
85 printf("diskbuf at %p, %d sectors\n", &diskbuf, diskbuf_size);
86 printf("using %d bytes of stack at %p\n", (&stacktop - &stackbase), &stacktop);
87#endif
88
89 /* We're booting from a BIOS disk, try to spiff this */
90 currdev.d_dev = devsw[0]; /* XXX presumes that biosdisk is first in devsw */
91 currdev.d_type = currdev.d_dev->dv_type;
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.
68 */

--- 13 unchanged lines hidden (view full) ---

82#if 0
83 printf("diskbuf at %p, %d sectors\n", &diskbuf, diskbuf_size);
84 printf("using %d bytes of stack at %p\n", (&stacktop - &stackbase), &stacktop);
85#endif
86
87 /* We're booting from a BIOS disk, try to spiff this */
88 currdev.d_dev = devsw[0]; /* XXX presumes that biosdisk is first in devsw */
89 currdev.d_type = currdev.d_dev->dv_type;
92 currdev.d_kind.biosdisk.unit = boot_biosdev;
90 currdev.d_kind.biosdisk.unit = 0; /* XXX wrong, need to get from bootinfo etc. */
93 currdev.d_kind.biosdisk.slice = -1; /* XXX should be able to detect this, default to autoprobe */
94 currdev.d_kind.biosdisk.partition = 0; /* default to 'a' */
95
96 /* Create i386-specific variables */
97
98 env_setenv("currdev", EV_VOLATILE, i386_fmtdev(&currdev), i386_setcurrdev, env_nounset);
99 env_setenv("loaddev", EV_VOLATILE, i386_fmtdev(&currdev), env_noset, env_nounset);
100 setenv("LINES", "24", 1); /* optional */

--- 15 unchanged lines hidden (view full) ---

116COMMAND_SET(reboot, "reboot", "reboot the system", command_reboot);
117
118static int
119command_reboot(int argc, char *argv[])
120{
121
122 printf("Rebooting...\n");
123 delay(1000000);
91 currdev.d_kind.biosdisk.slice = -1; /* XXX should be able to detect this, default to autoprobe */
92 currdev.d_kind.biosdisk.partition = 0; /* default to 'a' */
93
94 /* Create i386-specific variables */
95
96 env_setenv("currdev", EV_VOLATILE, i386_fmtdev(&currdev), i386_setcurrdev, env_nounset);
97 env_setenv("loaddev", EV_VOLATILE, i386_fmtdev(&currdev), env_noset, env_nounset);
98 setenv("LINES", "24", 1); /* optional */

--- 15 unchanged lines hidden (view full) ---

114COMMAND_SET(reboot, "reboot", "reboot the system", command_reboot);
115
116static int
117command_reboot(int argc, char *argv[])
118{
119
120 printf("Rebooting...\n");
121 delay(1000000);
124 reboot();
125 /* Note: we shouldn't get to this point! */
126 panic("Reboot failed!");
127 exit(0);
122 __exit(0);
128}
129
123}
124
125/* provide this for panic */
126void
127exit(int code)
128{
129 __exit(code);
130}
131
132#if 0 /* XXX learn to ask BTX */
133
130COMMAND_SET(stack, "stack", "show stack usage", command_stack);
131
134COMMAND_SET(stack, "stack", "show stack usage", command_stack);
135
136extern char stackbase, stacktop;
137
132static int
133command_stack(int argc, char *argv[])
134{
135 char *cp;
136
137 for (cp = &stackbase; cp < &stacktop; cp++)
138 if (*cp != 0)
139 break;
140
141 printf("%d bytes of stack used\n", &stacktop - cp);
142 return(CMD_OK);
143}
138static int
139command_stack(int argc, char *argv[])
140{
141 char *cp;
142
143 for (cp = &stackbase; cp < &stacktop; cp++)
144 if (*cp != 0)
145 break;
146
147 printf("%d bytes of stack used\n", &stacktop - cp);
148 return(CMD_OK);
149}
150#endif
144
145COMMAND_SET(heap, "heap", "show heap usage", command_heap);
146
147static int
148command_heap(int argc, char *argv[])
149{
150 printf("heap base at %p, top at %p, used %d\n", end, sbrk(0), sbrk(0) - end);
151 return(CMD_OK);
152}
151
152COMMAND_SET(heap, "heap", "show heap usage", command_heap);
153
154static int
155command_heap(int argc, char *argv[])
156{
157 printf("heap base at %p, top at %p, used %d\n", end, sbrk(0), sbrk(0) - end);
158 return(CMD_OK);
159}