Changeset View
Changeset View
Standalone View
Standalone View
stand/powerpc/boot1.chrp/boot1.c
Show All 18 Lines | |||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/dirent.h> | #include <sys/dirent.h> | ||||
#include <machine/elf.h> | #include <machine/elf.h> | ||||
#include <machine/stdarg.h> | #include <machine/stdarg.h> | ||||
#include <machine/md_var.h> | #include <machine/md_var.h> | ||||
#include <ufs/ffs/fs.h> | |||||
#include "paths.h" | #include "paths.h" | ||||
#include "ufsread.h" | |||||
#define BSIZEMAX 16384 | #define BSIZEMAX 16384 | ||||
typedef int putc_func_t(char c, void *arg); | typedef int putc_func_t(char c, void *arg); | ||||
typedef int32_t ofwh_t; | typedef int32_t ofwh_t; | ||||
struct sp_data { | struct sp_data { | ||||
char *sp_buf; | char *sp_buf; | ||||
u_int sp_len; | u_int sp_len; | ||||
u_int sp_size; | u_int sp_size; | ||||
}; | }; | ||||
static const char digits[] = "0123456789abcdef"; | static const char digits[] = "0123456789abcdef"; | ||||
static char bootpath[128]; | static char bootpath[128]; | ||||
static char bootargs[128]; | static char bootargs[128]; | ||||
static ofwh_t bootdev; | static ofwh_t bootdev; | ||||
static struct fs fs; | static struct fs fs; | ||||
static char blkbuf[BSIZEMAX]; | static char blkbuf[BSIZEMAX]; | ||||
static unsigned int fsblks; | static unsigned int fsblks; | ||||
static uint32_t fs_off; | |||||
int main(int ac, char **av); | int main(int ac, char **av); | ||||
int dskread(void *, u_int64_t, int); | |||||
void memcpy(void *dst, const void *src, size_t len); | |||||
int printf(const char *fmt, ...); | |||||
int strcmp(const char *s1, const char *s2); | |||||
static void exit(int) __dead2; | static void exit(int) __dead2; | ||||
static void load(const char *); | static void load(const char *); | ||||
static int dskread(void *, u_int64_t, int); | |||||
static void usage(void); | static void usage(void); | ||||
static void bcopy(const void *src, void *dst, size_t len); | static void bcopy(const void *src, void *dst, size_t len); | ||||
static void bzero(void *b, size_t len); | static void bzero(void *b, size_t len); | ||||
static int domount(const char *device, int quiet); | static int domount(const char *device, int quiet); | ||||
static void panic(const char *fmt, ...) __dead2; | static void panic(const char *fmt, ...) __dead2; | ||||
static int printf(const char *fmt, ...); | |||||
static int putchar(char c, void *arg); | static int putchar(char c, void *arg); | ||||
static int vprintf(const char *fmt, va_list ap); | static int vprintf(const char *fmt, va_list ap); | ||||
static int vsnprintf(char *str, size_t sz, const char *fmt, va_list ap); | static int vsnprintf(char *str, size_t sz, const char *fmt, va_list ap); | ||||
static int __printf(const char *fmt, putc_func_t *putc, void *arg, va_list ap); | static int __printf(const char *fmt, putc_func_t *putc, void *arg, va_list ap); | ||||
static int __putc(char c, void *arg); | static int __putc(char c, void *arg); | ||||
static int __puts(const char *s, putc_func_t *putc, void *arg); | static int __puts(const char *s, putc_func_t *putc, void *arg); | ||||
static int __sputc(char c, void *arg); | static int __sputc(char c, void *arg); | ||||
▲ Show 20 Lines • Show All 283 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
const char *s = src; | const char *s = src; | ||||
char *d = dst; | char *d = dst; | ||||
while (len-- != 0) | while (len-- != 0) | ||||
*d++ = *s++; | *d++ = *s++; | ||||
} | } | ||||
static void | void | ||||
memcpy(void *dst, const void *src, size_t len) | memcpy(void *dst, const void *src, size_t len) | ||||
{ | { | ||||
bcopy(src, dst, len); | bcopy(src, dst, len); | ||||
} | } | ||||
static void | static void | ||||
bzero(void *b, size_t len) | bzero(void *b, size_t len) | ||||
{ | { | ||||
char *p = b; | char *p = b; | ||||
while (len-- != 0) | while (len-- != 0) | ||||
*p++ = 0; | *p++ = 0; | ||||
} | } | ||||
static 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 ((u_char)*s1 - (u_char)*s2); | return ((u_char)*s1 - (u_char)*s2); | ||||
} | } | ||||
#include "ufsread.c" | |||||
int | int | ||||
main(int ac, char **av) | main(int ac, char **av) | ||||
{ | { | ||||
const char *path; | const char *path; | ||||
char bootpath_full[255]; | char bootpath_full[255]; | ||||
int i, len; | int i, len; | ||||
path = PATH_LOADER; | path = PATH_LOADER; | ||||
▲ Show 20 Lines • Show All 135 Lines • ▼ Show 20 Lines | if (ph.p_filesz != ph.p_memsz) | ||||
bzero(p + ph.p_filesz, ph.p_memsz - ph.p_filesz); | bzero(p + ph.p_filesz, ph.p_memsz - ph.p_filesz); | ||||
__syncicache(p, ph.p_memsz); | __syncicache(p, ph.p_memsz); | ||||
} | } | ||||
ofw_close(bootdev); | ofw_close(bootdev); | ||||
(*(void (*)(void *, int, ofwfp_t, char *, int))eh.e_entry)(NULL, 0, | (*(void (*)(void *, int, ofwfp_t, char *, int))eh.e_entry)(NULL, 0, | ||||
ofw,NULL,0); | ofw,NULL,0); | ||||
} | } | ||||
static int | int | ||||
dskread(void *buf, u_int64_t lba, int nblk) | dskread(void *buf, u_int64_t lba, int nblk) | ||||
{ | { | ||||
/* | /* | ||||
* The Open Firmware should open the correct partition for us. | * The Open Firmware should open the correct partition for us. | ||||
* That means, if we read from offset zero on an open instance handle, | * That means, if we read from offset zero on an open instance handle, | ||||
* we should read from offset zero of that partition. | * we should read from offset zero of that partition. | ||||
*/ | */ | ||||
ofw_seek(bootdev, lba * DEV_BSIZE); | ofw_seek(bootdev, lba * DEV_BSIZE); | ||||
Show All 10 Lines | panic(const char *fmt, ...) | ||||
va_start(ap, fmt); | va_start(ap, fmt); | ||||
vsnprintf(buf, sizeof buf, fmt, ap); | vsnprintf(buf, sizeof buf, fmt, ap); | ||||
printf("panic: %s\n", buf); | printf("panic: %s\n", buf); | ||||
va_end(ap); | va_end(ap); | ||||
exit(1); | exit(1); | ||||
} | } | ||||
static int | int | ||||
printf(const char *fmt, ...) | printf(const char *fmt, ...) | ||||
{ | { | ||||
va_list ap; | va_list ap; | ||||
int ret; | int ret; | ||||
va_start(ap, fmt); | va_start(ap, fmt); | ||||
ret = vprintf(fmt, ap); | ret = vprintf(fmt, ap); | ||||
va_end(ap); | va_end(ap); | ||||
▲ Show 20 Lines • Show All 198 Lines • Show Last 20 Lines |