Changeset View
Changeset View
Standalone View
Standalone View
sys/boot/efi/boot1/boot1.c
Show All 30 Lines | |||||
#define _PATH_LOADER "/boot/loader.efi" | #define _PATH_LOADER "/boot/loader.efi" | ||||
#define _PATH_KERNEL "/boot/kernel/kernel" | #define _PATH_KERNEL "/boot/kernel/kernel" | ||||
#define BSIZEMAX 16384 | #define BSIZEMAX 16384 | ||||
void panic(const char *fmt, ...) __dead2; | void panic(const char *fmt, ...) __dead2; | ||||
void putchar(int c); | void putchar(int c); | ||||
EFI_STATUS efi_main(EFI_HANDLE Ximage, EFI_SYSTEM_TABLE* Xsystab); | |||||
static int domount(EFI_DEVICE_PATH *device, EFI_BLOCK_IO *blkio, int quiet); | static int domount(EFI_DEVICE_PATH *device, EFI_BLOCK_IO *blkio, int quiet); | ||||
static void load(const char *fname); | static void load(const char *fname); | ||||
static EFI_SYSTEM_TABLE *systab; | static EFI_SYSTEM_TABLE *systab; | ||||
static EFI_HANDLE *image; | static EFI_HANDLE *image; | ||||
static EFI_GUID BlockIoProtocolGUID = BLOCK_IO_PROTOCOL; | static EFI_GUID BlockIoProtocolGUID = BLOCK_IO_PROTOCOL; | ||||
Show All 10 Lines | EFI_STATUS efi_main(EFI_HANDLE Ximage, EFI_SYSTEM_TABLE* Xsystab) | ||||
EFI_HANDLE handles[128]; | EFI_HANDLE handles[128]; | ||||
EFI_BLOCK_IO *blkio; | EFI_BLOCK_IO *blkio; | ||||
UINTN i, nparts = sizeof(handles), cols, rows, max_dim, best_mode; | UINTN i, nparts = sizeof(handles), cols, rows, max_dim, best_mode; | ||||
EFI_STATUS status; | EFI_STATUS status; | ||||
EFI_DEVICE_PATH *devpath; | EFI_DEVICE_PATH *devpath; | ||||
EFI_BOOT_SERVICES *BS; | EFI_BOOT_SERVICES *BS; | ||||
EFI_CONSOLE_CONTROL_PROTOCOL *ConsoleControl = NULL; | EFI_CONSOLE_CONTROL_PROTOCOL *ConsoleControl = NULL; | ||||
SIMPLE_TEXT_OUTPUT_INTERFACE *conout = NULL; | SIMPLE_TEXT_OUTPUT_INTERFACE *conout = NULL; | ||||
char *path = _PATH_LOADER; | const char *path = _PATH_LOADER; | ||||
systab = Xsystab; | systab = Xsystab; | ||||
image = Ximage; | image = Ximage; | ||||
BS = systab->BootServices; | BS = systab->BootServices; | ||||
status = BS->LocateProtocol(&ConsoleControlGUID, NULL, | status = BS->LocateProtocol(&ConsoleControlGUID, NULL, | ||||
(VOID **)&ConsoleControl); | (VOID **)&ConsoleControl); | ||||
if (status == EFI_SUCCESS) | if (status == EFI_SUCCESS) | ||||
▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | |||||
#include "ufsread.c" | #include "ufsread.c" | ||||
static ssize_t | static ssize_t | ||||
fsstat(ufs_ino_t inode) | fsstat(ufs_ino_t inode) | ||||
{ | { | ||||
#ifndef UFS2_ONLY | #ifndef UFS2_ONLY | ||||
static struct ufs1_dinode dp1; | static struct ufs1_dinode dp1; | ||||
ufs1_daddr_t addr1; | |||||
#endif | #endif | ||||
#ifndef UFS1_ONLY | #ifndef UFS1_ONLY | ||||
static struct ufs2_dinode dp2; | static struct ufs2_dinode dp2; | ||||
#endif | #endif | ||||
static struct fs fs; | static struct fs fs; | ||||
static ufs_ino_t inomap; | static ufs_ino_t inomap; | ||||
char *blkbuf; | char *blkbuf; | ||||
void *indbuf; | void *indbuf; | ||||
size_t n, nb, size, off, vboff; | size_t n, size; | ||||
ufs_lbn_t lbn; | |||||
ufs2_daddr_t addr2, vbaddr; | |||||
static ufs2_daddr_t blkmap, indmap; | static ufs2_daddr_t blkmap, indmap; | ||||
u_int u; | |||||
blkbuf = dmadat->blkbuf; | blkbuf = dmadat->blkbuf; | ||||
indbuf = dmadat->indbuf; | indbuf = dmadat->indbuf; | ||||
if (!dsk_meta) { | if (!dsk_meta) { | ||||
inomap = 0; | inomap = 0; | ||||
for (n = 0; sblock_try[n] != -1; n++) { | for (n = 0; sblock_try[n] != -1; n++) { | ||||
if (dskread(dmadat->sbbuf, sblock_try[n] / DEV_BSIZE, | if (dskread(dmadat->sbbuf, sblock_try[n] / DEV_BSIZE, | ||||
SBLOCKSIZE / DEV_BSIZE)) | SBLOCKSIZE / DEV_BSIZE)) | ||||
return -1; | return -1; | ||||
memcpy(&fs, dmadat->sbbuf, sizeof(struct fs)); | memcpy(&fs, dmadat->sbbuf, sizeof(struct fs)); | ||||
if (( | if (( | ||||
#if defined(UFS1_ONLY) | #if defined(UFS1_ONLY) | ||||
fs.fs_magic == FS_UFS1_MAGIC | fs.fs_magic == FS_UFS1_MAGIC | ||||
#elif defined(UFS2_ONLY) | #elif defined(UFS2_ONLY) | ||||
(fs.fs_magic == FS_UFS2_MAGIC && | (fs.fs_magic == FS_UFS2_MAGIC && | ||||
fs.fs_sblockloc == sblock_try[n]) | fs.fs_sblockloc == sblock_try[n]) | ||||
#else | #else | ||||
fs.fs_magic == FS_UFS1_MAGIC || | fs.fs_magic == FS_UFS1_MAGIC || | ||||
(fs.fs_magic == FS_UFS2_MAGIC && | (fs.fs_magic == FS_UFS2_MAGIC && | ||||
fs.fs_sblockloc == sblock_try[n]) | fs.fs_sblockloc == sblock_try[n]) | ||||
#endif | #endif | ||||
) && | ) && | ||||
fs.fs_bsize <= MAXBSIZE && | fs.fs_bsize <= MAXBSIZE && | ||||
fs.fs_bsize >= sizeof(struct fs)) | fs.fs_bsize >= (int32_t)sizeof(struct fs)) | ||||
break; | break; | ||||
} | } | ||||
if (sblock_try[n] == -1) { | if (sblock_try[n] == -1) { | ||||
return -1; | return -1; | ||||
} | } | ||||
dsk_meta++; | dsk_meta++; | ||||
} else | } else | ||||
memcpy(&fs, dmadat->sbbuf, sizeof(struct fs)); | memcpy(&fs, dmadat->sbbuf, sizeof(struct fs)); | ||||
if (!inode) | if (!inode) | ||||
return 0; | return 0; | ||||
if (inomap != inode) { | if (inomap != inode) { | ||||
n = IPERVBLK(&fs); | n = IPERVBLK(&fs); | ||||
if (dskread(blkbuf, INO_TO_VBA(&fs, n, inode), DBPERVBLK)) | if (dskread(blkbuf, INO_TO_VBA(&fs, n, inode), DBPERVBLK)) | ||||
return -1; | return -1; | ||||
n = INO_TO_VBO(n, inode); | n = INO_TO_VBO(n, inode); | ||||
#if defined(UFS1_ONLY) | #if defined(UFS1_ONLY) | ||||
memcpy(&dp1, (struct ufs1_dinode *)blkbuf + n, | memcpy(&dp1, (struct ufs1_dinode *)blkbuf + n, | ||||
sizeof(struct ufs1_dinode)); | sizeof(struct ufs1_dinode)); | ||||
#elif defined(UFS2_ONLY) | #elif defined(UFS2_ONLY) | ||||
memcpy(&dp2, (struct ufs2_dinode *)blkbuf + n, | memcpy(&dp2, (struct ufs2_dinode *)blkbuf + n, | ||||
sizeof(struct ufs2_dinode)); | sizeof(struct ufs2_dinode)); | ||||
#else | #else | ||||
if (fs.fs_magic == FS_UFS1_MAGIC) | if (fs.fs_magic == FS_UFS1_MAGIC) | ||||
memcpy(&dp1, (struct ufs1_dinode *)blkbuf + n, | memcpy(&dp1, (struct ufs1_dinode *)(void *)blkbuf + n, | ||||
sizeof(struct ufs1_dinode)); | sizeof(struct ufs1_dinode)); | ||||
else | else | ||||
memcpy(&dp2, (struct ufs2_dinode *)blkbuf + n, | memcpy(&dp2, (struct ufs2_dinode *)(void *)blkbuf + n, | ||||
sizeof(struct ufs2_dinode)); | sizeof(struct ufs2_dinode)); | ||||
#endif | #endif | ||||
inomap = inode; | inomap = inode; | ||||
fs_off = 0; | fs_off = 0; | ||||
blkmap = indmap = 0; | blkmap = indmap = 0; | ||||
} | } | ||||
size = DIP(di_size); | size = DIP(di_size); | ||||
n = size - fs_off; | n = size - fs_off; | ||||
▲ Show 20 Lines • Show All 91 Lines • Show Last 20 Lines |