Processes in the initrd are now made from ELF files.
This commit is contained in:
parent
4898343e2f
commit
013c5b5e71
|
@ -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)
|
||||||
|
|
||||||
|
|
|
@ -1,46 +1,15 @@
|
||||||
# This is a bit bothersome design, but it should serve well enough as a simple
|
# Set up variables such that we can easily cross-compile.
|
||||||
# cross-compiler for the Sortix operating system.
|
OSROOT=..
|
||||||
|
include ../crosscompilemakefile.mak
|
||||||
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
|
|
||||||
|
|
||||||
all: hello
|
all: hello
|
||||||
|
|
||||||
hello: hello.o
|
hello: hello.o
|
||||||
$(LD) $(LDFLAGS) hello.o -o hello.tmp $(LIBC)
|
$(LD) $(LDFLAGS) hello.o -o hello $(LIBS)
|
||||||
objcopy -O binary hello.tmp hello
|
|
||||||
|
|
||||||
hello.o: hello.cpp
|
hello.o: hello.cpp
|
||||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -O2 -c hello.cpp -o hello.o
|
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -O2 -c hello.cpp -o hello.o
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f hello.tmp hello.o hello
|
rm -f hello.o hello
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,7 @@
|
||||||
#include "uart.h"
|
#include "uart.h"
|
||||||
#include "serialterminal.h"
|
#include "serialterminal.h"
|
||||||
#include "vgaterminal.h"
|
#include "vgaterminal.h"
|
||||||
|
#include "elf.h"
|
||||||
|
|
||||||
using namespace Maxsi;
|
using namespace Maxsi;
|
||||||
|
|
||||||
|
@ -251,19 +252,14 @@ namespace Sortix
|
||||||
|
|
||||||
if ( initrd != NULL )
|
if ( initrd != NULL )
|
||||||
{
|
{
|
||||||
addr_t loadat = process->_endcodesection;
|
initstart = (Thread::Entry) ELF::Construct(initrd, initrdsize);
|
||||||
|
if ( initstart == NULL )
|
||||||
for ( size_t i = 0; i < initrdsize; i += 4096 )
|
|
||||||
{
|
{
|
||||||
addr_t apppage = Page::Get();
|
Panic("kernel.cpp: Could not construct ELF program");
|
||||||
if ( apppage == 0 ) { Panic("kernel.cpp: not enough memory for initrd!"); }
|
|
||||||
VirtualMemory::MapUser(loadat + i, apppage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Memory::Copy((void*) loadat, initrd, initrdsize);
|
// HACK: This should be determined from other information!
|
||||||
initstart = (Thread::Entry) loadat;
|
process->_endcodesection = 0x400000UL;
|
||||||
|
|
||||||
process->_endcodesection += initrdsize;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( Scheduler::CreateThread(process, initstart) == NULL )
|
if ( Scheduler::CreateThread(process, initstart) == NULL )
|
||||||
|
|
Loading…
Reference in New Issue