Processes in the initrd are now made from ELF files.

This commit is contained in:
Jonas 'Sortie' Termansen 2011-08-23 00:29:59 +02:00
parent 4898343e2f
commit 013c5b5e71
3 changed files with 46 additions and 46 deletions

35
crosscompilemakefile.mak Normal file
View File

@ -0,0 +1,35 @@
ifndef CPU
CPU=x86
endif
ifeq ($(CPU),x86)
X86FAMILY=1
CPUDEFINES=-DPLATFORM_X86
CPUFLAGS=-m32
CPULDFLAGS=-melf_i386
endif
ifeq ($(CPU),x64)
X86FAMILY=1
CPUDEFINES=-DPLATFORM_X64
CPUFLAGS=-m64
CPULDFLAGS=-melf_x86_64
endif
LIBMAXSIROOT=$(OSROOT)/libmaxsi
LIBC=$(LIBMAXSIROOT)/libc.a $(LIBMAXSIROOT)/start.o
LIBS=$(LIBC)
CPPFLAGS=$(CPUDEFINES)
FLAGS=-nostdinc -nostdlib -fno-builtin -nostartfiles -nodefaultlibs
INCLUDES=-I $(LIBMAXSIROOT)/c/h/ -I $(OSROOT)/
LD=ld
LDFLAGS=$(CPULDFLAGS)
CC=gcc
CFLAGS=$(CPUFLAGS) $(FLAGS) $(INCLUDES)
CXX=g++
CXXFLAGS=$(CPUFLAGS) $(FLAGS) $(INCLUDES)

View File

@ -1,46 +1,15 @@
# This is a bit bothersome design, but it should serve well enough as a simple
# cross-compiler for the Sortix operating system.
ifndef CPU
CPU=x86
endif
ifeq ($(CPU),x86)
X86FAMILY=1
CPUDEFINES=-DPLATFORM_X86
CPUFLAGS=-m32
CPULDFLAGS=-melf_i386
endif
ifeq ($(CPU),x64)
X86FAMILY=1
CPUDEFINES=-DPLATFORM_X64
CPUFLAGS=-m64
CPULDFLAGS=-melf_x86_64
endif
LIBMAXSIROOT=../libmaxsi
INCLUDES=-I $(LIBMAXSIROOT)/c/h/ -I ../
CPPFLAGS=$(CPUDEFINES)
LD=ld
LDFLAGS=$(CPULDFLAGS) -Ttext 400000 $(LIBMAXSIROOT)/start.o
CC=gcc
CFLAGS=$(CPUFLAGS) -nostdinc -nostdlib -fno-builtin -nostartfiles -nodefaultlibs -fno-stack-protector $(INCLUDES)
CXX=g++
CXXFLAGS=$(CPUFLAGS) -nostdinc -nostdlib -fno-builtin -nostartfiles -nodefaultlibs -fno-exceptions -fno-rtti -fno-stack-protector $(INCLUDES)
LIBC=$(LIBMAXSIROOT)/libc.a
# Set up variables such that we can easily cross-compile.
OSROOT=..
include ../crosscompilemakefile.mak
all: hello
hello: hello.o
$(LD) $(LDFLAGS) hello.o -o hello.tmp $(LIBC)
objcopy -O binary hello.tmp hello
$(LD) $(LDFLAGS) hello.o -o hello $(LIBS)
hello.o: hello.cpp
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -O2 -c hello.cpp -o hello.o
clean:
rm -f hello.tmp hello.o hello
rm -f hello.o hello

View File

@ -44,6 +44,7 @@
#include "uart.h"
#include "serialterminal.h"
#include "vgaterminal.h"
#include "elf.h"
using namespace Maxsi;
@ -251,19 +252,14 @@ namespace Sortix
if ( initrd != NULL )
{
addr_t loadat = process->_endcodesection;
for ( size_t i = 0; i < initrdsize; i += 4096 )
initstart = (Thread::Entry) ELF::Construct(initrd, initrdsize);
if ( initstart == NULL )
{
addr_t apppage = Page::Get();
if ( apppage == 0 ) { Panic("kernel.cpp: not enough memory for initrd!"); }
VirtualMemory::MapUser(loadat + i, apppage);
Panic("kernel.cpp: Could not construct ELF program");
}
Memory::Copy((void*) loadat, initrd, initrdsize);
initstart = (Thread::Entry) loadat;
process->_endcodesection += initrdsize;
// HACK: This should be determined from other information!
process->_endcodesection = 0x400000UL;
}
if ( Scheduler::CreateThread(process, initstart) == NULL )