Browse Source

[bios] Allow relocate.c to be compiled for x86_64

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 9 years ago
parent
commit
44e05b0ffc
1 changed files with 12 additions and 12 deletions
  1. 12
    12
      src/arch/i386/core/relocate.c

+ 12
- 12
src/arch/i386/core/relocate.c View File

16
  *
16
  *
17
  */
17
  */
18
 extern char _max_align[];
18
 extern char _max_align[];
19
-#define max_align ( ( unsigned int ) _max_align )
19
+#define max_align ( ( size_t ) _max_align )
20
 
20
 
21
 /* Linker symbols */
21
 /* Linker symbols */
22
 extern char _textdata[];
22
 extern char _textdata[];
44
  */
44
  */
45
 __asmcall void relocate ( struct i386_all_regs *ix86 ) {
45
 __asmcall void relocate ( struct i386_all_regs *ix86 ) {
46
 	struct memory_map memmap;
46
 	struct memory_map memmap;
47
-	unsigned long start, end, size, padded_size, max;
48
-	unsigned long new_start, new_end;
47
+	uint32_t start, end, size, padded_size, max;
48
+	uint32_t new_start, new_end;
49
 	unsigned i;
49
 	unsigned i;
50
 
50
 
51
 	/* Get memory map and current location */
51
 	/* Get memory map and current location */
55
 	size = ( end - start );
55
 	size = ( end - start );
56
 	padded_size = ( size + max_align - 1 );
56
 	padded_size = ( size + max_align - 1 );
57
 
57
 
58
-	DBG ( "Relocate: currently at [%lx,%lx)\n"
59
-	      "...need %lx bytes for %d-byte alignment\n",
58
+	DBG ( "Relocate: currently at [%x,%x)\n"
59
+	      "...need %x bytes for %zd-byte alignment\n",
60
 	      start, end, padded_size, max_align );
60
 	      start, end, padded_size, max_align );
61
 
61
 
62
 	/* Determine maximum usable address */
62
 	/* Determine maximum usable address */
63
 	max = MAX_ADDR;
63
 	max = MAX_ADDR;
64
 	if ( ix86->regs.ebp < max ) {
64
 	if ( ix86->regs.ebp < max ) {
65
 		max = ix86->regs.ebp;
65
 		max = ix86->regs.ebp;
66
-		DBG ( "Limiting relocation to [0,%lx)\n", max );
66
+		DBG ( "Limiting relocation to [0,%x)\n", max );
67
 	}
67
 	}
68
 
68
 
69
 	/* Walk through the memory map and find the highest address
69
 	/* Walk through the memory map and find the highest address
72
 	new_end = end;
72
 	new_end = end;
73
 	for ( i = 0 ; i < memmap.count ; i++ ) {
73
 	for ( i = 0 ; i < memmap.count ; i++ ) {
74
 		struct memory_region *region = &memmap.regions[i];
74
 		struct memory_region *region = &memmap.regions[i];
75
-		unsigned long r_start, r_end;
75
+		uint32_t r_start, r_end;
76
 
76
 
77
 		DBG ( "Considering [%llx,%llx)\n", region->start, region->end);
77
 		DBG ( "Considering [%llx,%llx)\n", region->start, region->end);
78
 		
78
 		
81
 		 * with using just 32-bit arithmetic after this stage.
81
 		 * with using just 32-bit arithmetic after this stage.
82
 		 */
82
 		 */
83
 		if ( region->start > max ) {
83
 		if ( region->start > max ) {
84
-			DBG ( "...starts after max=%lx\n", max );
84
+			DBG ( "...starts after max=%x\n", max );
85
 			continue;
85
 			continue;
86
 		}
86
 		}
87
 		r_start = region->start;
87
 		r_start = region->start;
88
 		if ( region->end > max ) {
88
 		if ( region->end > max ) {
89
-			DBG ( "...end truncated to max=%lx\n", max );
89
+			DBG ( "...end truncated to max=%x\n", max );
90
 			r_end = max;
90
 			r_end = max;
91
 		} else {
91
 		} else {
92
 			r_end = region->end;
92
 			r_end = region->end;
93
 		}
93
 		}
94
-		DBG ( "...usable portion is [%lx,%lx)\n", r_start, r_end );
94
+		DBG ( "...usable portion is [%x,%x)\n", r_start, r_end );
95
 
95
 
96
 		/* If we have rounded down r_end below r_ start, skip
96
 		/* If we have rounded down r_end below r_ start, skip
97
 		 * this block.
97
 		 * this block.
103
 
103
 
104
 		/* Check that there is enough space to fit in iPXE */
104
 		/* Check that there is enough space to fit in iPXE */
105
 		if ( ( r_end - r_start ) < size ) {
105
 		if ( ( r_end - r_start ) < size ) {
106
-			DBG ( "...too small (need %lx bytes)\n", size );
106
+			DBG ( "...too small (need %x bytes)\n", size );
107
 			continue;
107
 			continue;
108
 		}
108
 		}
109
 
109
 
128
 	new_start += ( start - new_start ) & ( max_align - 1 );
128
 	new_start += ( start - new_start ) & ( max_align - 1 );
129
 	new_end = new_start + size;
129
 	new_end = new_start + size;
130
 
130
 
131
-	DBG ( "Relocating from [%lx,%lx) to [%lx,%lx)\n",
131
+	DBG ( "Relocating from [%x,%x) to [%x,%x)\n",
132
 	      start, end, new_start, new_end );
132
 	      start, end, new_start, new_end );
133
 	
133
 	
134
 	/* Let prefix know what to copy */
134
 	/* Let prefix know what to copy */

Loading…
Cancel
Save