Changeset View
Changeset View
Standalone View
Standalone View
stand/i386/boot2/boot2.c
Show All 19 Lines | |||||
#include <sys/disklabel.h> | #include <sys/disklabel.h> | ||||
#include <sys/diskmbr.h> | #include <sys/diskmbr.h> | ||||
#include <sys/dirent.h> | #include <sys/dirent.h> | ||||
#include <sys/reboot.h> | #include <sys/reboot.h> | ||||
#include <machine/bootinfo.h> | #include <machine/bootinfo.h> | ||||
#include <machine/elf.h> | #include <machine/elf.h> | ||||
#include <ufs/ffs/fs.h> | |||||
#include <stdarg.h> | #include <stdarg.h> | ||||
#include <a.out.h> | #include <a.out.h> | ||||
#include <btxv86.h> | #include <btxv86.h> | ||||
#include "boot2.h" | #include "boot2.h" | ||||
#include "lib.h" | #include "lib.h" | ||||
#include "paths.h" | #include "paths.h" | ||||
#include "rbx.h" | #include "rbx.h" | ||||
#include "ufsread.h" | |||||
/* Define to 0 to omit serial support */ | /* Define to 0 to omit serial support */ | ||||
#ifndef SERIAL | #ifndef SERIAL | ||||
#define SERIAL 1 | #define SERIAL 1 | ||||
#endif | #endif | ||||
#define IO_KEYBOARD 1 | #define IO_KEYBOARD 1 | ||||
#define IO_SERIAL 2 | #define IO_SERIAL 2 | ||||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | |||||
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; | ||||
#endif | #endif | ||||
int main(void); | int main(void); | ||||
void exit(int); | void exit(int); | ||||
void memcpy(void *, const void *, int); | |||||
void printf(const char *, ...); | |||||
int strcmp(const char *, const char *); | |||||
int dskread(void *, unsigned, unsigned); | |||||
static void load(void); | static void load(void); | ||||
static int parse(void); | static int parse(void); | ||||
static int dskread(void *, unsigned, unsigned); | |||||
static void printf(const char *,...); | |||||
static void putchar(int); | static void putchar(int); | ||||
static int drvread(void *, unsigned, unsigned); | static int drvread(void *, unsigned, unsigned); | ||||
static int keyhit(unsigned); | static int keyhit(unsigned); | ||||
static int xputc(int); | static int xputc(int); | ||||
static int xgetc(int); | static int xgetc(int); | ||||
static inline int getc(int); | static inline int getc(int); | ||||
static void memcpy(void *, const void *, int); | void | ||||
static void | |||||
memcpy(void *dst, const void *src, int len) | memcpy(void *dst, const void *src, int len) | ||||
{ | { | ||||
const char *s = src; | const char *s = src; | ||||
char *d = dst; | char *d = dst; | ||||
while (len--) | while (len--) | ||||
*d++ = *s++; | *d++ = *s++; | ||||
} | } | ||||
static inline int | int | ||||
strcmp(const char *s1, const char *s2) | strcmp(const char *s1, const char *s2) | ||||
{ | { | ||||
for (; *s1 == *s2 && *s1; s1++, s2++); | for (; *s1 == *s2 && *s1; s1++, s2++); | ||||
return (unsigned char)*s1 - (unsigned char)*s2; | return (unsigned char)*s1 - (unsigned char)*s2; | ||||
} | } | ||||
#define UFS_SMALL_CGBASE | |||||
#include "ufsread.c" | |||||
static int | static int | ||||
xfsread(ufs_ino_t inode, void *buf, size_t nbyte) | xfsread(ufs_ino_t inode, void *buf, size_t nbyte) | ||||
{ | { | ||||
if ((size_t)fsread(inode, buf, nbyte) != nbyte) { | if ((size_t)fsread(inode, buf, nbyte) != nbyte) { | ||||
printf("Invalid %s\n", "format"); | printf("Invalid %s\n", "format"); | ||||
return -1; | return -1; | ||||
} | } | ||||
return 0; | return 0; | ||||
▲ Show 20 Lines • Show All 295 Lines • ▼ Show 20 Lines | #endif | ||||
kname = knamebuf; | kname = knamebuf; | ||||
} | } | ||||
} | } | ||||
arg = p; | arg = p; | ||||
} | } | ||||
return 0; | return 0; | ||||
} | } | ||||
static int | int | ||||
dskread(void *buf, unsigned lba, unsigned nblk) | dskread(void *buf, unsigned lba, unsigned nblk) | ||||
{ | { | ||||
struct dos_partition *dp; | struct dos_partition *dp; | ||||
struct disklabel *d; | struct disklabel *d; | ||||
char *sec; | char *sec; | ||||
unsigned i; | unsigned i; | ||||
uint8_t sl; | uint8_t sl; | ||||
const char *reason; | const char *reason; | ||||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | dskread(void *buf, unsigned lba, unsigned nblk) | ||||
} | } | ||||
} | } | ||||
return drvread(buf, dsk.start + lba, nblk); | return drvread(buf, dsk.start + lba, nblk); | ||||
error: | error: | ||||
printf("Invalid %s\n", reason); | printf("Invalid %s\n", reason); | ||||
return -1; | return -1; | ||||
} | } | ||||
static void | void | ||||
printf(const char *fmt,...) | printf(const char *fmt, ...) | ||||
{ | { | ||||
va_list ap; | va_list ap; | ||||
static char buf[10]; | static char buf[10]; | ||||
char *s; | char *s; | ||||
unsigned u; | unsigned u; | ||||
int c; | int c; | ||||
va_start(ap, fmt); | va_start(ap, fmt); | ||||
▲ Show 20 Lines • Show All 113 Lines • Show Last 20 Lines |