Content-Length: 940022 | pFad | http://github.com/DragonFlyBSD/DragonFlyBSD/commit/234ac8c0ad606eb0fd557eeebd62ba20ca1ca26f

6B Fix PXE: · DragonFlyBSD/DragonFlyBSD@234ac8c · GitHub
Skip to content

Commit 234ac8c

Browse files
author
Diederik de Groot
committed
Fix PXE:
- Default to RB_MULTIPLE/RB_DUAL Fix Loader: - Handle serial settings when started by pxeldr - Move/Merge howto_names table to ../sys/boot.h Fix comc_set_speed - Sleep function was not working - Would never stop after changing speed Update dloader kenv entries
1 parent 64c241a commit 234ac8c

File tree

8 files changed

+108
-96
lines changed

8 files changed

+108
-96
lines changed

sys/boot/common/bootstrap.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,9 +317,6 @@ extern struct arch_switch archsw;
317317
/* This must be provided by the MD code, but should it be in the archsw? */
318318
void delay(int delay);
319319

320-
#define usleep(nanosecs) delay(nanosecs * 1000)
321-
#define sleep(secs) delay(secs * 1000000)
322-
323320
void dev_cleanup(void);
324321

325322
time_t time(time_t *tloc);

sys/boot/dloader/cmds.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,17 @@ static char *kenv_vars[] = {
7272
"boot_cdrom",
7373
"boot_ddb",
7474
"boot_gdb",
75+
"boot_multicons",
76+
"boot_mute",
7577
"boot_serial",
7678
"boot_single",
79+
"boot_pause",
7780
"boot_verbose",
7881
"boot_vidcons",
7982
"bootfile",
8083
"console",
84+
"comconsole_speed",
85+
"comconsole_port",
8186
"currdev",
8287
"default_kernel",
8388
"dumpdev",

sys/boot/pc32/libi386/comconsole.c

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,26 @@ comc_ischar(void)
180180
return (inb(comc_port + com_lsr) & LSR_RXRDY);
181181
}
182182

