[kernel] Improve process init
Move process init from each process needing a main.s with _start to crt0.s in libc. Also change to a sysv-like initial stack with a j6-specific array of initialization values after the program arguments.
This commit is contained in:
@@ -1,25 +1,16 @@
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "j6/types.h"
|
||||
#include "j6/init.h"
|
||||
#include "j6/errors.h"
|
||||
#include "j6/signals.h"
|
||||
#include "j6/types.h"
|
||||
|
||||
#include <j6libc/syscalls.h>
|
||||
|
||||
extern "C" {
|
||||
void _init_libc(j6_process_init *);
|
||||
int main(int, const char **);
|
||||
}
|
||||
|
||||
j6_handle_t sys = j6_handle_invalid;
|
||||
size_t size = 0;
|
||||
|
||||
void
|
||||
_init_libc(j6_process_init *init)
|
||||
{
|
||||
sys = init->handles[0];
|
||||
size = reinterpret_cast<size_t>(init->handles[1]);
|
||||
void _get_init(size_t *initc, struct j6_init_value **initv);
|
||||
}
|
||||
|
||||
int
|
||||
@@ -27,12 +18,25 @@ main(int argc, const char **argv)
|
||||
{
|
||||
_syscall_system_log("fb driver starting");
|
||||
|
||||
if (size == 0)
|
||||
size_t initc = 0;
|
||||
j6_init_value *initv = nullptr;
|
||||
_get_init(&initc, &initv);
|
||||
|
||||
j6_init_framebuffer *fb = nullptr;
|
||||
for (unsigned i = 0; i < initc; ++i) {
|
||||
if (initv[i].type == j6_init_desc_framebuffer) {
|
||||
fb = reinterpret_cast<j6_init_framebuffer*>(initv[i].value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!fb)
|
||||
return 1;
|
||||
|
||||
uint32_t *fb = reinterpret_cast<uint32_t*>(0x100000000);
|
||||
uint32_t *fbp = reinterpret_cast<uint32_t*>(fb->addr);
|
||||
size_t size = fb->size;
|
||||
for (size_t i=0; i < size/4; ++i) {
|
||||
fb[i] = 0xff;
|
||||
fbp[i] = 0xff;
|
||||
}
|
||||
|
||||
_syscall_system_log("fb driver done, exiting");
|
||||
|
||||
Reference in New Issue
Block a user