Let the user application decide upon the resource ID (RID)
All checks were successful
Build documentation / build-and-deploy (push) Successful in 22s
All checks were successful
Build documentation / build-and-deploy (push) Successful in 22s
This commit is contained in:
@@ -42,10 +42,9 @@ struct proc* proc_from_elf (uint8_t* elf_contents) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int kstk_rid = atomic_fetch_add (&proc->rids, 1);
|
||||
struct proc_resource_mem_init kstk_mem_init = {.pages = KSTACK_SIZE / PAGE_SIZE};
|
||||
struct proc_resource* kstk_r =
|
||||
proc_create_resource (proc, kstk_rid, PR_MEM, RV_PRIVATE, (void*)&kstk_mem_init);
|
||||
proc_create_resource (proc, 0, PR_MEM, RV_PRIVATE, (void*)&kstk_mem_init);
|
||||
if (kstk_r == NULL) {
|
||||
pmm_free (proc->pd->cr3_paddr, 1);
|
||||
free (proc->pd);
|
||||
@@ -55,10 +54,9 @@ struct proc* proc_from_elf (uint8_t* elf_contents) {
|
||||
|
||||
proc->pdata.kernel_stack = kstk_r->u.mem.paddr + (uintptr_t)hhdm->offset + KSTACK_SIZE;
|
||||
|
||||
int ustk_rid = atomic_fetch_add (&proc->rids, 1);
|
||||
struct proc_resource_mem_init ustk_mem_init = {.pages = USTACK_SIZE / PAGE_SIZE};
|
||||
struct proc_resource* ustk_r =
|
||||
proc_create_resource (proc, ustk_rid, PR_MEM, RV_PRIVATE, (void*)&ustk_mem_init);
|
||||
proc_create_resource (proc, 1, PR_MEM, RV_PRIVATE, (void*)&ustk_mem_init);
|
||||
if (ustk_r == NULL) {
|
||||
kstk_r->ops.cleanup (proc, kstk_r);
|
||||
free (kstk_r);
|
||||
|
||||
@@ -144,6 +144,7 @@ struct elf_aux proc_load_segments (struct proc* proc, uint8_t* elf) {
|
||||
aux.phent = ehdr->e_phentsize;
|
||||
|
||||
struct limine_hhdm_response* hhdm = limine_hhdm_request.response;
|
||||
int rid_counter = 10;
|
||||
|
||||
for (uint64_t segment = 0; segment < ehdr->e_phnum; segment++) {
|
||||
Elf64_Phdr* phdr =
|
||||
@@ -159,10 +160,9 @@ struct elf_aux proc_load_segments (struct proc* proc, uint8_t* elf) {
|
||||
|
||||
size_t blks = div_align_up (phdr->p_memsz + off, PAGE_SIZE);
|
||||
|
||||
int rid = atomic_fetch_add (&proc->rids, 1);
|
||||
struct proc_resource_mem_init mem_init = {.pages = blks};
|
||||
struct proc_resource* r =
|
||||
proc_create_resource (proc, rid, PR_MEM, RV_PRIVATE, (void*)&mem_init);
|
||||
proc_create_resource (proc, rid_counter++, PR_MEM, RV_PRIVATE, (void*)&mem_init);
|
||||
if (r == NULL) {
|
||||
DEBUG ("pmm oom error while loading ELF segments! (tried to alloc %zu blks)\n", blks);
|
||||
}
|
||||
|
||||
@@ -49,7 +49,6 @@ struct proc {
|
||||
struct cpu* cpu;
|
||||
atomic_int state;
|
||||
struct rb_node_link* resource_tree;
|
||||
atomic_int rids;
|
||||
struct proc_suspension_q* suspension_q;
|
||||
};
|
||||
|
||||
|
||||
@@ -57,14 +57,18 @@ DEFINE_SYSCALL (sys_proc_unmap) {
|
||||
return ok ? SR_OK : -SR_OOM_ERROR;
|
||||
}
|
||||
|
||||
/* int proc_create_resource_mem (size_t pages, int vis, uintptr_t* out_paddr) */
|
||||
/* int proc_create_resource_mem (int rid, size_t pages, int vis, uintptr_t* out_paddr) */
|
||||
DEFINE_SYSCALL (sys_proc_create_resource_mem) {
|
||||
struct limine_hhdm_response* hhdm = limine_hhdm_request.response;
|
||||
spin_lock_ctx_t ctxprpd;
|
||||
|
||||
size_t pages = (size_t)a1;
|
||||
int vis = (int)a2;
|
||||
uintptr_t* out_paddr_buf = (uintptr_t*)a3;
|
||||
int rid = (int)a1;
|
||||
size_t pages = (size_t)a2;
|
||||
int vis = (int)a3;
|
||||
uintptr_t* out_paddr_buf = (uintptr_t*)a4;
|
||||
|
||||
if (rid < 0)
|
||||
return -SR_BAD_RESOURCE;
|
||||
|
||||
spin_lock (&proc->pd->lock, &ctxprpd);
|
||||
|
||||
@@ -79,7 +83,6 @@ DEFINE_SYSCALL (sys_proc_create_resource_mem) {
|
||||
|
||||
uintptr_t* out_paddr_buf_vaddr = (uintptr_t*)((uintptr_t)hhdm->offset + out_paddr_buf_paddr);
|
||||
|
||||
int rid = atomic_fetch_add (&proc->rids, 1);
|
||||
struct proc_resource_mem_init mem_init = {.pages = pages};
|
||||
struct proc_resource* r = proc_create_resource (proc, rid, PR_MEM, vis, &mem_init);
|
||||
|
||||
@@ -91,11 +94,14 @@ DEFINE_SYSCALL (sys_proc_create_resource_mem) {
|
||||
}
|
||||
}
|
||||
|
||||
/* int proc_create_resource_mutex (int vis) */
|
||||
/* int proc_create_resource_mutex (int rid, int vis) */
|
||||
DEFINE_SYSCALL (sys_proc_create_resource_mutex) {
|
||||
int vis = (int)a1;
|
||||
int rid = (int)a1;
|
||||
int vis = (int)a2;
|
||||
|
||||
if (rid < 0)
|
||||
return -SR_BAD_RESOURCE;
|
||||
|
||||
int rid = atomic_fetch_add (&proc->rids, 1);
|
||||
struct proc_resource* r = proc_create_resource (proc, rid, PR_MUTEX, vis, NULL);
|
||||
if (r != NULL)
|
||||
return r->rid;
|
||||
|
||||
Reference in New Issue
Block a user