big commit

This commit is contained in:
Taku Shimosawa
2011-11-28 13:00:13 +09:00
parent ea0e1327c8
commit 480e1b12ef
21 changed files with 1866 additions and 89 deletions

View File

@@ -1,5 +1,8 @@
#ifndef __HEADER_CLS_H
#define __HEADER_CLS_H
#include <process.h>
#include <syscall.h>
/*
* CPU Local Storage (cls)
*/
@@ -12,7 +15,16 @@ struct malloc_header {
struct cpu_local_var {
/* malloc */
struct malloc_header free_list;
/* Align to 64-byte */
struct process idle;
struct process *current;
struct process *next;
struct aal_ikc_channel_desc *syscall_channel;
struct syscall_params scp;
struct ikc_scd_init_param iip;
} __attribute__((aligned(64)));

52
kernel/include/process.h Normal file
View File

@@ -0,0 +1,52 @@
#ifndef HEADER_PROCESS_H
#define HEADER_PROCESS_H
#include <aal/context.h>
#include <aal/cpu.h>
#include <aal/mm.h>
#include <list.h>
#define VR_STACK 1
struct vm_range {
struct list_head list;
unsigned long start, end;
unsigned long phys;
unsigned long flag;
};
struct vm_regions {
unsigned long text_start, text_end;
unsigned long data_start, data_end;
unsigned long brk_start, brk_end;
unsigned long map_start, map_end;
unsigned long stack_start, stack_end;
};
struct process {
int pid;
int status;
struct page_table *page_table;
struct list_head vm_range_list;
struct vm_regions region;
aal_mc_kernel_context_t ctx;
aal_mc_user_context_t *uctx;
};
struct process *create_process(unsigned long user_pc);
int add_process_memory_range(struct process *process,
unsigned long start, unsigned long end,
unsigned long phys, unsigned long flag);
int remove_process_region(struct process *proc,
unsigned long start, unsigned long end);
void init_process_stack(struct process *process);
unsigned long extend_process_region(struct process *proc,
unsigned long start, unsigned long end,
unsigned long address);
void schedule(void);
#endif

65
kernel/include/syscall.h Normal file
View File

@@ -0,0 +1,65 @@
#ifndef __HEADER_SYSCALL_H
#define __HEADER_SYSCALL_H
#define NUM_SYSCALLS 255
#define SCD_MSG_PREPARE_PROCESS 0x1
#define SCD_MSG_PREPARE_PROCESS_ACKED 0x2
#define SCD_MSG_SCHEDULE_PROCESS 0x3
#define SCD_MSG_INIT_CHANNEL 0x5
#define SCD_MSG_INIT_CHANNEL_ACKED 0x6
#define SCD_MSG_SYSCALL_ONESIDE 0x4
struct ikc_scd_packet {
int msg;
int ref;
unsigned long arg;
};
struct program_image_section {
unsigned long vaddr;
unsigned long len;
unsigned long remote_pa;
unsigned long filesz, offset;
void *source;
};
struct program_load_desc {
int num_sections;
int status;
int cpu;
int pid;
unsigned long entry;
unsigned long rprocess;
struct program_image_section sections[0];
};
struct ikc_scd_init_param {
unsigned long request_page;
unsigned long response_page;
unsigned long doorbell_page;
};
struct syscall_request {
unsigned long number;
unsigned long args[5];
};
struct syscall_response {
unsigned long status;
long ret;
};
struct syscall_params {
unsigned long request_rpa, request_pa;
struct syscall_request *request_va;
unsigned long response_pa;
struct syscall_response *response_va;
unsigned long doorbell_rpa, doorbell_pa;
unsigned long *doorbell_va;
};
#endif