Cleaner memory map; avoid < 64K; handle older kernels
[wraplinux.git] / reloc / reloc_linux.c
index 5849c54..79655c1 100644 (file)
@@ -158,30 +158,36 @@ static int place_initrd(void)
        return probe_memory_88();
 }
 
+extern char _end[];
+/* This structure is hacked by the installer */
+static const struct startup_info startup_info
+__attribute__((section(".startupinfo"))) =
+{
+       .reloc_size = (uint32_t)&_end,
+};
+
 int main(void)
 {
-       extern struct startup_info _start[]; /* Cute hack, eh? */
-       struct startup_info *info = _start - 1;
-       struct setup_header *hdr = (void *)(info->setup_addr + 0x1f1);
+       struct setup_header *hdr = (void *)(startup_info.setup_addr + 0x1f1);
 
-       if (info->rd_len) {
-               initrd_len = info->rd_len;
-               max_addr   = info->rd_maxaddr;
+       if (startup_info.rd_len) {
+               initrd_len = startup_info.rd_len;
+               max_addr   = startup_info.rd_maxaddr;
 
                if (place_initrd())
                        return -1;
 
                /* Move the initrd into place */
                printf("Moving initrd: 0x%08x -> 0x%08x (0x%08x bytes)\n",
-                      info->rd_addr, initrd_addr, info->rd_len);
+                      startup_info.rd_addr, initrd_addr, startup_info.rd_len);
 
-               memmove((void *)initrd_addr, (void *)info->rd_addr,
-                       info->rd_len);
+               memmove((void *)initrd_addr, (void *)startup_info.rd_addr,
+                       startup_info.rd_len);
                
                hdr->ramdisk_image = initrd_addr;
        }
 
-       jump_to_kernel(info->setup_addr >> 4,
-                      info->cmdline_addr - info->setup_addr);
+       jump_to_kernel(startup_info.setup_addr >> 4,
+                      startup_info.cmdline_addr - startup_info.setup_addr);
        return -1;              /* Shouldn't return... */
 }