Changeset View
Changeset View
Standalone View
Standalone View
stand/i386/boot2/boot2.c
Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | |||||
#else | #else | ||||
#define DO_KBD (1) | #define DO_KBD (1) | ||||
#define DO_SIO (0) | #define DO_SIO (0) | ||||
#endif | #endif | ||||
#define SECOND 18 /* Circa that many ticks in a second. */ | #define SECOND 18 /* Circa that many ticks in a second. */ | ||||
#define ARGS 0x900 | #define ARGS 0x900 | ||||
#define NOPT 14 | #define NOPT 15 | ||||
#define NDEV 3 | #define NDEV 3 | ||||
#define MEM_BASE 0x12 | #define MEM_BASE 0x12 | ||||
#define MEM_EXT 0x15 | #define MEM_EXT 0x15 | ||||
#define DRV_HARD 0x80 | #define DRV_HARD 0x80 | ||||
#define DRV_MASK 0x7f | #define DRV_MASK 0x7f | ||||
#define TYPE_AD 0 | #define TYPE_AD 0 | ||||
#define TYPE_DA 1 | #define TYPE_DA 1 | ||||
#define TYPE_MAXHARD TYPE_DA | #define TYPE_MAXHARD TYPE_DA | ||||
#define TYPE_FD 2 | #define TYPE_FD 2 | ||||
extern uint32_t _end; | extern uint32_t _end; | ||||
static const char optstr[NOPT] = "DhaCcdgmnpqrsv"; /* Also 'P', 'S' */ | static const char optstr[NOPT] = "DhaCcdgmnpqRrsv"; /* Also 'P', 'S' */ | ||||
static const unsigned char flags[NOPT] = { | static const unsigned char flags[NOPT] = { | ||||
RBX_DUAL, | RBX_DUAL, | ||||
RBX_SERIAL, | RBX_SERIAL, | ||||
RBX_ASKNAME, | RBX_ASKNAME, | ||||
RBX_CDROM, | RBX_CDROM, | ||||
RBX_CONFIG, | RBX_CONFIG, | ||||
RBX_KDB, | RBX_KDB, | ||||
RBX_GDB, | RBX_GDB, | ||||
RBX_MUTE, | RBX_MUTE, | ||||
RBX_NOINTR, | RBX_NOINTR, | ||||
RBX_PAUSE, | RBX_PAUSE, | ||||
RBX_QUIET, | RBX_QUIET, | ||||
RBX_RTERM, | |||||
RBX_DFLTROOT, | RBX_DFLTROOT, | ||||
RBX_SINGLE, | RBX_SINGLE, | ||||
RBX_VERBOSE | RBX_VERBOSE | ||||
}; | }; | ||||
static const char *const dev_nm[NDEV] = {"ad", "da", "fd"}; | static const char *const dev_nm[NDEV] = {"ad", "da", "fd"}; | ||||
static const unsigned char dev_maj[NDEV] = {30, 4, 2}; | static const unsigned char dev_maj[NDEV] = {30, 4, 2}; | ||||
static struct dsk { | static struct dsk { | ||||
unsigned drive; | unsigned drive; | ||||
unsigned type; | unsigned type; | ||||
unsigned unit; | unsigned unit; | ||||
uint8_t slice; | uint8_t slice; | ||||
uint8_t part; | uint8_t part; | ||||
unsigned start; | unsigned start; | ||||
int init; | int init; | ||||
} dsk; | } dsk; | ||||
static char cmd[512], cmddup[512], knamebuf[1024]; | static char cmd[512], cmddup[512], knamebuf[1024]; | ||||
static const char *kname; | static const char *kname; | ||||
uint32_t opts; | uint32_t opts; | ||||
static struct bootinfo bootinfo; | static struct bootinfo bootinfo; | ||||
#if SERIAL | #if SERIAL | ||||
static int comspeed = SIOSPD; | static int comspeed = SIOSPD; | ||||
static uint8_t ioctrl = IO_KEYBOARD; | static uint8_t ioctrl = IO_KEYBOARD; | ||||
static const char resettermcmd[] = SIORST; | |||||
#endif | #endif | ||||
int main(void); | int main(void); | ||||
void exit(int); | void exit(int); | ||||
static void load(void); | static void load(void); | ||||
static int parse(void); | static int parse(void); | ||||
static int dskread(void *, unsigned, unsigned); | static int dskread(void *, unsigned, unsigned); | ||||
static void printf(const char *,...); | static void printf(const char *,...); | ||||
▲ Show 20 Lines • Show All 285 Lines • ▼ Show 20 Lines | #endif | ||||
if (i == NOPT - 1) | if (i == NOPT - 1) | ||||
return (-1); | return (-1); | ||||
opts ^= OPT_SET(flags[i]); | opts ^= OPT_SET(flags[i]); | ||||
} | } | ||||
#if SERIAL | #if SERIAL | ||||
ioctrl = OPT_CHECK(RBX_DUAL) ? (IO_SERIAL|IO_KEYBOARD) : | ioctrl = OPT_CHECK(RBX_DUAL) ? (IO_SERIAL|IO_KEYBOARD) : | ||||
OPT_CHECK(RBX_SERIAL) ? IO_SERIAL : IO_KEYBOARD; | OPT_CHECK(RBX_SERIAL) ? IO_SERIAL : IO_KEYBOARD; | ||||
if (DO_SIO) { | if (DO_SIO) { | ||||
if (sio_init(115200 / comspeed) != 0) | if (sio_init(115200 / comspeed) != 0) { | ||||
ioctrl &= ~IO_SERIAL; | ioctrl &= ~IO_SERIAL; | ||||
} else if (OPT_CHECK(RBX_RTERM)) { | |||||
for (i = 0; resettermcmd[i]; i++) | |||||
sio_putc(resettermcmd[i]); | |||||
sio_flush(); | |||||
} | |||||
imp: So this adds about 30-40 bytes of code to boot2. We've had size issues with this code forever... | |||||
Done Inline ActionsIt works for me :-) # pwd /usr/obj/nanobsd/gateway.v3/data/src/amd64.amd64/stand/i386/boot2 # ls -la boot2* -rw-r--r-- 1 root wheel 7680 Feb 24 21:28 boot2 -rwxr-xr-x 1 root wheel 5352 Feb 24 21:28 boot2.bin -rw-r--r-- 1 root wheel 23 Feb 24 21:28 boot2.h -rw-r--r-- 1 root wheel 7576 Feb 24 21:28 boot2.ld -rw-r--r-- 1 root wheel 512 Feb 24 21:28 boot2.ldr -rw-r--r-- 1 root wheel 10296 Feb 24 21:28 boot2.o -rwxr-xr-x 1 root wheel 15300 Feb 24 21:28 boot2.out # lev: It works for me :-)
```
# pwd
/usr/obj/nanobsd/gateway.v3/data/src/amd64. | |||||
} | } | ||||
#endif | #endif | ||||
} else { | } else { | ||||
for (q = arg--; *q && *q != '('; q++); | for (q = arg--; *q && *q != '('; q++); | ||||
if (*q) { | if (*q) { | ||||
drv = -1; | drv = -1; | ||||
if (arg[1] == ':') { | if (arg[1] == ':') { | ||||
drv = *arg - '0'; | drv = *arg - '0'; | ||||
▲ Show 20 Lines • Show All 242 Lines • Show Last 20 Lines |
So this adds about 30-40 bytes of code to boot2. We've had size issues with this code forever... how are we doing these days for size?