Working on reorganizing kernel.c
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
nobase_include_HEADERS = types/status.h types/syscallid.h types/physaddr.h \
|
||||
types/syscallarg.h sys/syscalls.h types/pid.h types/oid.h \
|
||||
types/sigaction.h
|
||||
types/sigaction.h types/message.h
|
||||
@@ -11,6 +11,10 @@ typedef struct address_space_t
|
||||
|
||||
address_space_t *address_space_construct();
|
||||
|
||||
void address_space_switch(address_space_t *address_space);
|
||||
|
||||
address_space_t *address_space_release(address_space_t *address_space);
|
||||
|
||||
void address_space_destroy(address_space_t *address_space);
|
||||
|
||||
#endif
|
||||
@@ -6,6 +6,8 @@
|
||||
#include "mmgr.h"
|
||||
#include "syscalls.h"
|
||||
#include "addressspace.h"
|
||||
#include "process.h"
|
||||
#include "types/message.h"
|
||||
#include "types/syscallid.h"
|
||||
#include "types/status.h"
|
||||
#include "types/pid.h"
|
||||
@@ -45,15 +47,12 @@ struct boot_info_t
|
||||
struct module_t modules[MODULE_LIMIT];
|
||||
};
|
||||
|
||||
struct message_t
|
||||
{
|
||||
pid_t sender;
|
||||
unsigned long code;
|
||||
unsigned long args[6];
|
||||
};
|
||||
|
||||
void kernel_initialize(struct boot_info_t *boot_info);
|
||||
|
||||
process_t *kernel_get_process(pid_t pid);
|
||||
|
||||
process_t *kernel_get_active_process();
|
||||
|
||||
error_t kernel_set_syscall(int id, int arg_count, void *func_ptr);
|
||||
|
||||
size_t kernel_do_syscall(syscall_id_t id, syscall_arg_t arg1, syscall_arg_t arg2, syscall_arg_t arg3, void *pc, void *stack, unsigned long flags);
|
||||
@@ -70,6 +69,8 @@ pid_t kernel_spawn_process(void *program_entry, int priority, address_space_t *a
|
||||
|
||||
struct process_context_t *kernel_advance_scheduler();
|
||||
|
||||
void kernel_schedule_process(process_t *process);
|
||||
|
||||
error_t kernel_terminate_process(pid_t process_id);
|
||||
|
||||
error_t kernel_create_port(unsigned long id);
|
||||
@@ -78,10 +79,6 @@ error_t kernel_remove_port(unsigned long id);
|
||||
|
||||
pid_t kernel_get_port_owner(unsigned long id);
|
||||
|
||||
error_t kernel_send_message(unsigned long recipient, struct message_t *message);
|
||||
|
||||
error_t kernel_queue_message(unsigned long recipient, struct message_t *message);
|
||||
|
||||
int kernel_receive_message(struct message_t *buffer, int flags);
|
||||
|
||||
error_t kernel_register_interrupt_handler(unsigned long interrupt, signal_handler_t handler, void *userdata);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "sharedobject.h"
|
||||
#include "platform/paging.h"
|
||||
#include "types/physaddr.h"
|
||||
#include "types/status.h"
|
||||
@@ -102,6 +103,15 @@ physaddr_t current_address_space();
|
||||
*/
|
||||
error_t map_region(void *page, physaddr_t frame, size_t size, int flags);
|
||||
|
||||
/**
|
||||
* @brief Maps a shared object into virtual memory.
|
||||
*
|
||||
* @param location
|
||||
* @param object
|
||||
* @return
|
||||
*/
|
||||
error_t map_object(void *location, shared_object_t *object);
|
||||
|
||||
/**
|
||||
* @brief Unmaps a region in virtual memory. All pages which contain some part
|
||||
* of the region specified will be unmapped.
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
#ifndef QUARK_PROCESS_H
|
||||
#define QUARK_PROCESS_H
|
||||
|
||||
#include "types/message.h"
|
||||
#include "types/pid.h"
|
||||
#include "types/physaddr.h"
|
||||
#include "types/status.h"
|
||||
#include "queue.h"
|
||||
#include "addressspace.h"
|
||||
#include "sharedobject.h"
|
||||
|
||||
typedef enum process_state_t
|
||||
{
|
||||
@@ -21,7 +23,6 @@ typedef struct process_t
|
||||
address_space_t *address_space;
|
||||
struct avltree_t *shared_objects;
|
||||
process_state_t state;
|
||||
struct queue_t sending_queue;
|
||||
struct queue_t message_queue;
|
||||
struct message_t *message_buffer;
|
||||
struct process_context_t *ctx;
|
||||
@@ -29,4 +30,10 @@ typedef struct process_t
|
||||
|
||||
process_t *process_construct(pid_t pid, void *entry, void *stack, int priority, address_space_t *address_space);
|
||||
|
||||
error_t process_queue_message(process_t *process, message_t *msg);
|
||||
|
||||
error_t process_store_object(process_t *process, int id, void *location);
|
||||
|
||||
void *process_get_object(process_t *process, int id);
|
||||
|
||||
#endif
|
||||
@@ -4,14 +4,13 @@
|
||||
#include "types/physaddr.h"
|
||||
#include <stddef.h>
|
||||
|
||||
struct shared_object_t
|
||||
typedef struct shared_object_t
|
||||
{
|
||||
physaddr_t phys_addr;
|
||||
size_t size;
|
||||
unsigned long access_flags;
|
||||
unsigned long refcount;
|
||||
struct avltree_t *users;
|
||||
};
|
||||
} shared_object_t;
|
||||
|
||||
struct shared_object *create_shared_object(size_t size, unsigned long flags);
|
||||
|
||||
|
||||
@@ -42,9 +42,9 @@ static inline int map_anon(void *addr, size_t length, long flags)
|
||||
* @param length
|
||||
* @return
|
||||
*/
|
||||
static inline int unmap_anon(void *addr, size_t length)
|
||||
static inline int unmap_anon(void *addr)
|
||||
{
|
||||
return _do_syscall(SYSCALL_UNMAP_ANON, addr, length);
|
||||
return _do_syscall(SYSCALL_UNMAP_ANON, addr);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,7 +22,6 @@ struct syscall_t
|
||||
{
|
||||
bool defined;
|
||||
int arg_count;
|
||||
int process_id;
|
||||
union
|
||||
{
|
||||
syscall_ptr_0_t func_ptr_0;
|
||||
@@ -47,7 +46,7 @@ int syscall_map_anon(syscall_arg_t location, syscall_arg_t length, syscall_arg_t
|
||||
/**
|
||||
*
|
||||
*/
|
||||
int syscall_unmap_anon(syscall_arg_t location, syscall_arg_t length);
|
||||
int syscall_unmap_anon(syscall_arg_t location);
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
13
include/types/message.h
Normal file
13
include/types/message.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef QUARK_MESSAGE_H
|
||||
#define QUARK_MESSAGE_H
|
||||
|
||||
#include <types/pid.h>
|
||||
|
||||
typedef struct message_t
|
||||
{
|
||||
pid_t sender;
|
||||
unsigned long code;
|
||||
unsigned long args[6];
|
||||
} message_t;
|
||||
|
||||
#endif
|
||||
10
include/types/signalid.h
Normal file
10
include/types/signalid.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef QUARK_SIGNALID_H
|
||||
#define QUARK_SIGNALID_H
|
||||
|
||||
typedef enum signalid_t
|
||||
{
|
||||
SIG_KILL = 1,
|
||||
SIG_STOP
|
||||
} signalid_t;
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user