Module Name:    src
Committed By:   phx
Date:           Tue Apr 22 21:37:52 UTC 2014

Modified Files:
        src/sys/arch/powerpc/stand/mkbootimage: bebox_bootrec.h mkbootimage.c
            pef.h

Log Message:
Fixed mkbootimage for 64-bit architectures. Now I can create a working
BeBox boot.fs under NetBSD/amd64.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 \
    src/sys/arch/powerpc/stand/mkbootimage/bebox_bootrec.h
cvs rdiff -u -r1.17 -r1.18 \
    src/sys/arch/powerpc/stand/mkbootimage/mkbootimage.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/powerpc/stand/mkbootimage/pef.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/powerpc/stand/mkbootimage/bebox_bootrec.h
diff -u src/sys/arch/powerpc/stand/mkbootimage/bebox_bootrec.h:1.3 src/sys/arch/powerpc/stand/mkbootimage/bebox_bootrec.h:1.4
--- src/sys/arch/powerpc/stand/mkbootimage/bebox_bootrec.h:1.3	Mon Dec 24 14:01:24 2012
+++ src/sys/arch/powerpc/stand/mkbootimage/bebox_bootrec.h	Tue Apr 22 21:37:52 2014
@@ -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_blo
 	{ -1 }
 };
 
-long bebox_mtime_offset[] = {
+int32_t bebox_mtime_offset[] = {
 	0x00000004,
 	0x0000048c,
 	0x00000490,

Index: src/sys/arch/powerpc/stand/mkbootimage/mkbootimage.c
diff -u src/sys/arch/powerpc/stand/mkbootimage/mkbootimage.c:1.17 src/sys/arch/powerpc/stand/mkbootimage/mkbootimage.c:1.18
--- src/sys/arch/powerpc/stand/mkbootimage/mkbootimage.c:1.17	Tue Jul  9 13:10:33 2013
+++ src/sys/arch/powerpc/stand/mkbootimage/mkbootimage.c	Tue Apr 22 21:37:52 2014
@@ -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 *bo
 	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 *bo
 
 	/* 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);
 

Index: src/sys/arch/powerpc/stand/mkbootimage/pef.h
diff -u src/sys/arch/powerpc/stand/mkbootimage/pef.h:1.2 src/sys/arch/powerpc/stand/mkbootimage/pef.h:1.3
--- src/sys/arch/powerpc/stand/mkbootimage/pef.h:1.2	Sat Oct 16 05:05:09 2010
+++ src/sys/arch/powerpc/stand/mkbootimage/pef.h	Tue Apr 22 21:37:52 2014
@@ -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 (g...@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;
 };

Reply via email to