Skip to content
Snippets Groups Projects
Commit 69108852 authored by Paul Weiß (Poohl)'s avatar Paul Weiß (Poohl)
Browse files

u7 docu

parent ea06554e
Branches main
Tags u7
No related merge requests found
......@@ -36,6 +36,7 @@ void release_addsp_slot(addsp_queue* q, int slt) {
q->available++;
}
// this is needed by the process mgmt, but we can't turn on the mmu before process mgmt
void init_mmu_mgmt() {
init_addsp_queue(&addsp_q);
}
......@@ -63,17 +64,16 @@ void init_first_level_pagetable(uint address_space_id) {
address_spaces[address_space_id].desc[i] = (AP_NONE_NONE << 10) | 0b10;
for (uint i = (UNDEF_MEMORY2 >> 20); i < 249; ++i)
address_spaces[address_space_id].desc[i] = (AP_NONE_NONE << 10) | 0b10;
// make userland acessible by users
// make usercode acessible by users
uint userland_desc = EXTERNAL_SRAM >> 20;
address_spaces[address_space_id].desc[userland_desc] = (userland_desc << 20) | (AP_RW_R << 10) | 0b10;
/*for (uint i = 0; i < 63; ++i) {
address_spaces[address_space_id].desc[userland_desc + 1 + i] |= (AP_RW_RW << 10);
}*/
// modify the mapping to switch 1MB of sram with 1MB of undef memory
//address_spaces[address_space_id].desc[(EXTERNAL_SRAM + 17*MEGABYTE) >> 20] = (UNDEF_MEMORY1) | (AP_RW_RW << 10) | 0b10;
//address_spaces[address_space_id].desc[(UNDEF_MEMORY1) >> 20] = (EXTERNAL_SRAM + 17*MEGABYTE) | (AP_RW_RW << 10) | 0b10;
}
/**
* Grants access to a section of memory of size size located at dest in physical address space
* and mapped at address in logical address space address_space_id.
*/
int set_ap(uint address_space_id, void* address, uint size, void* dest, uint ap) {
if (size != MEGABYTE)
return -1;
......
......@@ -78,7 +78,6 @@ void c_entry(void) {
demo_t.start = &u7_demo;
new_thread("demo", &demo_t);
/* interrupt tst loop*/
while (42) {
asm volatile("nop":::);
......
......@@ -67,8 +67,11 @@ void idle() {
}
void exit(u32* hw_context) {
// Don't call tis directly frem kernel... Why would you?
// if (current.open_handles == 0)
// Don't call this directly from kernel... Why would you?
// we can only release a process if it has no children,
// as it might be owner of the address space.
// we can only release the address_space if we're actually its owner.
if (processes[current].children > 0) {
processes[current].state = ZOMBIE;
} else {
......@@ -137,7 +140,9 @@ int new_thread(char* name, init_thread_state_args* args) {
return internal_new_thread_finalizer(name, id);
}
// this one is not yet updated for the children + address-space thing.
int new_thread_raw(char* name, cpu_context* init_state, bool may_be_sys) {
return -1;
if (!cpu_context_validate(init_state, may_be_sys)) return -2;
int id = get_tcb_slot(&tcbq);
if (id < 0) return -1;
......@@ -158,12 +163,14 @@ void thread_swap_callback(u32* context) {
break;
// get your chainsaw and your shotgun cause we're going on a zombie-hunt
// we haven't upgraded to the recursive shotgun yet.
if (processes[next].state == ZOMBIE && processes[next].children == 0) {
release_tcb_slot(&tcbq, processes[next].id);
release_address_space(processes[next].address_space);
processes[next].state = DEAD;
if (processes[next].parent)
processes[processes[next].parent].children -= 1;
else
release_address_space(processes[next].address_space);
printf("BOOM! -> %x\n", processes[next].id);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment