mirror of
https://github.com/vivier/EMILE.git
synced 2025-01-22 00:32:15 +00:00
64bit support
This commit is contained in:
parent
35c022d25d
commit
5430f75fb4
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@ -52,7 +53,7 @@ int first_info(char* image)
|
|||||||
printf("Boot Block Header:\n\n");
|
printf("Boot Block Header:\n\n");
|
||||||
printf("Boot blocks signature: 0x%x\n",
|
printf("Boot blocks signature: 0x%x\n",
|
||||||
read_short(&firstBlock.boot_block_header.ID));
|
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));
|
read_long(&firstBlock.boot_block_header.Entry));
|
||||||
printf("Boot blocks version number: %x\n",
|
printf("Boot blocks version number: %x\n",
|
||||||
read_short(&firstBlock.boot_block_header.Version));
|
read_short(&firstBlock.boot_block_header.Version));
|
||||||
@ -81,11 +82,11 @@ int first_info(char* image)
|
|||||||
read_short(&firstBlock.boot_block_header.CntFCBs));
|
read_short(&firstBlock.boot_block_header.CntFCBs));
|
||||||
printf("Number of event queue elements: %d\n",
|
printf("Number of event queue elements: %d\n",
|
||||||
read_short(&firstBlock.boot_block_header.CntEvts));
|
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));
|
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));
|
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));
|
read_long(&firstBlock.boot_block_header.SysHeapSize));
|
||||||
|
|
||||||
if ( strncmp( firstBlock.boot_block_header.SysName+1,
|
if ( strncmp( firstBlock.boot_block_header.SysName+1,
|
||||||
@ -97,9 +98,9 @@ int first_info(char* image)
|
|||||||
read_short(&firstBlock.second_param_block.ioVRefNum));
|
read_short(&firstBlock.second_param_block.ioVRefNum));
|
||||||
printf("File reference number: %d\n",
|
printf("File reference number: %d\n",
|
||||||
read_short(&firstBlock.second_param_block.ioRefNum));
|
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));
|
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));
|
read_long(&firstBlock.second_param_block.ioPosOffset));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,9 +80,9 @@ int first_tune( char* image, unsigned short tune_mask, int drive_num,
|
|||||||
read_short(&firstBlock.second_param_block.ioVRefNum));
|
read_short(&firstBlock.second_param_block.ioVRefNum));
|
||||||
printf("File reference number: %d\n",
|
printf("File reference number: %d\n",
|
||||||
read_short(&firstBlock.second_param_block.ioRefNum));
|
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));
|
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));
|
read_long(&firstBlock.second_param_block.ioPosOffset));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -18,22 +18,22 @@
|
|||||||
typedef struct BootBlkHdr BootBlkHdr_t;
|
typedef struct BootBlkHdr BootBlkHdr_t;
|
||||||
|
|
||||||
struct BootBlkHdr {
|
struct BootBlkHdr {
|
||||||
unsigned short ID; /* boot blocks signature */
|
u_int16_t ID; /* boot blocks signature */
|
||||||
unsigned long Entry; /* entry point to bootcode */
|
u_int32_t Entry; /* entry point to bootcode */
|
||||||
unsigned short Version; /* boot blocks version number */
|
u_int16_t Version; /* boot blocks version number */
|
||||||
unsigned short PageFlags; /* used internally */
|
u_int16_t PageFlags; /* used internally */
|
||||||
unsigned char SysName[16]; /* System filename */
|
u_int8_t SysName[16]; /* System filename */
|
||||||
unsigned char ShellName[16]; /* Finder filename */
|
u_int8_t ShellName[16]; /* Finder filename */
|
||||||
unsigned char Dbg1Name[16]; /* debugger filename */
|
u_int8_t Dbg1Name[16]; /* debugger filename */
|
||||||
unsigned char Dbg2Name[16]; /* debugger filename */
|
u_int8_t Dbg2Name[16]; /* debugger filename */
|
||||||
unsigned char ScreenName[16]; /* name of startup screen */
|
u_int8_t ScreenName[16]; /* name of startup screen */
|
||||||
unsigned char HelloName[16]; /* name of startup program */
|
u_int8_t HelloName[16]; /* name of startup program */
|
||||||
unsigned char ScrapName[16]; /* name of system scrap file */
|
u_int8_t ScrapName[16]; /* name of system scrap file */
|
||||||
unsigned short CntFCBs; /* number of FCBs to allocate */
|
u_int16_t CntFCBs; /* number of FCBs to allocate */
|
||||||
unsigned short CntEvts; /* number of event queue elements */
|
u_int16_t CntEvts; /* number of event queue elements */
|
||||||
unsigned long Heap128K; /* system heap size on 128K Mac */
|
u_int32_t Heap128K; /* system heap size on 128K Mac */
|
||||||
unsigned long Heap256K; /* used internally */
|
u_int32_t Heap256K; /* used internally */
|
||||||
unsigned long SysHeapSize; /* system heap size on all machines */
|
u_int32_t SysHeapSize; /* system heap size on all machines */
|
||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
|
||||||
#define ASSERT_BBH(a) if ( sizeof(BootBlkHdr_t) != 138 ) { a }
|
#define ASSERT_BBH(a) if ( sizeof(BootBlkHdr_t) != 138 ) { a }
|
||||||
@ -45,7 +45,7 @@ typedef struct eBootBlock eBootBlock_t;
|
|||||||
struct eBootBlock {
|
struct eBootBlock {
|
||||||
BootBlkHdr_t boot_block_header;
|
BootBlkHdr_t boot_block_header;
|
||||||
ParamBlockRec_t second_param_block;
|
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)];
|
- sizeof(ParamBlockRec_t)];
|
||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
|
||||||
|
@ -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));
|
write_long(&header.ramdisk_size, get_size(ramdisk));
|
||||||
}
|
}
|
||||||
printf("Setting second level info: \n");
|
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_offset),
|
||||||
read_long(&header.kernel_image_size),
|
read_long(&header.kernel_image_size),
|
||||||
read_long(&header.kernel_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_offset),
|
||||||
read_long(&header.ramdisk_size));
|
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));
|
write_long(&firstBlock.second_param_block.ioReqCount, get_size(second_level));
|
||||||
|
|
||||||
printf(
|
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_short(&firstBlock.second_param_block.ioVRefNum),
|
||||||
read_long(&firstBlock.second_param_block.ioPosOffset),
|
read_long(&firstBlock.second_param_block.ioPosOffset),
|
||||||
read_long(&firstBlock.second_param_block.ioReqCount));
|
read_long(&firstBlock.second_param_block.ioReqCount));
|
||||||
@ -132,7 +132,6 @@ static int first_tune(int fd, char* second_level)
|
|||||||
|
|
||||||
ret = write(fd, &firstBlock, sizeof(firstBlock));
|
ret = write(fd, &firstBlock, sizeof(firstBlock));
|
||||||
if (ret != sizeof(firstBlock))
|
if (ret != sizeof(firstBlock))
|
||||||
if (ret != sizeof(firstBlock))
|
|
||||||
return 12;
|
return 12;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -302,6 +301,13 @@ int main(int argc, char** argv)
|
|||||||
int i;
|
int i;
|
||||||
int ret;
|
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))
|
if ((argc != 12) && (argc != 10))
|
||||||
{
|
{
|
||||||
usage(argc, argv);
|
usage(argc, argv);
|
||||||
|
@ -12,14 +12,14 @@
|
|||||||
typedef struct emile_l2_header emile_l2_header_t;
|
typedef struct emile_l2_header emile_l2_header_t;
|
||||||
|
|
||||||
struct emile_l2_header {
|
struct emile_l2_header {
|
||||||
unsigned long entry;
|
u_int32_t entry;
|
||||||
unsigned long signature; /* EM01 */
|
u_int32_t signature; /* EM01 */
|
||||||
unsigned long kernel_image_offset;
|
u_int32_t kernel_image_offset;
|
||||||
unsigned long kernel_image_size;
|
u_int32_t kernel_image_size;
|
||||||
unsigned long kernel_size;
|
u_int32_t kernel_size;
|
||||||
unsigned long ramdisk_offset;
|
u_int32_t ramdisk_offset;
|
||||||
unsigned long ramdisk_size;
|
u_int32_t ramdisk_size;
|
||||||
char command_line[256];
|
int8_t command_line[256];
|
||||||
};
|
};
|
||||||
|
|
||||||
#define EMILE_001_SIGNATURE (('E'<<24)|('M'<<16)|('0'<<8)|'1')
|
#define EMILE_001_SIGNATURE (('E'<<24)|('M'<<16)|('0'<<8)|'1')
|
||||||
|
@ -10,22 +10,22 @@
|
|||||||
|
|
||||||
/* nothing to do, because m68k is big endian too */
|
/* 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;
|
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;
|
*addr = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline unsigned long read_long(unsigned long* addr)
|
static inline u_int32_t read_long(u_int32_t* addr)
|
||||||
{
|
{
|
||||||
return *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;
|
*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 */
|
/* 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;
|
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;
|
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;
|
*(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) |
|
return ((u_int32_t)read_short(saddr) << 16) |
|
||||||
(unsigned long)read_short(saddr+1);;
|
(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, (u_int16_t)(value>>16));
|
||||||
write_short(saddr+1, (unsigned short)value);
|
write_short(saddr+1, (u_int16_t)value);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user