|
@@ -16,7 +16,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
16
|
16
|
*
|
17
|
17
|
*/
|
18
|
18
|
extern char _max_align[];
|
19
|
|
-#define max_align ( ( unsigned int ) _max_align )
|
|
19
|
+#define max_align ( ( size_t ) _max_align )
|
20
|
20
|
|
21
|
21
|
/* Linker symbols */
|
22
|
22
|
extern char _textdata[];
|
|
@@ -44,8 +44,8 @@ extern char _etextdata[];
|
44
|
44
|
*/
|
45
|
45
|
__asmcall void relocate ( struct i386_all_regs *ix86 ) {
|
46
|
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
|
49
|
unsigned i;
|
50
|
50
|
|
51
|
51
|
/* Get memory map and current location */
|
|
@@ -55,15 +55,15 @@ __asmcall void relocate ( struct i386_all_regs *ix86 ) {
|
55
|
55
|
size = ( end - start );
|
56
|
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
|
60
|
start, end, padded_size, max_align );
|
61
|
61
|
|
62
|
62
|
/* Determine maximum usable address */
|
63
|
63
|
max = MAX_ADDR;
|
64
|
64
|
if ( ix86->regs.ebp < max ) {
|
65
|
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
|
69
|
/* Walk through the memory map and find the highest address
|
|
@@ -72,7 +72,7 @@ __asmcall void relocate ( struct i386_all_regs *ix86 ) {
|
72
|
72
|
new_end = end;
|
73
|
73
|
for ( i = 0 ; i < memmap.count ; i++ ) {
|
74
|
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
|
77
|
DBG ( "Considering [%llx,%llx)\n", region->start, region->end);
|
78
|
78
|
|
|
@@ -81,17 +81,17 @@ __asmcall void relocate ( struct i386_all_regs *ix86 ) {
|
81
|
81
|
* with using just 32-bit arithmetic after this stage.
|
82
|
82
|
*/
|
83
|
83
|
if ( region->start > max ) {
|
84
|
|
- DBG ( "...starts after max=%lx\n", max );
|
|
84
|
+ DBG ( "...starts after max=%x\n", max );
|
85
|
85
|
continue;
|
86
|
86
|
}
|
87
|
87
|
r_start = region->start;
|
88
|
88
|
if ( region->end > max ) {
|
89
|
|
- DBG ( "...end truncated to max=%lx\n", max );
|
|
89
|
+ DBG ( "...end truncated to max=%x\n", max );
|
90
|
90
|
r_end = max;
|
91
|
91
|
} else {
|
92
|
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
|
96
|
/* If we have rounded down r_end below r_ start, skip
|
97
|
97
|
* this block.
|
|
@@ -103,7 +103,7 @@ __asmcall void relocate ( struct i386_all_regs *ix86 ) {
|
103
|
103
|
|
104
|
104
|
/* Check that there is enough space to fit in iPXE */
|
105
|
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
|
107
|
continue;
|
108
|
108
|
}
|
109
|
109
|
|
|
@@ -128,7 +128,7 @@ __asmcall void relocate ( struct i386_all_regs *ix86 ) {
|
128
|
128
|
new_start += ( start - new_start ) & ( max_align - 1 );
|
129
|
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
|
132
|
start, end, new_start, new_end );
|
133
|
133
|
|
134
|
134
|
/* Let prefix know what to copy */
|