more fixes
This commit is contained in:
@@ -13,6 +13,7 @@ errno_t arch_task_init(
|
||||
uintptr_t stack_start,
|
||||
bool is_user
|
||||
);
|
||||
void arch_task_fini(struct arch_task_context* context);
|
||||
[[noreturn]]
|
||||
void arch_sched_jump_to_context(struct arch_context* context);
|
||||
[[noreturn]]
|
||||
|
||||
@@ -14,7 +14,15 @@
|
||||
#define __format(like, ...) gnu::format(like, __VA_ARGS__)
|
||||
#define __always_inline gnu::always_inline
|
||||
#define __visibility gnu::visibility
|
||||
#define __pure gnu::pure
|
||||
|
||||
// TODO: Workaround for clang which doesn't have these C23 standard attributes yet.
|
||||
#if !__has_c_attribute(unsequenced)
|
||||
#define unsequenced gnu::const
|
||||
#endif
|
||||
|
||||
#if !__has_c_attribute(reproducible)
|
||||
#define reproducible gnu::pure
|
||||
#endif
|
||||
|
||||
// Only clang has these hints, GCC would throw a warning here.
|
||||
// clang::noderef also don't support the C23 attribute format.
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <zinnia/errno.h>
|
||||
#include <bits/elf.h>
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -339,3 +340,16 @@ static inline uint32_t ELF64_R_SYM(uint64_t info) {
|
||||
static inline uint32_t ELF64_R_TYPE(uint64_t info) {
|
||||
return info & 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
struct vma;
|
||||
struct vmo;
|
||||
struct task;
|
||||
|
||||
struct exec_info {
|
||||
struct vma* space;
|
||||
struct vmo* file_obj;
|
||||
const char** argv;
|
||||
const char** envp;
|
||||
};
|
||||
|
||||
errno_t elf_load(struct exec_info* info, struct task** out);
|
||||
|
||||
+23
-9
@@ -1,24 +1,38 @@
|
||||
#pragma once
|
||||
#include <zinnia/compiler.h>
|
||||
#include <zinnia/errno.h>
|
||||
#include <zinnia/utils.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define MODULE_PROPERTY(name, data) \
|
||||
[[__used, __section(".mod." name)]] \
|
||||
static const char UNIQUE_IDENT(_name)[] = data;
|
||||
static const char UNIQUE_IDENT(_name)[] = data
|
||||
|
||||
#define MODULE(desc, author, license, version, entry) \
|
||||
void __module_start(struct module* _module) { \
|
||||
entry(_module); \
|
||||
#define MODULE_AUTHOR(author) MODULE_PROPERTY("author", author)
|
||||
#define MODULE_DESC(desc) MODULE_PROPERTY("desc", desc)
|
||||
#define MODULE_VERSION(version) MODULE_PROPERTY("version", version)
|
||||
#define MODULE_LICENSE(license) MODULE_PROPERTY("license", license)
|
||||
|
||||
#define MODULE_ENTRY(func) \
|
||||
[[__used]] \
|
||||
errno_t __module_entry(struct module* __module) { \
|
||||
return func(__module); \
|
||||
} \
|
||||
MODULE_PROPERTY("author", author); \
|
||||
MODULE_PROPERTY("desc", desc); \
|
||||
MODULE_PROPERTY("version", version); \
|
||||
MODULE_PROPERTY("license", license);
|
||||
[[__used, __section(".mod.entry")]] \
|
||||
static const void* __entry_fn = &__module_entry
|
||||
|
||||
#define MODULE_EXIT(func) \
|
||||
[[__used]] \
|
||||
errno_t __module_exit(struct module* __module) { \
|
||||
return func(__module); \
|
||||
} \
|
||||
[[__used, __section(".mod.exit")]] \
|
||||
static const void* __exit_fn = &__module_exit
|
||||
|
||||
struct module {
|
||||
const char* name;
|
||||
struct module* owner;
|
||||
};
|
||||
|
||||
#define THIS_MODULE (struct module*)nullptr
|
||||
|
||||
void module_init();
|
||||
|
||||
@@ -36,6 +36,7 @@ errno_t pmap_unmap(struct pmap* pt, uintptr_t vaddr);
|
||||
void pmap_set(struct pmap* pt);
|
||||
|
||||
void pte_clear(pte_t* pte);
|
||||
void pte_flush(uintptr_t vaddr);
|
||||
pte_t pte_build(phys_t addr, enum pte_flags flags, enum cache_mode cache);
|
||||
bool pte_is_present(pte_t* pte);
|
||||
bool pte_is_dir(pte_t* pte);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <zinnia/errno.h>
|
||||
#include <zinnia/init.h>
|
||||
#include <zinnia/stack.h>
|
||||
#include <zinnia/tailq.h>
|
||||
#include <zinnia/types.h>
|
||||
#include <bits/sched.h>
|
||||
@@ -29,7 +30,7 @@ struct task {
|
||||
enum task_state state;
|
||||
struct arch_task_context context;
|
||||
struct usercopy_region* usercopy_region;
|
||||
uintptr_t kernel_stack;
|
||||
struct stack kernel_stack;
|
||||
uintptr_t user_stack;
|
||||
size_t time_slice;
|
||||
int8_t priority;
|
||||
@@ -48,8 +49,9 @@ struct scheduler {
|
||||
typedef void (*task_fn_t)(uintptr_t arg0);
|
||||
|
||||
errno_t task_create(const char* name, struct vma* space, task_fn_t entry, uintptr_t arg0, struct task** out);
|
||||
void task_destroy(struct task* task);
|
||||
[[noreturn]]
|
||||
void task_entry(task_fn_t entry, uintptr_t arg0);
|
||||
void task_entry(task_fn_t entry, uintptr_t arg0, struct task* prev);
|
||||
|
||||
void sched_init(struct scheduler* sched);
|
||||
void sched_reschedule(struct scheduler* sched);
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include <zinnia/errno.h>
|
||||
#include <zinnia/types.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
struct stack {
|
||||
uintptr_t base;
|
||||
phys_t phys;
|
||||
size_t size;
|
||||
};
|
||||
|
||||
errno_t stack_init(struct stack* ks, size_t size);
|
||||
void stack_destroy(struct stack* ks);
|
||||
|
||||
static inline uintptr_t kernel_stack_top(struct stack* ks) {
|
||||
return ks->base + ks->size;
|
||||
}
|
||||
@@ -2,8 +2,8 @@
|
||||
#define SYSCALL_DECLARE(number, name, num_args) extern void sys_##name(...);
|
||||
#endif
|
||||
|
||||
// SYSCALL_DECLARE(0, exit, -1)
|
||||
// SYSCALL_DECLARE(1, syslog, -1)
|
||||
SYSCALL_DECLARE(0, exit, 1)
|
||||
SYSCALL_DECLARE(1, syslog, 3)
|
||||
SYSCALL_DECLARE(2, getuname, 1)
|
||||
SYSCALL_DECLARE(3, setuname, 1)
|
||||
SYSCALL_DECLARE(4, archctl, 2)
|
||||
|
||||
Reference in New Issue
Block a user