mirror of
https://git.planet-casio.com/Lephenixnoir/gint.git
synced 2025-04-03 17:17:10 +02:00
kernel: get arenas from MPM load info
This commit is contained in:
parent
fa9c225c99
commit
411b1a3d7d
3 changed files with 43 additions and 10 deletions
|
@ -33,13 +33,17 @@ uint8_t *gint_driver_flags = NULL;
|
|||
/* Top of the stack */
|
||||
void *gint_stack_top = NULL;
|
||||
|
||||
u32 *gint_load_info = NULL;
|
||||
|
||||
//---
|
||||
// Initialization and unloading
|
||||
//---
|
||||
|
||||
/* kinit(): Install and start gint */
|
||||
void kinit(void)
|
||||
void kinit(u32 *load_info)
|
||||
{
|
||||
gint_load_info = load_info;
|
||||
|
||||
/* Figure out which CASIOWIN API to use based on the OS type. */
|
||||
#if GINT_OS_CG
|
||||
char *version = (void *)0x80020020;
|
||||
|
@ -134,6 +138,33 @@ void kinit(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
/* Create arenas in locations provided by loader */
|
||||
#if GINT_OS_CG
|
||||
u32 load_arena_start = 0;
|
||||
char const *names[4] = { "_ld1", "_ld2", "_ld3", "_ld4" };
|
||||
int count = 0;
|
||||
for(int i = 0; load_info && load_info[i] && count < 4; i += 2)
|
||||
{
|
||||
if(load_info[i] == 0x00000010)
|
||||
load_arena_start = load_info[i+1];
|
||||
else if(load_info[i] == 0x00000011 && load_arena_start)
|
||||
{
|
||||
u32 load_arena_end = load_info[i+1];
|
||||
kmalloc_arena_t *arena = kmalloc(sizeof *arena, NULL);
|
||||
if(arena)
|
||||
{
|
||||
arena->name = names[count];
|
||||
arena->is_default = true;
|
||||
arena->start = (void *)load_arena_start;
|
||||
arena->end = (void *)load_arena_end;
|
||||
kmalloc_init_arena(arena, true);
|
||||
kmalloc_add_arena(arena);
|
||||
}
|
||||
load_arena_start = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Allocate world buffers for the OS and for gint */
|
||||
gint_world_os = gint_world_alloc();
|
||||
gint_world_addin = gint_world_alloc();
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
#ifndef GINT_CORE_KERNEL
|
||||
#define GINT_CORE_KERNEL
|
||||
|
||||
#include <gint/defs/types.h>
|
||||
|
||||
/* gint_load_onchip_sections(): Initialize on-chip memory sections */
|
||||
void gint_load_onchip_sections(void);
|
||||
|
||||
|
@ -13,7 +15,7 @@ void gint_load_onchip_sections(void);
|
|||
void gint_copy_vram(void);
|
||||
|
||||
/* kinit(): Install and start gint */
|
||||
void kinit(void);
|
||||
void kinit(u32 *load_info);
|
||||
|
||||
/* kquit(): Quit gint and give back control to the system */
|
||||
void kquit(void);
|
||||
|
|
|
@ -109,7 +109,7 @@ void gint_load_onchip_sections(void)
|
|||
}
|
||||
}
|
||||
|
||||
static int start2(int isappli, int optnum)
|
||||
static int start2(int load_type, u32 *load_info)
|
||||
{
|
||||
/* We are currently in a dynamic userspace mapping of an add-in run
|
||||
from the storage memory. We are running in privileged mode with one
|
||||
|
@ -174,8 +174,11 @@ static int start2(int isappli, int optnum)
|
|||
}
|
||||
#endif
|
||||
|
||||
/* Install gint, switch VBR and initialize drivers */
|
||||
kinit();
|
||||
/* Install gint, switch VBR and initialize drivers. If loading information
|
||||
was provided, pass it on. */
|
||||
if(load_type == 0x4d504d30 /* 'MPM0' */ && !((u32)load_info & 3)) {}
|
||||
else load_info = NULL;
|
||||
kinit(load_info);
|
||||
|
||||
/* We are now running on our own in kernel mode. Since we have taken
|
||||
control of interrupts, pretty much any interaction with the system
|
||||
|
@ -190,9 +193,6 @@ static int start2(int isappli, int optnum)
|
|||
what it wants in exit() after main() finishes executing */
|
||||
if(!setjmp(gint_exitbuf)) {
|
||||
callarray(&bctors, &ectors);
|
||||
// TODO: record isappli and optnum in globals
|
||||
(void)isappli;
|
||||
(void)optnum;
|
||||
exit(main());
|
||||
}
|
||||
else {
|
||||
|
@ -211,11 +211,11 @@ static int start2(int isappli, int optnum)
|
|||
}
|
||||
|
||||
GSECTION(".text.entry")
|
||||
int start(int isappli, int optnum)
|
||||
int start(int load_type, u32 *load_info)
|
||||
{
|
||||
int rc;
|
||||
while(1) {
|
||||
rc = start2(isappli, optnum);
|
||||
rc = start2(load_type, load_info);
|
||||
if(!gint_restart) break;
|
||||
gint_osmenu_native();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue