Add syscalls to get initrd size and copy it into user supplied memory
This commit is contained in:
parent
e8730b145a
commit
916ffea498
@ -8,6 +8,7 @@
|
||||
#include <tasking.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <initrd.h>
|
||||
|
||||
typedef struct {
|
||||
char filename[100];
|
||||
@ -157,18 +158,22 @@ void test_vfs(char* path,uint32_t box,uint32_t fs_box) {
|
||||
free(msg.msg);
|
||||
}
|
||||
|
||||
int main(char* initrd, uint32_t initrd_sz) {
|
||||
int main() {
|
||||
text_fb_info info;
|
||||
info.address=map_phys((void*)0xB8000,10);
|
||||
info.width=80;
|
||||
info.height=25;
|
||||
vga_init(info);
|
||||
vga_write_string("INIT\n");
|
||||
long size=initrd_sz();
|
||||
char* initrd=malloc(size);
|
||||
initrd_get(initrd);
|
||||
uint32_t datapos=find_loc("vfs",initrd);
|
||||
load_task(datapos,initrd);
|
||||
yield(); // Bochs fails here
|
||||
datapos=find_loc("fsdrv",initrd);
|
||||
load_task(datapos,initrd);
|
||||
free(initrd);
|
||||
yieldToPID(3);
|
||||
FILE* file;
|
||||
do {
|
||||
|
@ -4,7 +4,8 @@
|
||||
#include <cpu/ports.h>
|
||||
#include "paging.h"
|
||||
#include "../halt.h"
|
||||
#include "../..//vga_err.h"
|
||||
#include "../../vga_err.h"
|
||||
#include "../../kernel.h"
|
||||
#include "../tasking.h"
|
||||
#include "interrupt.h"
|
||||
#include "address_spaces.h"
|
||||
@ -232,6 +233,12 @@ void isr_handler(registers_t r) {
|
||||
serial_write_string((char*)r.ebx);
|
||||
} else if (r.eax==17) {
|
||||
tasking_exit((uint8_t)r.ebx);
|
||||
} else if (r.eax==18) {
|
||||
serial_printf("Initrd size is %d bytes\n",initrd_sz);
|
||||
r.ebx=initrd_sz;
|
||||
} else if (r.eax==19) {
|
||||
serial_printf("Copying initrd\n");
|
||||
memcpy((char*)r.ebx,initrd,initrd_sz);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -20,8 +20,8 @@ typedef struct {
|
||||
char typeflag[1];
|
||||
} tar_header;
|
||||
|
||||
static long initrd_sz;
|
||||
static char* initrd;
|
||||
long initrd_sz;
|
||||
char* initrd;
|
||||
typedef int (*func_ptr)();
|
||||
static struct multiboot_boot_header_tag* tags;
|
||||
|
||||
@ -102,10 +102,7 @@ void kmain(struct multiboot_boot_header_tag* hdr) {
|
||||
}
|
||||
copy_data(cr3,ptr,pheader.memsz,(void*)pheader.vaddr);
|
||||
}
|
||||
char* initrd2=alloc_memory((initrd_sz/4096)+1);
|
||||
memcpy(initrd2,initrd,initrd_sz);
|
||||
initrd2=put_data(cr3,initrd2,initrd_sz);
|
||||
createTaskCr3Param((void*)header.entry,cr3,(uint32_t)initrd2,initrd_sz);
|
||||
createTaskCr3((void*)header.entry,cr3);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
7
kernel/kernel.h
Normal file
7
kernel/kernel.h
Normal file
@ -0,0 +1,7 @@
|
||||
#ifndef KERNEL_H
|
||||
#define KERNEL_H
|
||||
|
||||
extern long initrd_sz;
|
||||
extern char* initrd;
|
||||
|
||||
#endif
|
15
libc/initrd.c
Normal file
15
libc/initrd.c
Normal file
@ -0,0 +1,15 @@
|
||||
long initrd_sz() {
|
||||
long size;
|
||||
asm volatile(" \
|
||||
mov $18, %%eax; \
|
||||
int $80; \
|
||||
":"=b"(size));
|
||||
return size;
|
||||
}
|
||||
|
||||
void initrd_get(char* initrd) {
|
||||
asm volatile(" \
|
||||
mov $19, %%eax; \
|
||||
int $80; \
|
||||
"::"b"(initrd));
|
||||
}
|
7
sysroot/usr/include/initrd.h
Normal file
7
sysroot/usr/include/initrd.h
Normal file
@ -0,0 +1,7 @@
|
||||
#ifndef INITRD_H
|
||||
#define INITRD_H
|
||||
|
||||
long initrd_sz();
|
||||
void initrd_get(char* initrd);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user