floppy image is now built from several parts (first, second, kernel, ramdisk) with emile-install. Linker cannot provide kernel size and position anymore

This commit is contained in:
Laurent Vivier 2004-06-01 22:00:21 +00:00
parent c0fb2a2399
commit 5dbc36d650
6 changed files with 82 additions and 63 deletions

View File

@ -23,14 +23,25 @@ OBJCOPY=$(CROSS_COMPILE)objcopy
KERNEL=vmlinux
FILE=file -bknL
KERNEL_ARCH=$(filter Motorola PowerPC, $(shell $(FILE) $(KERNEL) | cut -d"," -f 2))
KERNEL_SIZE=$(shell ls -l $(KERNEL) | awk '{print $$5}')
RAMDISK=$(basename $(shell ls ramdisk 2> /dev/null))
all: floppy.img
floppy.img: tools first/first vmlinuz second/second
cat first/first > floppy.img.X
cat second/second >> floppy.img.X
ls -l floppy.img.X|awk '{ printf "%s",$$5}'| xargs tools/emile-first-tune -d 1 -o 1024 floppy.img.X -s
@#tools/emile-first-tune -d 1 -o 1024 floppy.img.X -s 1473536
floppy.img: tools first/first vmlinuz second/second $(RAMDISK)
ifeq ($(RAMDISK),ramdisk)
tools/emile-install -f first/first -s second/second \
-i vmlinuz -b $(KERNEL_SIZE) \
-r $(RAMDISK) \
floppy.img.X
else
tools/emile-install -f first/first -s second/second \
-i vmlinuz -b $(KERNEL_SIZE) \
floppy.img.X
endif
tools/emile-set-cmdline floppy.img.X \
"root=/dev/nfs ip=dhcp nfsroot=192.168.100.1:/mnt/usb-storage/nfsroot"
mv floppy.img.X floppy.img
vmlinux.bin: $(KERNEL)
@ -53,7 +64,6 @@ tools::
dump: floppy.img
tools/emile-set-cmdline floppy.img "root=/dev/nfs ip=dhcp nfsroot=192.168.100.1:/mnt/usb-storage/nfsroot"
dd if=floppy.img of=/dev/fd0 bs=512
eject /dev/fd0
@ -72,11 +82,13 @@ DISTFILES = second/head.S second/MMU030.c second/MMU040.c second/main.c \
second/bootinfo.h second/misc.h second/lowmem.h \
second/bootinfo.c second/glue.h second/memory.h \
second/glue.S second/enter_kernel030.S \
second/load.h second/load.c \
second/enter_kernel040.S first/first.S \
first/Makefile second/bank.c second/bank.h second/arch.h \
second/arch.c Makefile COPYING README AUTHORS ChangeLog \
tools/Makefile tools/emile-first.h tools/emile-set-cmdline.c \
tools/emile-first-info.c tools/emile-first-tune.c
tools/emile-first-info.c tools/emile-first-tune.c \
tools/emile.h tools/emile-install.c
dist:
rm -fr $(PACKAGE)-$(VERSION)

View File

@ -10,24 +10,18 @@ ASFLAGS =
LS = ls
AWK = awk
RAMDISK = ../ramdisk.gz
KERNEL_BIN = ../vmlinux.bin
ZIPPED_KERNEL = ../vmlinuz
KERNEL_SIZE=$(shell $(LS) -l $(KERNEL_BIN) | $(AWK) '{print $$5}')
ifeq ($(KERNEL_ARCH),PowerPC)
CPPFLAGS += -DTARGET_PPC
OBJS = head.o MMU030_asm.o MMU040_asm.o image.o console.o printf.o \
OBJS = head.o MMU030_asm.o MMU040_asm.o main.o console.o printf.o \
font_8x16.o memory.o MMU030.o MMU040.o bootinfo.o misc.o glue.o \
bank.o arch.o
bank.o arch.o load.o
else
ifeq ($(KERNEL_ARCH),Motorola)
CPPFLAGS += -DTARGET_M68K
OBJS = head.o MMU030_asm.o MMU040_asm.o image.o console.o printf.o \
OBJS = head.o MMU030_asm.o MMU040_asm.o main.o console.o printf.o \
font_8x16.o memory.o uncompress.o MMU030.o MMU040.o bootinfo.o \
misc.o glue.o \
enter_kernel030.o enter_kernel040.o bank.o arch.o
misc.o glue.o enter_kernel030.o enter_kernel040.o bank.o arch.o \
load.o
endif
endif
@ -36,17 +30,7 @@ second: second.o
-O binary second.o second
second.o: $(OBJS) ld.script
$(LD) -T ld.script \
--defsym _KERNEL_SIZE=$(KERNEL_SIZE) -o second.o $(OBJS)
ifeq ($(shell ls $(RAMDISK) 2> /dev/null),$(RAMDISK))
image.o: main.o $(ZIPPED_KERNEL) $(RAMDISK)
$(OBJCOPY) --add-section .image=$(ZIPPED_KERNEL) \
--add-section .ramdisk=$(RAMDISK) main.o image.o ;
else
image.o: main.o $(ZIPPED_KERNEL)
$(OBJCOPY) --add-section .image=$(ZIPPED_KERNEL) main.o image.o;
endif
$(LD) -T ld.script -o second.o $(OBJS)
MMU030_asm.o: MMU030_asm.S
$(AS) $(ASFLAGS) -m68030 -o $@ $^

View File

@ -18,8 +18,8 @@
#include "bootinfo.h"
#include "arch.h"
extern unsigned char _ramdisk_start;
extern unsigned char _ramdisk_end;
extern unsigned long ramdisk_start;
extern unsigned long _ramdisk_size;
extern char _command_line;
static char* command_line = &_command_line;
@ -195,9 +195,8 @@ void bootinfo_init()
/* ramdisk info */
boot_info.ramdisk_size = (unsigned long)&_ramdisk_end -
(unsigned long)&_ramdisk_start;
logical2physical((unsigned long)&_ramdisk_start, &boot_info.ramdisk_addr);
boot_info.ramdisk_size = _ramdisk_size;
logical2physical(ramdisk_start, &boot_info.ramdisk_addr);
/* command line */

View File

@ -54,14 +54,6 @@ SECTIONS
PROVIDE (etext = .);
.rodata : {
*(.rodata .rodata.* .gnu.linkonce.r.*)
. = ALIGN(4);
_kernel_start = . ;
*(.image)
_kernel_end = . ;
. = ALIGN(4);
_ramdisk_start = . ;
*(.ramdisk)
_ramdisk_end = . ;
}
.rodata1 : { *(.rodata1) }
.eh_frame_hdr : { *(.eh_frame_hdr) }
@ -96,6 +88,5 @@ SECTIONS
. = ALIGN(32 / 8);
__bss_size = . - __bss_start;
_end = .;
__bootloader_end = .;
PROVIDE (end = .);
}

View File

