static struct mem *store[PTABSIZE]; /* Where our memory currently lives */
static struct mem memblock[PTABSIZE];
-extern struct u_data *udata_shadow; /* FIXME HACK */
+extern struct u_data *udata_shadow;
static void mem_free(struct mem *m)
{
p is the process we are going to create maps for, udata.u_ptab is our
own process. init is a special case!
- FIXME: where do we need to call pagemap_alloc from to get it early
- and make the valaddr and init data special cases go away ?
*/
int pagemap_alloc(ptptr p)
kprintf("%d: pagemap_alloc %p\n", proc, p);
#endif
p->p_page = nproc;
- platform_udata_set(p);
+ if (platform_udata_set(p))
+ return ENOMEM;
/* Init is special */
if (p->p_pid == 1) {
struct memblk *mb;
extern void platform_switchout(void);
extern void platform_interrupt(void);
extern uint8_t platform_suspend(void);
-extern void platform_udata_set(ptptr p);
+extern uint8_t platform_udata_set(ptptr p);
extern void platform_swap_found(uint8_t part, uint8_t letter);
Propogate synchronous trap changes to Z80+MMU and Z180 illegal and maybe
generically jp 0 and 0 corruptor ?
-Dynamic udata allocation
-Do we need the extra irqstack any more ?
Move lots of p68000.S code into lowlevel-68000.S
Need some kind of CPU specific C file (or a general one with ifdefs ?) and
then move lots of platform/main.c into it.
Look into posix spawn functions or vfork and if /bin/sh can use them
+Longer term split into multiple segments (code R/O uncopied, data/stack etc
+copied)
+
DONE Add a 'user touches kernel' catcher on the debug/sim
DONE ps user/kernel include mismatch error
DONE (libc bug) calendar does not put a : before 'cannot open file'
DONE Switch from one process in memory model to flat model with parent first
and child custom stack build
DONE All I/O going via buffers
+DONE Dynamic udata allocation
+DONE Do we need the extra irqstack any more ?
void pagemap_init(void)
{
- /* FIXME: base should be from _end of binary aligned
- and size we want to probe early and deal with shifted monitor
- etc */
- kmemaddblk((void *)0x40000, 0xFF8000 - 0x40000);
+ /* Linker provided end of kernel */
+ extern uint8_t _end;
+ uint32_t e = (uint32_t)&_end;
+ kprintf("Kernel end %p\n", e);
+ /* Allocate the rest of memory to the userspace */
+ kmemaddblk((void *)e, 0xFF8000 - e);
}
/* Udata and kernel stacks */
-/* FIXME: dynamic allocation needed */
-u_block udata_block[PTABSIZE];
-/* FIXME: irqstack can go now I think */
-uint16_t irqstack[128]; /* Used for swapping only */
+/* We need an initial kernel stack and udata so the slot for init is
+ set up at compile time */
+u_block udata_block0;
+static u_block *udata_block[PTABSIZE] = {&udata_block0,};
/* This will belong in the core 68K code once finalized */
memcpy((void *)udata.u_codebase, &vdso, 0x40);
}
-void platform_udata_set(ptptr p)
+uint8_t platform_udata_set(ptptr p)
{
- p->p_udata = &udata_block[p - ptab].u_d;
+ u_block **up = &udata_block[p - ptab];
+ if (*up == NULL) {
+ *up = kmalloc(sizeof(struct u_block));
+ if (*up == NULL)
+ return ENOMEM;
+ kputs("alloc udata");
+ }
+ p->p_udata = &(*up)->u_d;
+ kprintf("udata %p\n", p->p_udata);
+ return 0;
}
extern void *get_usp(void);
#include "../kernel-68000.def"
-/*
- * Lots left to fill in
- */
.globl platform_reboot
.globl init_early
.globl program_vectors
.globl outchar
.globl platform_monitor
- .globl udata_block
+ .globl udata_block0
.globl devide_read_data
.globl devide_write_data
.globl vdso
bra platform_monitor
init_early:
- lea.l udata_block,a5 ; udata ptr
+ lea.l udata_block0,a5 ; udata ptr
move.l a5,udata_shadow ; shadow copy for entry/exit
rts