hos/kernel/proc/proc.h

92 lines
1.7 KiB
C

// proc.h
// Author: Josh Holtrop
// Date; 08/18/05
// Modified: 08/18/05
#ifndef __HOS_PROC_H__
#define __HOS_PROC_H__ __HOS_PROC_H__
#ifdef _HOS_CPP_
extern "C" {
#endif
#include "hos_defines.h"
#include "kernel.h"
#define PROC_MIN_USER_PID 1024
typedef struct
{
u32_t *page_dir; /* Page directory with physical PT addys */
u32_t *v_page_dir; /* Virtual page table addresses for init */
u32_t p_page_dir; /* Physical address of page directory */
u32_t size; /* Process size, bytes from 0 through bss */
u32_t uid; /* Process owner */
int_stack_t int_stack;
} process_t;
typedef struct
{
u16_t backlink;
u16_t reserved0;
u32_t esp0;
u16_t ss0;
u16_t _ss0;
u32_t esp1;
u16_t ss1;
u16_t _ss1;
u32_t esp2;
u16_t ss2;
u16_t _ss2;
u32_t pdbr;
u32_t eip;
u32_t eflags;
u32_t eax;
u32_t ecx;
u32_t edx;
u32_t ebx;
u32_t esp;
u32_t ebp;
u32_t esi;
u32_t edi;
u16_t es;
u16_t _es;
u16_t cs;
u16_t _cs;
u16_t ss;
u16_t _ss;
u16_t ds;
u16_t _ds;
u16_t fs;
u16_t _fs;
u16_t gs;
u16_t _gs;
u16_t ldt;
u16_t _ldt;
u16_t trap;
u16_t iomap;
} __attribute__((packed)) tss_t;
int proc_init();
process_t *proc_get_struct(u32_t pid);
void proc_sched(int_stack_t *int_stack);
u32_t get_pid();
void switch_task(int_stack_t *int_stack, u32_t new_task);
u32_t create_task(void *base, u32_t image_size, u32_t bss_size, void *entry);
process_t *create_process(void *base, u32_t image_size, u32_t bss_size, void *entry);
void create_address_space(process_t *p);
void create_process_stack(process_t *p, void *entry);
void copy_into_address_space(u32_t dest_addr,
char *src_addr,
u32_t pages,
process_t *p);
void zero_address_space(u32_t dest_addr, u32_t pages, process_t *p);
#ifdef _HOS_CPP_
}
#endif
#endif