@ -16,13 +16,11 @@
#include "console.h"
#include "arch.h"
#include "misc.h"
#include "glue.h"
#include "load.h"
typedef void (*entry_t) (unsigned long , unsigned long , unsigned long );
extern char _kernel_start;
extern char _kernel_end;
extern char _KERNEL_SIZE;
extern void enter_kernel030(unsigned long addr, unsigned long size, unsigned long dest);
extern char end_enter_kernel030;
extern void enter_kernel040(unsigned long addr, unsigned long size, unsigned long dest);
@ -35,14 +33,20 @@ extern char end_enter_kernel040;
#define BI_ALLOC_SIZE (4096L) // Allocate 4K for bootinfo
#define KERNEL_ALIGN (256L * 1024L) // Kernel alignment, on 256K boundary
extern unsigned long _kernel_image_offset;
extern unsigned long _kernel_image_size;
extern unsigned long _kernel_size;
extern unsigned long _ramdisk_offset;
extern unsigned long _ramdisk_size;
extern char _command_line;
unsigned long kernel_image_start;
unsigned long ramdisk_start;
int main(int argc, char** argv)
{
#ifdef TARGET_M68K
char * kernel;
char* kernel_image_start = &_kernel_start;
unsigned long kernel_image_size = &_kernel_end - &_kernel_start;
unsigned long kernel_size = (unsigned long)&_KERNEL_SIZE;
unsigned long physImage;
entry_t entry;
int ret;
@ -63,6 +67,16 @@ int main(int argc, char** argv)
bootinfo_init();
/* load kernel */
printf("vmlinux %s\n", &_command_line);
printf("Loading kernel...\n");
kernel_image_start = (unsigned long)load_image(
(unsigned long)_kernel_image_offset,
_kernel_image_size);
printf("Kernel image loaded at 0x%lx\n", kernel_image_start);
printf("Kernel image size is %ld Bytes\n", _kernel_image_size);
#ifdef TARGET_PPC
if (arch_type == gestalt68k)
@ -85,19 +99,20 @@ int main(int argc, char** argv)
printf("Available Memory: %ld kB\n", bank_mem_avail() / 1024);
printf("Kernel image found at %p\n", kernel_image_start);
printf("Kernel image size is %ld Bytes\n", kernel_image_size);
if (kernel_image_size != 0)
if (_kernel_image_size != 0)
{
if (_kernel_size == 0)
_kernel_size = _kernel_image_size * 3;
/* add KERNEL_ALIGN if we have to align
* and BI_ALLOC_SIZE for bootinfo
*/
kernel = (char*)malloc(kernel_size + 4 + BI_ALLOC_SIZE);
kernel = (char*)malloc(_kernel_size + 4 + BI_ALLOC_SIZE);
if (kernel == 0)
{
printf("cannot allocate %ld bytes\n", kernel_size);
printf("cannot allocate %ld bytes\n", _kernel_size);
while(1);
}
@ -105,6 +120,8 @@ int main(int argc, char** argv)
kernel = (unsigned char*)(((unsigned long)kernel + 3) & 0xFFFFFFFC);
uncompress(kernel);
printf("\n");
}
else
{
@ -112,6 +129,22 @@ int main(int argc, char** argv)
return 1; /* to make gcc happy */
}
/* free kernel image */
free((void*)kernel_image_start);
/* load ramdisk if needed */
if (_ramdisk_size != 0)
{
printf("Loading RAMDISK...\n");
ramdisk_start = (unsigned long)load_image(
(unsigned long)_ramdisk_offset,
_ramdisk_size);
printf("RAMDISK loaded at 0x%lx\n", ramdisk_start);
printf("RAMDISK size is %ld Bytes\n", _ramdisk_size);
}
ret = logical2physical((unsigned long)kernel, &physImage);
/* compute final address of kernel */
@ -128,7 +161,7 @@ int main(int argc, char** argv)
/* set bootinfo at end of kernel image */
set_kernel_bootinfo(kernel + kernel_size);
set_kernel_bootinfo(kernel + _kernel_size);
/* disable interrupt */
@ -167,14 +200,12 @@ int main(int argc, char** argv)
}
start_mem = boot_info.memory[0].addr + PAGE_SIZE;
printf("\n");
printf("Physical address of kernel will be 0x%08lx\n", start_mem);
printf("Ok, booting the kernel.\n");
entry(physImage, kernel_size + BI_ALLOC_SIZE, start_mem);
entry(physImage, _kernel_size + BI_ALLOC_SIZE, start_mem);
return 0;

View File

@ -11,8 +11,9 @@
#include "uncompress.h"
#include "misc.h"
extern char _kernel_start;
extern char _kernel_end;
unsigned long kernel_image_start;
unsigned long kernel_image_size;
/*
* gzip declarations
@ -52,8 +53,8 @@ static unsigned long output_ptr = 0;
static int fill_inbuf(void)
{
inbuf = &_kernel_start;
insize = &_kernel_end - &_kernel_start;
inbuf = (uch*)kernel_image_start;
insize = kernel_image_size;
inptr = 1;
return inbuf[0];
}
@ -94,6 +95,7 @@ static void flush_window(void)
unsigned long uncompress(char* buf)
{
output_data = buf;
makecrc();
printf("Uncompressing kernel to %p", buf);
gunzip();