183+
/* should be moved to one of the common files */
184+
static void
185+
sleep(int timeout) {
186+
time_t when, otime, ntime;
187+
188+
otime = time(NULL);
189+
when = otime + timeout; /* when to boot */
190+
for (;;) {
191+
ntime = time(NULL);
192+
if (ntime >= when)
193+
break;
194+
otime = ntime;
195+
}
196+
183197
static int
184198
comc_speed_set(struct env_var *ev, int flags, const void *value)
185199
{
186200
char intbuf[64];
187201
int speed;
188-
int tries;
202+
int tries = 0;
189203

190204
if ((comconsole.c_flags & (C_ACTIVEIN | C_ACTIVEOUT)) != (C_ACTIVEIN | C_ACTIVEOUT)) {
191205
printf("Com 0x%x Not Active\n", comc_port);
@@ -198,19 +212,16 @@ comc_speed_set(struct env_var *ev, int flags, const void *value)
198212
}
199213

200214
if (comc_curspeed != speed) {
201-
if (comc_curspeed != -1 && comc_curspeed != speed) {
202-
printf("Com 0x%x: changing speed to %d baud in 5 seconds, "
203-
"change your terminal to match!\n\a",
204-
comc_port, speed);
205-
sleep(5);
206-
}
215+
printf("Com 0x%x: changing speed from %d to %d baud in 5 seconds, "
216+
"change your terminal to match!\n\a",
217+
comc_port, comc_curspeed, speed);
218+
sleep(5);
207219

208220
outb(comc_port + com_cfcr, LCR_DLAB);
209221
outb(comc_port + com_dlbl, COMC_BPS(speed) & 0xff);
210222
outb(comc_port + com_dlbh, COMC_BPS(speed) >> 8);
211223
outb(comc_port + com_cfcr, LCR_8BITS);
212-
213-
tries = 0;
224+
outb(comc_port + com_mcr, MCR_RTS | MCR_DTR);
214225
do
215226
inb(comc_port + com_data);
216227
while (inb(comc_port + com_lsr) & LSR_RXRDY && ++tries < RX_TRY_COUNT);

sys/boot/pc32/loader/main.c

Lines changed: 35 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
#include <machine/bootinfo.h>
6969
#include <machine/psl.h>
7070
#include <sys/reboot.h>
71+
#include <sys/boot.h>
7172

7273
#include "bootstrap.h"
7374
#include "libi386/libi386.h"
@@ -106,55 +107,29 @@ extern char bootprog_name[], bootprog_rev[], bootprog_date[], bootprog_maker[];
106107
/* XXX debugging */
107108
extern char _end[];
108109

109-
/* move this to rbx.h */
110-
static struct
111-
{
112-
const char * const ev;
113-
const char * const desc;
114-
const char flag;
115-
int mask;
116-
} howto_names[] = {
117-
{"boot_askname", "askname", 'a', RB_ASKNAME},
118-
{"boot_single", "single", 's', RB_SINGLE},
119-
{NULL, "nosync", '-', RB_NOSYNC},
120-
{NULL, "halt", '-', RB_HALT},
121-
{NULL, "initname", '-', RB_INITNAME},
122-
{"boot_dfltroot", "dfltroot", 'r', RB_DFLTROOT},
123-
{"boot_kdb", "kdb", 'd', RB_KDB},
124-
{NULL, "rdonly", '-', RB_RDONLY},
125-
{NULL, "dump", '-', RB_DUMP},
126-
{NULL, "miniroot", '-', RB_MINIROOT},
127-
{NULL, "config", 'c', RB_CONFIG},
128-
{"boot_verbose", "verbose", 'v', RB_VERBOSE},
129-
{"boot_serial", "serial", 'h', RB_SERIAL},
130-
{"boot_cdrom", "cdrom", 'C', RB_CDROM},
131-
{NULL, "poweroff", '-', RB_POWEROFF},
132-
{"boot_gdb", "gdb", 'g', RB_GDB},
133-
{"boot_mute", "mute", 'm', RB_MUTE},
134-
{NULL, "selftest", '-', RB_SELFTEST},
135-
{NULL, "RESERVED01", '-', RB_RESERVED01},
136-
{NULL, "RESERVED02", '-', RB_RESERVED02},
137-
{"boot_pause", "pause", 'p', RB_PAUSE},
138-
{NULL, "quiet", 'q', RB_QUIET},
139-
{NULL, "noint", 'n', RB_NOINTR},
140-
{"boot_multicons", "dual", 'D', RB_DUAL},
141-
{"boot_multicons", "video", '-', RB_VIDEO},
142-
{"boot_multicons", "multiple", 'M', RB_MULTIPLE},
143-
{NULL, "bootinfo", '-', RB_BOOTINFO}
144-
};
145-
146110
/* convert flags to environment "boot_xxx" strings */
147-
/* copied from /build/freebsd/sys/sys/boot.h, /build/freebsd/sys/kern/subr_boot.c */
148111
static void howtoflags2env(uint32_t howto)
149112
{
150113
uint32_t i;
151-
for (i = 0; howto_names[i].mask != RB_BOOTINFO; i++) {
152-
if (howto_names[i].ev != NULL && (howto & howto_names[i].mask)) {
153-
printf("add:%s\n",howto_names[i].ev);
114+
for (i = 0; howto_names[i].mask != 0; i++) {
115+
if (howto & howto_names[i].mask) {
154116
setenv(howto_names[i].ev, "YES", 1);
155117
}
156118
}
157-
printf("\n");
119+
}
120+
121+
static void setconsole(void)
122+
{
123+
if (initial_howto & RB_MUTE)
124+
setenv("console", "nullconsole", 1);
125+
else if (!strcmp(getenv("boot_multicons"), "YES")) {
126+
if (!strcmp(getenv("boot_serial"), "YES"))
127+
setenv("console", "comconsole vidconsole", 1);
128+
else
129+
setenv("console", "vidconsole comconsole", 1);
130+
}
131+
else if (!strcmp(getenv("boot_serial"), "YES"))
132+
setenv("console", "comconsole", 1);
158133
}
159134

160135
int
@@ -210,34 +185,14 @@ main(void)
210185
setheap((void *)heapbase, (void *)memtop);
211186

212187
/*
213-
* XXX Chicken-and-egg problem; we want to have console output early,
214-
* but some console attributes may depend on reading from eg. the boot
215-
* device, which we can't do yet.
216-
*
217-
* We can use printf() etc. once this is done. The previous boot stage
218-
* might have requested a video or serial preference, in which case we
219-
* set it. If neither is specified or both are specified we leave the
220-
* console environment variable alone, defaulting to dual boot.
188+
* Initialise the block cache
221189
*/
222-
howtoflags2env(initial_howto);
223-
if (initial_howto & RB_MUTE)
224-
setenv("console", "nullconsole", 1);
225-
else if ((initial_howto & RB_MULTIPLE) == RB_MULTIPLE ||
226-
(initial_howto & RB_DUAL) == RB_DUAL ||
227-
(initial_howto & (RB_VIDEO|RB_SERIAL)) == (RB_VIDEO|RB_SERIAL) /* old implementation */
228-
) {
229-
if (initial_howto & RB_SERIAL)
230-
setenv("console", "comconsole vidconsole", 1);
231-
else
232-
setenv("console", "vidconsole comconsole", 1);
233-
} else if (initial_howto & RB_SERIAL)
234-
setenv("console", "comconsole", 1);
235-
cons_probe();
190+
bcache_init(32, 512); /* 16k cache XXX tune this */
236191

237192
/*
238-
* Initialise the block cache
193+
* convert flags to environment boot_xxxx entries
239194
*/
240-
bcache_init(32, 512); /* 16k cache XXX tune this */
195+
howtoflags2env(initial_howto);
241196

242197
/*
243198
* Special handling for PXE and CD booting.
@@ -253,6 +208,19 @@ main(void)
253208
bc_add(initial_bootdev);
254209
}
255210

211+
/*
212+
* XXX Chicken-and-egg problem; we want to have console output early,
213+
* but some console attributes may depend on reading from eg. the boot
214+
* device, which we can't do yet.
215+
*
216+
* We can use printf() etc. once this is done. The previous boot stage
217+
* might have requested a video or serial preference, in which case we
218+
* set it. If neither is specified or both are specified we leave the
219+
* console environment variable alone, defaulting to dual boot.
220+
*/
221+
setconsole();
222+
cons_probe();
223+
256224
/*
257225
* March through the device switch probing for things.
258226
*/
@@ -288,11 +256,10 @@ main(void)
288256
#if COMCONSOLE_DEBUG
289257
printf("args at %p initial_howto = %08x bootdev = %08x bootinfo = %p\n",
290258
kargs, initial_howto, initial_bootdev, initial_bootinfo);
291-
if (initial_howto & RB_SERIAL) {
259+
if (initial_howto & RB_SERIAL || initial_howto & RB_MULTIPLE || initial_howto & RB_DUAL) {
292260
printf("Serial at Speed:%s on Port:%s\n", getenv("comconsole_speed"), getenv("comconsole_port"));
293261
}
294262
#endif
295-
howtoflags2env(initial_howto);
296263

297264
extract_currdev(); /* set $currdev and $loaddev */
298265
setenv("LINES", "24", 1); /* optional */

sys/boot/pc32/pxeldr/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ BTXDIR= ${.CURDIR}/../btx
3434
BTXLDR= ${BTXDIR}/btxldr/btxldr
3535
BTXKERN= ${BTXDIR}/btx/btx
3636
BTXCRT= ${BTXDIR}/lib/crt0.o
37+
CFLAGS+= -I../../..
3738

3839
${BOOT}: ${LDR} ${LOADER}
3940
cat ${LDR} ${LOADER} > ${.TARGET}.tmp

sys/boot/pc32/pxeldr/pxeldr.S

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@
4545
*/
4646
.set KARGS_FLAGS_PXE,0x2 # flag to indicate booting from
4747
# PXE loader
48-
/*
49-
* Boot howto bits
50-
*/
51-
//.set RB_SERIAL,0x1000 # serial console
5248

5349
/*
5450
* Segment selectors.
@@ -111,6 +107,9 @@ start: cld # string ops inc
111107
orb $KARGS_FLAGS_PXE, 0x8(%bx) # kargs->bootflags |=
112108
# KARGS_FLAGS_PXE
113109
popl 0xc(%bx) # kargs->pxeinfo = *PXENV+
110+
#if !defined(ALWAYS_SERIAL) && !defined(PROBE_KEYBOARD)
111+
orl $(RB_DUAL | RB_MULTIPLE), (%bx) # enable multi console
112+
#endif
114113
#ifdef ALWAYS_SERIAL
115114
/*
116115
* set the RBX_SERIAL bit in the howto byte.
@@ -125,7 +124,6 @@ start: cld # string ops inc
125124
*/
126125
testb $KEYBOARD_BIT, BDA_KEYBOARD # keyboard present?
127126
jnz keyb # yes, so skip
128-
//orl $RB_SERIAL, (%bx) # enable serial console
129127
orl $(RB_MULTIPLE | RB_SERIAL), (%bx) # enable serial console
130128
keyb:
131129
#endif

sys/sys/boot.h

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,50 @@
3636
static struct
3737
{
3838
const char *ev;
39+
const char flag;
3940
int mask;
4041
} howto_names[] = {
41-
{ "boot_askname", RB_ASKNAME},
42-
{ "boot_cdrom", RB_CDROM},
43-
{ "boot_ddb", RB_KDB},
44-
{ "boot_gdb", RB_GDB},
45-
{ "boot_single", RB_SINGLE},
46-
{ "boot_verbose", RB_VERBOSE},
47-
{ "boot_vidcons", RB_VIDEO},
48-
{ "boot_serial", RB_SERIAL},
49-
{ NULL, 0}
42+
{"boot_askname", 'a', RB_ASKNAME},
43+
{"boot_single", 's', RB_SINGLE},
44+
/*
45+
{NULL, '-', RB_NOSYNC},
46+
{NULL, '-', RB_HALT},
47+
{NULL, '-', RB_INITNAME},
48+
*/
49+
{"boot_dfltroot", 'r', RB_DFLTROOT},
50+
{"boot_ddb", 'd', RB_KDB},
51+
/*
52+
{NULL, '-', RB_RDONLY},
53+
{NULL, '-', RB_DUMP},
54+
{NULL, '-', RB_MINIROOT},
55+
{NULL, 'c', RB_CONFIG},
56+
*/
57+
{"boot_verbose", 'v', RB_VERBOSE},
58+
{"boot_serial", 'h', RB_SERIAL},
59+
{"boot_cdrom", 'C', RB_CDROM},
60+
/*
61+
{NULL, '-', RB_POWEROFF},
62+
*/
63+
{"boot_gdb", 'g', RB_GDB},
64+
{"boot_mute", 'm', RB_MUTE},
65+
/*
66+
{NULL, '-', RB_SELFTEST},
67+
{NULL, '-', RB_RESERVED01},
68+
{NULL, '-', RB_RESERVED02},
69+
*/
70+
{"boot_pause", 'p', RB_PAUSE},
71+
/*
72+
{NULL, 'q', RB_QUIET},
73+
{NULL, 'n', RB_NOINTR},
74+
*/
75+
{"boot_multicons", 'D', RB_DUAL},
76+
{"boot_vidcons", '-', RB_VIDEO},
77+
{"boot_multicons", 'M', RB_MULTIPLE},
78+
/*
79+
{NULL, '-', RB_BOOTINFO},
80+
*/
81+
{NULL, '-', 0}
82+
5083
};
5184

5285
#endif /* !_SYS_BOOT_H_ */

sys/sys/reboot.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@
7272
//#define RB_UNUSED05 0x04000000
7373
#define RB_NOINTR 0x08000000 /* Non Interruptable come up (-n) */
7474
#define RB_DUAL 0x10000000 /* use comconsole and vidconsole (-D) */
75-
//#define RB_PROBE 0x20000000 /* Probe multiple consoles (fbsd) */
7675

7776
/* temp fixup */
78-
#define RB_VIDEO 0x40000000 /* use video console */
77+
//#define RB_PROBE 0x20000000 /* Probe multiple consoles (fbsd) */
78+
#define RB_VIDEO 0x20000000 /* use video console */
7979
#define RB_MULTIPLE 0x40000000 /* use multiple consoles (-D) */
8080
/* end temp */
8181

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/DragonFlyBSD/DragonFlyBSD/commit/234ac8c0ad606eb0fd557eeebd62ba20ca1ca26f

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy