Fixed mkbootimage for 64-bit architectures. Now I can create a working

BeBox boot.fs under NetBSD/amd64.
This commit is contained in:
phx 2014-04-22 21:37:52 +00:00
parent 57561cf1db
commit 625c110fa2
3 changed files with 49 additions and 49 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: bebox_bootrec.h,v 1.3 2012/12/24 14:01:24 kiyohara Exp $ */
/* $NetBSD: bebox_bootrec.h,v 1.4 2014/04/22 21:37:52 phx Exp $ */
#define BEBOX_HEADER_SIZE 0x6400
#define BEBOX_BLOCK_SIZE 0x200
@ -136,9 +136,9 @@ u_char bebox_image_data12[] = {
};
struct bebox_image_block {
long offset;
int32_t offset;
u_char *data;
int size;
int32_t size;
};
#define BEBOX_IMG(x) __CONCAT(bebox_image_data,x)
@ -162,7 +162,7 @@ struct bebox_image_block bebox_image_block[] = {
{ -1 }
};
long bebox_mtime_offset[] = {
int32_t bebox_mtime_offset[] = {
0x00000004,
0x0000048c,
0x00000490,

View File

@ -1,4 +1,4 @@
/* $NetBSD: mkbootimage.c,v 1.17 2013/07/09 13:10:33 joerg Exp $ */
/* $NetBSD: mkbootimage.c,v 1.18 2014/04/22 21:37:52 phx Exp $ */
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
@ -685,10 +685,9 @@ bebox_build_image(char *kernel, char *boot, char *rawdev, char *outname)
unsigned char *elf_img = NULL, *kern_img = NULL, *header_img = NULL;
int i, ch, tmp, kgzlen, err, hsize = BEBOX_HEADER_SIZE;
int elf_fd, bebox_fd, kern_fd, elf_img_len = 0;
off_t lenpos, kstart, kend, toff, endoff, flength;
uint32_t swapped[128];
off_t lenpos, kstart, kend, toff, endoff;
unsigned long length;
long flength, *offset;
int32_t *offset;
gzFile gzf;
struct stat kern_stat;
struct bebox_image_block *p;
@ -818,14 +817,15 @@ bebox_build_image(char *kernel, char *boot, char *rawdev, char *outname)
/* fix the file size in the header */
tmp = endoff - BEBOX_HEADER_SIZE;
*(long *)(header_img + BEBOX_FILE_SIZE_OFFSET) =
(long)sa_htobe32(tmp);
*(long *)(header_img + BEBOX_FILE_SIZE_ALIGN_OFFSET) =
(long)sa_htobe32(roundup(tmp, BEBOX_FILE_BLOCK_SIZE));
*(int32_t *)(header_img + BEBOX_FILE_SIZE_OFFSET) =
(int32_t)sa_htobe32(tmp);
*(int32_t *)(header_img + BEBOX_FILE_SIZE_ALIGN_OFFSET) =
(int32_t)sa_htobe32(roundup(tmp, BEBOX_FILE_BLOCK_SIZE));
gettimeofday(&tp, 0);
for (offset = bebox_mtime_offset; *offset != -1; offset++)
*(long *)(header_img + *offset) = (long)sa_htobe32(tp.tv_sec);
*(int32_t *)(header_img + *offset) =
(int32_t)sa_htobe32(tp.tv_sec);
write(bebox_fd, header_img, BEBOX_HEADER_SIZE);

View File

@ -1,4 +1,4 @@
/* $NetBSD: pef.h,v 1.2 2010/10/16 05:05:09 kiyohara Exp $ */
/* $NetBSD: pef.h,v 1.3 2014/04/22 21:37:52 phx Exp $ */
/*-
* Copyright (C) 1995-1997 Gary Thomas (gdt@linuxppc.org)
@ -34,17 +34,17 @@
struct FileHeader
{
unsigned long magic;
unsigned long fileTypeID;
unsigned long archID;
unsigned long versionNumber;
unsigned long dateTimeStamp;
unsigned long definVersion;
unsigned long implVersion;
unsigned long currentVersion;
unsigned short numSections;
unsigned short loadableSections;
unsigned long memoryAddress;
uint32_t magic;
uint32_t fileTypeID;
uint32_t archID;
uint32_t versionNumber;
uint32_t dateTimeStamp;
uint32_t definVersion;
uint32_t implVersion;
uint32_t currentVersion;
uint16_t numSections;
uint16_t loadableSections;
uint32_t memoryAddress;
};
#define PEF_MAGIC 0x4A6F7921 /* Joy! */
@ -53,16 +53,16 @@ struct FileHeader
struct SectionHeader
{
unsigned long sectionName;
unsigned long sectionAddress;
unsigned long execSize;
unsigned long initSize;
unsigned long rawSize;
unsigned long fileOffset;
unsigned char regionKind;
unsigned char shareKind;
unsigned char alignment;
unsigned char _reserved;
uint32_t sectionName;
uint32_t sectionAddress;
uint32_t execSize;
uint32_t initSize;
uint32_t rawSize;
uint32_t fileOffset;
uint8_t regionKind;
uint8_t shareKind;
uint8_t alignment;
uint8_t _reserved;
};
#define CodeSection 0
@ -79,18 +79,18 @@ struct SectionHeader
struct LoaderHeader
{
unsigned long entryPointSection;
unsigned long entryPointOffset;
unsigned long initPointSection;
unsigned long initPointOffset;
unsigned long termPointSection;
unsigned long termPointOffset;
unsigned long numImportFiles;
unsigned long numImportSyms;
unsigned long numSections;
unsigned long relocationsOffset;
unsigned long stringsOffset;
unsigned long hashSlotTable;
unsigned long hashSlotTableSize;
unsigned long numExportSyms;
uint32_t entryPointSection;
uint32_t entryPointOffset;
uint32_t initPointSection;
uint32_t initPointOffset;
uint32_t termPointSection;
uint32_t termPointOffset;
uint32_t numImportFiles;
uint32_t numImportSyms;
uint32_t numSections;
uint32_t relocationsOffset;
uint32_t stringsOffset;
uint32_t hashSlotTable;
uint32_t hashSlotTableSize;
uint32_t numExportSyms;
};