mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
The initrd now uses the mkinitrd format and the kernel now loads it.
This commit is contained in:
parent
d9c0c8d0cd
commit
011addf46c
3 changed files with 27 additions and 11 deletions
10
Makefile
10
Makefile
|
@ -5,7 +5,7 @@ endif
|
||||||
REMOTE=192.168.2.6
|
REMOTE=192.168.2.6
|
||||||
REMOTEUSER=sortie
|
REMOTEUSER=sortie
|
||||||
REMOTECOPYDIR:=/home/$(REMOTEUSER)/Desktop/MaxsiOS
|
REMOTECOPYDIR:=/home/$(REMOTEUSER)/Desktop/MaxsiOS
|
||||||
MODULES=libmaxsi hello pong sortix
|
MODULES=libmaxsi hello pong mkinitrd sortix
|
||||||
|
|
||||||
VERSION=0.4
|
VERSION=0.4
|
||||||
DEBNAME:=sortix_$(VERSION)_$(CPU)
|
DEBNAME:=sortix_$(VERSION)_$(CPU)
|
||||||
|
@ -17,6 +17,7 @@ PACKAGENAME:=sortix
|
||||||
ISODIR:=builds/$(DEBNAME)-iso
|
ISODIR:=builds/$(DEBNAME)-iso
|
||||||
ISOFILE:=builds/$(DEBNAME).iso
|
ISOFILE:=builds/$(DEBNAME).iso
|
||||||
JSNAME:=jssortix_$(VERSION)_$(CPU).bin
|
JSNAME:=jssortix_$(VERSION)_$(CPU).bin
|
||||||
|
INITRDDIR:=initrd
|
||||||
|
|
||||||
all:
|
all:
|
||||||
(for D in $(MODULES); do $(MAKE) all $(MFLAGS) --directory $$D; done)
|
(for D in $(MODULES); do $(MAKE) all $(MFLAGS) --directory $$D; done)
|
||||||
|
@ -99,7 +100,12 @@ iso: all debsource
|
||||||
mkdir -p $(ISODIR)
|
mkdir -p $(ISODIR)
|
||||||
cp -r isosrc/. $(ISODIR)
|
cp -r isosrc/. $(ISODIR)
|
||||||
cp sortix/sortix.bin $(ISODIR)/boot
|
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)
|
cp builds/$(DEBSRCNAME)-src.tar.gz $(ISODIR)
|
||||||
grub-mkrescue -o $(ISOFILE) $(ISODIR)
|
grub-mkrescue -o $(ISOFILE) $(ISODIR)
|
||||||
rm -rf $(ISODIR)
|
rm -rf $(ISODIR)
|
||||||
|
|
3
mkinitrd/.gitignore
vendored
Normal file
3
mkinitrd/.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
mkinitrd
|
||||||
|
lsinitrd
|
||||||
|
catinitrd
|
|
@ -45,6 +45,7 @@
|
||||||
#include "serialterminal.h"
|
#include "serialterminal.h"
|
||||||
#include "vgaterminal.h"
|
#include "vgaterminal.h"
|
||||||
#include "elf.h"
|
#include "elf.h"
|
||||||
|
#include "initrd.h"
|
||||||
|
|
||||||
using namespace Maxsi;
|
using namespace Maxsi;
|
||||||
|
|
||||||
|
@ -209,6 +210,8 @@ namespace Sortix
|
||||||
initrd = modules[2*I+0];
|
initrd = modules[2*I+0];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( initrd == NULL ) { PanicF("No initrd provided"); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Initialize the GDT and TSS structures.
|
// Initialize the GDT and TSS structures.
|
||||||
|
@ -250,9 +253,14 @@ namespace Sortix
|
||||||
Process* process = new Process(addrspace);
|
Process* process = new Process(addrspace);
|
||||||
if ( process == 0 ) { Panic("kernel.cpp: Could not allocate the first process!"); }
|
if ( process == 0 ) { Panic("kernel.cpp: Could not allocate the first process!"); }
|
||||||
|
|
||||||
if ( initrd != NULL )
|
InitRD::Init(initrd, initrdsize);
|
||||||
{
|
|
||||||
initstart = (Thread::Entry) ELF::Construct(process, initrd, initrdsize);
|
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 )
|
if ( initstart == NULL )
|
||||||
{
|
{
|
||||||
Panic("kernel.cpp: Could not construct ELF program");
|
Panic("kernel.cpp: Could not construct ELF program");
|
||||||
|
@ -260,7 +268,6 @@ namespace Sortix
|
||||||
|
|
||||||
// HACK: This should be determined from other information!
|
// HACK: This should be determined from other information!
|
||||||
process->_endcodesection = 0x400000UL;
|
process->_endcodesection = 0x400000UL;
|
||||||
}
|
|
||||||
|
|
||||||
if ( Scheduler::CreateThread(process, initstart) == NULL )
|
if ( Scheduler::CreateThread(process, initstart) == NULL )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue