Use 32-bit ufs_ino_t instead of ino_t to keep boot2 small and prevent

unnecessary 64-bit math on 32-bit machines.

Sponsored by:	Google Summer of Code 2011
This commit is contained in:
Gleb Kurtsou 2012-05-25 09:36:39 +00:00
parent 5ca724dc59
commit 491a40587d
8 changed files with 26 additions and 31 deletions

View File

@ -95,7 +95,6 @@ static uint8_t dsk_meta;
static void load(void);
static int parse(void);
static int xfsread(ino_t, void *, size_t);
static int dskread(void *, unsigned, unsigned);
#ifdef FIXUP_BOOT_DRV
static void fixup_boot_drv(caddr_t, int, int, int);
@ -111,7 +110,7 @@ static void fixup_boot_drv(caddr_t, int, int, int);
#endif
static inline int
xfsread(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)
return -1;
@ -154,7 +153,7 @@ int
main(void)
{
int autoboot, c = 0;
ino_t ino;
ufs_ino_t ino;
dmadat = (void *)(0x20000000 + (16 << 20));
board_init();
@ -199,7 +198,7 @@ load(void)
Elf32_Ehdr eh;
static Elf32_Phdr ep[2];
caddr_t p;
ino_t ino;
ufs_ino_t ino;
uint32_t addr;
int i, j;
#ifdef FIXUP_BOOT_DRV

View File

@ -98,7 +98,6 @@ static int disk_layout;
static void load(void);
static int parse(void);
static int xfsread(ino_t, void *, size_t);
static int dskread(void *, unsigned, unsigned);
static int drvread(void *, unsigned, unsigned);
#ifdef FIXUP_BOOT_DRV
@ -114,7 +113,7 @@ static void fixup_boot_drv(caddr_t, int, int, int);
#endif
static inline int
xfsread(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)
return -1;
@ -158,7 +157,7 @@ main(void)
{
const char *bt;
int autoboot, c = 0;
ino_t ino;
ufs_ino_t ino;
dmadat = (void *)(0x1c0000);
p_memset((char *)dmadat, 0, 32 * 1024);
@ -207,7 +206,7 @@ load(void)
Elf32_Ehdr eh;
static Elf32_Phdr ep[2];
caddr_t p;
ino_t ino;
ufs_ino_t ino;
uint32_t addr;
int i, j;
#ifdef FIXUP_BOOT_DRV

View File

@ -58,6 +58,8 @@ __FBSDID("$FreeBSD$");
#define cgbase(fs, c) ((ufs2_daddr_t)((fs)->fs_fpg * (c)))
#endif
typedef uint32_t ufs_ino_t;
/*
* We use 4k `virtual' blocks for filesystem data, whatever the actual
* filesystem block size. FFS blocks are always a multiple of 4k.
@ -85,14 +87,14 @@ struct dmadat {
};
static struct dmadat *dmadat;
static ino_t lookup(const char *);
static ssize_t fsread(ino_t, void *, size_t);
static ufs_ino_t lookup(const char *);
static ssize_t fsread(ufs_ino_t, void *, size_t);
static uint8_t ls, dsk_meta;
static uint32_t fs_off;
static __inline uint8_t
fsfind(const char *name, ino_t * ino)
fsfind(const char *name, ufs_ino_t * ino)
{
static char buf[DEV_BSIZE];
struct direct *d;
@ -116,12 +118,12 @@ fsfind(const char *name, ino_t * ino)
return 0;
}
static ino_t
static ufs_ino_t
lookup(const char *path)
{
static char name[MAXNAMLEN + 1];
const char *s;
ino_t ino;
ufs_ino_t ino;
ssize_t n;
uint8_t dt;
@ -163,7 +165,7 @@ static int sblock_try[] = SBLOCKSEARCH;
#endif
static ssize_t
fsread(ino_t inode, void *buf, size_t nbyte)
fsread(ufs_ino_t inode, void *buf, size_t nbyte)
{
#ifndef UFS2_ONLY
static struct ufs1_dinode dp1;
@ -173,7 +175,7 @@ fsread(ino_t inode, void *buf, size_t nbyte)
static struct ufs2_dinode dp2;
#endif
static struct fs fs;
static ino_t inomap;
static ufs_ino_t inomap;
char *blkbuf;
void *indbuf;
char *s;

View File

@ -138,7 +138,6 @@ static uint8_t ioctrl = IO_KEYBOARD;
void exit(int);
static void load(void);
static int parse(void);
static int xfsread(ino_t, void *, size_t);
static int dskread(void *, unsigned, unsigned);
static void printf(const char *,...);
static void putchar(int);
@ -170,7 +169,7 @@ strcmp(const char *s1, const char *s2)
#include "ufsread.c"
static inline int
xfsread(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) {
printf("Invalid %s\n", "format");
@ -222,7 +221,7 @@ int
main(void)
{
uint8_t autoboot;
ino_t ino;
ufs_ino_t ino;
size_t nbyte;
dmadat = (void *)(roundup2(__base + (int32_t)&_end, 0x10000) - __base);
@ -307,7 +306,7 @@ load(void)
static Elf32_Phdr ep[2];
static Elf32_Shdr es[2];
caddr_t p;
ino_t ino;
ufs_ino_t ino;
uint32_t addr;
int i, j;

View File

@ -90,14 +90,13 @@ static struct bootinfo bootinfo;
void exit(int);
static void load(void);
static int parse(char *, int *);
static int xfsread(ino_t, void *, size_t);
static int dskread(void *, daddr_t, unsigned);
static uint32_t memsize(void);
#include "ufsread.c"
static inline int
xfsread(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) {
@ -138,7 +137,7 @@ main(void)
{
char cmd[512], cmdtmp[512];
int autoboot, dskupdated;
ino_t ino;
ufs_ino_t ino;
dmadat = (void *)(roundup2(__base + (int32_t)&_end, 0x10000) - __base);
v86.ctl = V86_FLAGS;
@ -247,7 +246,7 @@ load(void)
static Elf32_Phdr ep[2];
static Elf32_Shdr es[2];
caddr_t p;
ino_t ino;
ufs_ino_t ino;
uint32_t addr, x;
int fmt, i, j;

View File

@ -140,7 +140,6 @@ static uint8_t ioctrl = IO_KEYBOARD;
void exit(int);
static void load(void);
static int parse(void);
static int xfsread(ino_t, void *, size_t);
static int dskread(void *, unsigned, unsigned);
static void printf(const char *,...);
static void putchar(int);
@ -172,7 +171,7 @@ strcmp(const char *s1, const char *s2)
#include "ufsread.c"
static inline int
xfsread(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) {
printf("Invalid %s\n", "format");
@ -351,7 +350,7 @@ main(void)
int i;
#endif
uint8_t autoboot;
ino_t ino;
ufs_ino_t ino;
size_t nbyte;
dmadat = (void *)(roundup2(__base + (int32_t)&_end, 0x10000) - __base);
@ -446,7 +445,7 @@ load(void)
static Elf32_Phdr ep[2];
static Elf32_Shdr es[2];
caddr_t p;
ino_t ino;
ufs_ino_t ino;
uint32_t addr;
int i, j;

View File

@ -45,7 +45,6 @@ static char bootargs[128];
static ofwh_t bootdev;
static struct fs fs;
static ino_t inomap;
static char blkbuf[BSIZEMAX];
static unsigned int fsblks;
@ -492,7 +491,7 @@ load(const char *fname)
Elf32_Ehdr eh;
Elf32_Phdr ph;
caddr_t p;
ino_t ino;
ufs_ino_t ino;
int i;
if ((ino = lookup(fname)) == 0) {

View File

@ -415,7 +415,6 @@ loadzfs(void)
Elf64_Ehdr eh;
Elf64_Phdr ph;
caddr_t p;
ino_t ino;
int i;
if (zbread((char *)&eh, 0, sizeof(eh)) != sizeof(eh)) {
@ -459,7 +458,7 @@ load(const char *fname)
Elf64_Ehdr eh;
Elf64_Phdr ph;
caddr_t p;
ino_t ino;
ufs_ino_t ino;
int i;
if ((ino = lookup(fname)) == 0) {