From 5430f75fb4a4834e8d23f348b742a71c9c6e70e5 Mon Sep 17 00:00:00 2001 From: Laurent Vivier Date: Wed, 2 Jun 2004 17:40:47 +0000 Subject: [PATCH] 64bit support --- tools/emile-first-info.c | 13 +++++++------ tools/emile-first-tune.c | 4 ++-- tools/emile-first.h | 34 +++++++++++++++++----------------- tools/emile-install.c | 14 ++++++++++---- tools/emile-second.h | 16 ++++++++-------- tools/emile.h | 30 +++++++++++++++--------------- 6 files changed, 59 insertions(+), 52 deletions(-) diff --git a/tools/emile-first-info.c b/tools/emile-first-info.c index 5cfe292..719692a 100644 --- a/tools/emile-first-info.c +++ b/tools/emile-first-info.c @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -52,7 +53,7 @@ int first_info(char* image) printf("Boot Block Header:\n\n"); printf("Boot blocks signature: 0x%x\n", read_short(&firstBlock.boot_block_header.ID)); - printf("Entry point to bootcode: 0x%lX\n", + printf("Entry point to bootcode: 0x%X\n", read_long(&firstBlock.boot_block_header.Entry)); printf("Boot blocks version number: %x\n", read_short(&firstBlock.boot_block_header.Version)); @@ -81,11 +82,11 @@ int first_info(char* image) read_short(&firstBlock.boot_block_header.CntFCBs)); printf("Number of event queue elements: %d\n", read_short(&firstBlock.boot_block_header.CntEvts)); - printf("System heap size on 128K Mac: 0x%lx\n", + printf("System heap size on 128K Mac: 0x%x\n", read_long(&firstBlock.boot_block_header.Heap128K)); - printf("System heap size on 256K Mac: 0x%lx\n", + printf("System heap size on 256K Mac: 0x%x\n", read_long(&firstBlock.boot_block_header.Heap256K)); - printf("System heap size on all machines: 0x%lx\n", + printf("System heap size on all machines: 0x%x\n", read_long(&firstBlock.boot_block_header.SysHeapSize)); if ( strncmp( firstBlock.boot_block_header.SysName+1, @@ -97,9 +98,9 @@ int first_info(char* image) read_short(&firstBlock.second_param_block.ioVRefNum)); printf("File reference number: %d\n", read_short(&firstBlock.second_param_block.ioRefNum)); - printf("Second level size: %ld\n", + printf("Second level size: %d\n", read_long(&firstBlock.second_param_block.ioReqCount)); - printf("Second level offset: %ld\n", + printf("Second level offset: %d\n", read_long(&firstBlock.second_param_block.ioPosOffset)); } diff --git a/tools/emile-first-tune.c b/tools/emile-first-tune.c index ffa22cf..06d4a73 100644 --- a/tools/emile-first-tune.c +++ b/tools/emile-first-tune.c @@ -80,9 +80,9 @@ int first_tune( char* image, unsigned short tune_mask, int drive_num, read_short(&firstBlock.second_param_block.ioVRefNum)); printf("File reference number: %d\n", read_short(&firstBlock.second_param_block.ioRefNum)); - printf("Second level size: %ld\n", + printf("Second level size: %d\n", read_long(&firstBlock.second_param_block.ioReqCount)); - printf("Second level offset: %ld\n", + printf("Second level offset: %d\n", read_long(&firstBlock.second_param_block.ioPosOffset)); } else diff --git a/tools/emile-first.h b/tools/emile-first.h index 3b6f517..77ee89d 100644 --- a/tools/emile-first.h +++ b/tools/emile-first.h @@ -18,22 +18,22 @@ typedef struct BootBlkHdr BootBlkHdr_t; struct BootBlkHdr { - unsigned short ID; /* boot blocks signature */ - unsigned long Entry; /* entry point to bootcode */ - unsigned short Version; /* boot blocks version number */ - unsigned short PageFlags; /* used internally */ - unsigned char SysName[16]; /* System filename */ - unsigned char ShellName[16]; /* Finder filename */ - unsigned char Dbg1Name[16]; /* debugger filename */ - unsigned char Dbg2Name[16]; /* debugger filename */ - unsigned char ScreenName[16]; /* name of startup screen */ - unsigned char HelloName[16]; /* name of startup program */ - unsigned char ScrapName[16]; /* name of system scrap file */ - unsigned short CntFCBs; /* number of FCBs to allocate */ - unsigned short CntEvts; /* number of event queue elements */ - unsigned long Heap128K; /* system heap size on 128K Mac */ - unsigned long Heap256K; /* used internally */ - unsigned long SysHeapSize; /* system heap size on all machines */ + u_int16_t ID; /* boot blocks signature */ + u_int32_t Entry; /* entry point to bootcode */ + u_int16_t Version; /* boot blocks version number */ + u_int16_t PageFlags; /* used internally */ + u_int8_t SysName[16]; /* System filename */ + u_int8_t ShellName[16]; /* Finder filename */ + u_int8_t Dbg1Name[16]; /* debugger filename */ + u_int8_t Dbg2Name[16]; /* debugger filename */ + u_int8_t ScreenName[16]; /* name of startup screen */ + u_int8_t HelloName[16]; /* name of startup program */ + u_int8_t ScrapName[16]; /* name of system scrap file */ + u_int16_t CntFCBs; /* number of FCBs to allocate */ + u_int16_t CntEvts; /* number of event queue elements */ + u_int32_t Heap128K; /* system heap size on 128K Mac */ + u_int32_t Heap256K; /* used internally */ + u_int32_t SysHeapSize; /* system heap size on all machines */ } __attribute__((packed)); #define ASSERT_BBH(a) if ( sizeof(BootBlkHdr_t) != 138 ) { a } @@ -45,7 +45,7 @@ typedef struct eBootBlock eBootBlock_t; struct eBootBlock { BootBlkHdr_t boot_block_header; ParamBlockRec_t second_param_block; - unsigned char boot_code[1024 - sizeof(BootBlkHdr_t) + u_int8_t boot_code[1024 - sizeof(BootBlkHdr_t) - sizeof(ParamBlockRec_t)]; } __attribute__((packed)); diff --git a/tools/emile-install.c b/tools/emile-install.c index a93b35e..25d05f3 100644 --- a/tools/emile-install.c +++ b/tools/emile-install.c @@ -68,11 +68,11 @@ static int second_tune(int fd, char* second_level, char *kernel_image, unsigned write_long(&header.ramdisk_size, get_size(ramdisk)); } printf("Setting second level info: \n"); - printf("kernel offset %ld, kernel size %ld, buffer size %ld\n", + printf("kernel offset %d, kernel size %d, buffer size %d\n", read_long(&header.kernel_image_offset), read_long(&header.kernel_image_size), read_long(&header.kernel_size)); - printf("ramdisk offset %ld, ramdisk size %ld\n", + printf("ramdisk offset %d, ramdisk size %d\n", read_long(&header.ramdisk_offset), read_long(&header.ramdisk_size)); @@ -119,7 +119,7 @@ static int first_tune(int fd, char* second_level) write_long(&firstBlock.second_param_block.ioReqCount, get_size(second_level)); printf( - "Setting second level position to: drive %d, offset %ld, size %ld\n", + "Setting second level position to: drive %d, offset %d, size %d\n", read_short(&firstBlock.second_param_block.ioVRefNum), read_long(&firstBlock.second_param_block.ioPosOffset), read_long(&firstBlock.second_param_block.ioReqCount)); @@ -131,7 +131,6 @@ static int first_tune(int fd, char* second_level) return 11; ret = write(fd, &firstBlock, sizeof(firstBlock)); - if (ret != sizeof(firstBlock)) if (ret != sizeof(firstBlock)) return 12; @@ -302,6 +301,13 @@ int main(int argc, char** argv) int i; int ret; + ASSERT_BBH( + {fprintf(stderr,"Internal Error: Bad BootBlkHdr size\n"); exit(1);}); + ASSERT_PBR( + {fprintf(stderr,"Internal Error: Bad ParamBlockRec size\n"); exit(1);}); + ASSERT_BB( + {fprintf(stderr,"Internal Error: Bad boot block size\n"); exit(1);}); + if ((argc != 12) && (argc != 10)) { usage(argc, argv); diff --git a/tools/emile-second.h b/tools/emile-second.h index 6441157..5ee0115 100644 --- a/tools/emile-second.h +++ b/tools/emile-second.h @@ -12,14 +12,14 @@ typedef struct emile_l2_header emile_l2_header_t; struct emile_l2_header { - unsigned long entry; - unsigned long signature; /* EM01 */ - unsigned long kernel_image_offset; - unsigned long kernel_image_size; - unsigned long kernel_size; - unsigned long ramdisk_offset; - unsigned long ramdisk_size; - char command_line[256]; + u_int32_t entry; + u_int32_t signature; /* EM01 */ + u_int32_t kernel_image_offset; + u_int32_t kernel_image_size; + u_int32_t kernel_size; + u_int32_t ramdisk_offset; + u_int32_t ramdisk_size; + int8_t command_line[256]; }; #define EMILE_001_SIGNATURE (('E'<<24)|('M'<<16)|('0'<<8)|'1') diff --git a/tools/emile.h b/tools/emile.h index 55e5353..7004edc 100644 --- a/tools/emile.h +++ b/tools/emile.h @@ -10,22 +10,22 @@ /* nothing to do, because m68k is big endian too */ -static inline unsigned short read_short(unsigned short* addr) +static inline u_int16_t read_short(u_int16_t* addr) { return *addr; } -static inline void write_short(unsigned short* addr, unsigned short value) +static inline void write_short(u_int16_t* addr, u_int16_t value) { *addr = value; } -static inline unsigned long read_long(unsigned long* addr) +static inline u_int32_t read_long(u_int32_t* addr) { return *addr; } -static inline void write_long(unsigned long* addr, unsigned long value) +static inline void write_long(u_int32_t* addr, u_int32_t value) { *addr = value; } @@ -34,14 +34,14 @@ static inline void write_long(unsigned long* addr, unsigned long value) /* little endian (or unknown), read byte by byte to get it in good order */ -static inline unsigned short read_short(unsigned short* addr) +static inline u_int16_t read_short(u_int16_t* addr) { unsigned char* baddr = (unsigned char*)addr; - return ((unsigned short)(*baddr) << 8) | (unsigned short)*(baddr+1); + return ((u_int16_t)(*baddr) << 8) | (u_int16_t)*(baddr+1); } -static inline void write_short(unsigned short* addr, unsigned short value) +static inline void write_short(u_int16_t* addr, u_int16_t value) { unsigned char* baddr = (unsigned char*)addr; @@ -49,19 +49,19 @@ static inline void write_short(unsigned short* addr, unsigned short value) *(baddr+1) = (unsigned char)value; } -static inline unsigned long read_long(unsigned long* addr) +static inline u_int32_t read_long(u_int32_t* addr) { - unsigned short* saddr = (unsigned short*)addr; + u_int16_t* saddr = (u_int16_t*)addr; - return ((unsigned long)read_short(saddr) << 16) | - (unsigned long)read_short(saddr+1);; + return ((u_int32_t)read_short(saddr) << 16) | + (u_int32_t)read_short(saddr+1);; } -static inline void write_long(unsigned long* addr, unsigned long value) +static inline void write_long(u_int32_t* addr, u_int32_t value) { - unsigned short* saddr = (unsigned short*)addr; + u_int16_t* saddr = (u_int16_t*)addr; - write_short(saddr, (unsigned short)(value>>16)); - write_short(saddr+1, (unsigned short)value); + write_short(saddr, (u_int16_t)(value>>16)); + write_short(saddr+1, (u_int16_t)value); } #endif