The initrd now uses the mkinitrd format and the kernel now loads it.

This commit is contained in:
Jonas 'Sortie' Termansen 2011-08-27 20:07:08 +02:00
parent d9c0c8d0cd
commit 011addf46c
3 changed files with 27 additions and 11 deletions

View File

@ -5,7 +5,7 @@ endif
REMOTE=192.168.2.6
REMOTEUSER=sortie
REMOTECOPYDIR:=/home/$(REMOTEUSER)/Desktop/MaxsiOS
MODULES=libmaxsi hello pong sortix
MODULES=libmaxsi hello pong mkinitrd sortix
VERSION=0.4
DEBNAME:=sortix_$(VERSION)_$(CPU)
@ -17,6 +17,7 @@ PACKAGENAME:=sortix
ISODIR:=builds/$(DEBNAME)-iso
ISOFILE:=builds/$(DEBNAME).iso
JSNAME:=jssortix_$(VERSION)_$(CPU).bin
INITRDDIR:=initrd
all:
(for D in $(MODULES); do $(MAKE) all $(MFLAGS) --directory $$D; done)
@ -99,7 +100,12 @@ iso: all debsource
mkdir -p $(ISODIR)
cp -r isosrc/. $(ISODIR)
cp sortix/sortix.bin $(ISODIR)/boot
cp hello/hello $(ISODIR)/boot/sortix.initrd
mkdir -p $(INITRDDIR)
cp hello/hello $(INITRDDIR)
cp pong/pong $(INITRDDIR)
cp $(INITRDDIR)/hello $(INITRDDIR)/init
(cd $(INITRDDIR) && ../mkinitrd/mkinitrd * -o ../$(ISODIR)/boot/sortix.initrd)
rm -rf $(INITRDDIR)
cp builds/$(DEBSRCNAME)-src.tar.gz $(ISODIR)
grub-mkrescue -o $(ISOFILE) $(ISODIR)
rm -rf $(ISODIR)

3
mkinitrd/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
mkinitrd
lsinitrd
catinitrd

View File

@ -45,6 +45,7 @@
#include "serialterminal.h"
#include "vgaterminal.h"
#include "elf.h"
#include "initrd.h"
using namespace Maxsi;
@ -209,6 +210,8 @@ namespace Sortix
initrd = modules[2*I+0];
break;
}
if ( initrd == NULL ) { PanicF("No initrd provided"); }
#endif
// Initialize the GDT and TSS structures.
@ -250,18 +253,22 @@ namespace Sortix
Process* process = new Process(addrspace);
if ( process == 0 ) { Panic("kernel.cpp: Could not allocate the first process!"); }
if ( initrd != NULL )
{
initstart = (Thread::Entry) ELF::Construct(process, initrd, initrdsize);
if ( initstart == NULL )
{
Panic("kernel.cpp: Could not construct ELF program");
}
InitRD::Init(initrd, initrdsize);
// HACK: This should be determined from other information!
process->_endcodesection = 0x400000UL;
const char* initname = "init";
size_t programsize = 0;
byte* program = InitRD::Open(initname, &programsize);
if ( program == NULL ) { PanicF("initrd did not contain '%s'", initname); }
initstart = (Thread::Entry) ELF::Construct(process, program, programsize);
if ( initstart == NULL )
{
Panic("kernel.cpp: Could not construct ELF program");
}
// HACK: This should be determined from other information!
process->_endcodesection = 0x400000UL;
if ( Scheduler::CreateThread(process, initstart) == NULL )
{
Panic("Could not create a sample thread!");