Compare commits
4 changed files with 3 additions and 29 deletions
|
|
@ -81,7 +81,7 @@ struct proc {
|
|||
int proc_kill(struct proc *proc, int signal);
|
||||
void proc_mmap(struct proc *proc, paddr_t p, vaddr_t v, size_t len, u64 flags);
|
||||
ssize_t proc_load_file(const char *file, struct proc *proc);
|
||||
struct proc *proc_create(struct thread *parent);
|
||||
struct proc *proc_create(struct proc *parent);
|
||||
void proc_free(struct proc *proc);
|
||||
void switch_to(struct thread *from, struct thread *to);
|
||||
void proc_init();
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
#include <stdbool.h>
|
||||
|
||||
void *memcpy(void *dest, const void *src, size_t num);
|
||||
void *memcpy_user(struct proc *proc, void *dest, const void *src, size_t num);
|
||||
int memcmp(const void *aa, const void *bb, size_t num);
|
||||
int strcmp(const char *a, const char *b);
|
||||
int strncmp(const char *a, const char *b, size_t n);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
#include <arch/page.h>
|
||||
#include <arch/proc.h>
|
||||
#include <kernel/proc.h>
|
||||
#include <kernel/slab.h>
|
||||
#include <lib/string.h>
|
||||
|
|
@ -56,7 +55,6 @@ static int copy_parent(struct proc *new, struct proc *parent)
|
|||
|
||||
void *vm_alloc = proc_alloc(new, area->len);
|
||||
proc_mmap(new, TO_PHYS(vm_alloc), area->start, area->len, area->flags);
|
||||
memcpy_user(parent, (void *)area->start, vm_alloc, area->len);
|
||||
|
||||
node = rbt_successor(node);
|
||||
}
|
||||
|
|
@ -66,7 +64,7 @@ static int copy_parent(struct proc *new, struct proc *parent)
|
|||
return 0;
|
||||
}
|
||||
|
||||
struct proc *proc_create(struct thread *parent)
|
||||
struct proc *proc_create(struct proc *parent)
|
||||
{
|
||||
struct proc *ret = slab_alloc(proc_slab);
|
||||
if (!ret)
|
||||
|
|
@ -106,7 +104,7 @@ struct proc *proc_create(struct thread *parent)
|
|||
ret->main_thread = r_mt;
|
||||
|
||||
if (parent) {
|
||||
int res = copy_parent(ret, parent->proc);
|
||||
int res = copy_parent(ret, parent);
|
||||
if (res)
|
||||
kerr("failed to copy parent memmap for new process: %s\n", strerror(-res));
|
||||
}
|
||||
|
|
@ -114,12 +112,6 @@ struct proc *proc_create(struct thread *parent)
|
|||
return ret;
|
||||
}
|
||||
|
||||
pid_t sys_fork()
|
||||
{
|
||||
struct thread *cur_thread = get_cur_thread();
|
||||
struct proc *ret = proc_create(cur_thread);
|
||||
}
|
||||
|
||||
void proc_free(struct proc *proc)
|
||||
{
|
||||
slab_free(proc_slab, proc);
|
||||
|
|
|
|||
17
lib/string.c
17
lib/string.c
|
|
@ -1,8 +1,6 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
#include <kernel/types.h>
|
||||
#include <kernel/slab.h>
|
||||
#include <kernel/proc.h>
|
||||
#include <arch/page.h>
|
||||
#include <lib/string.h>
|
||||
|
||||
void *memcpy(void *dest, const void *src, size_t num)
|
||||
|
|
@ -247,18 +245,3 @@ char *basename(const char *path)
|
|||
kfree(copy);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void *memcpy_user(struct proc *proc, void *dest, const void *src, size_t num)
|
||||
{
|
||||
pgd_t *pgd = pgd_get();
|
||||
|
||||
if (pgd != proc->pgd)
|
||||
pgd_load(proc->pgd);
|
||||
|
||||
memcpy(dest, src, num);
|
||||
|
||||
if (pgd != proc->pgd)
|
||||
pgd_load(pgd);
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue