|
||||||
Prex Home > Document Index > Architecture Dependent Interface | ||||||
Prex Architecture Dependent InterfaceVersion 1.0.2, 2007/12/23 Table of ContentsIntroductionThe interface for the architecture dependent layer is defined to abstract a processor and minimum hardware in the Prex kernel. If you want to port the Prex kernel to new architecture or new platform, you have to modify the architecture dependent codes properly for your target system. Some functions are optional on the specific target. For example, you don't have to implement the MMU support code if your target system does not have a MMU. The interface described here is used only by the kernel code. And, it is not defined to provide hardware abstraction for device drivers. So, it is different from the layer generally called as HAL (Hardware Abstraction Layer). General InformationData TypesThe following data types are defined by the architecture dependent layer.
ContextA context includes processor registers and additional per-thread information. context_t represents the pointer to the context structure of each architecture/platform. The kernel treats the pointer as a context ID and it does not touch the internal data of the context structure. void context_init(context_t ctx, u_long kstack); void context_set(context_t ctx, int type, void *val); void context_switch(context_t prev, context_t next); void context_save(context_t ctx, int exc); void context_restore(context_t ctx, void *regs);
InterruptThe kernel abstracts whole interrupt related hardware. The architecture dependent interface provides only primitive routines to handle the interrupt. void interrupt_enable(void); void interrupt_disable(void); void interrupt_save(int *sts); void interrupt_restore(int sts); void interrupt_mask(int vector); void interrupt_unmask(int vector, int level); void interrupt_setup(int vector, int mode);
MMUThe architecture dependent code must provide the functions for Memory Management Unit (MMU). Even if the system does not support MMU, mmu_init() and mmu_switch() must be defined as NULL macro. void mmu_init(void); int mmu_map(pgd_t pgd, void *phys, void *virt, size_t size, int type); pgd_t mmu_newmap(void); void mmu_delmap(pgd_t pgd); void mmu_switch(pgd_t pgd); void *mmu_extract(pgd_t pgd, void *virt, size_t size);
ClockThe Prex kernel requires a clock timer hardware for all systems.void clock_init(void);
User MemorySince accessing to the user memory may cause a page fault, the manipulation of the user buffer is handled by each architecture codes. The following functions should detect the page fault and return an error if it can. int umem_copyin(void *uaddr, void *kaddr, size_t len); int umem_copyout(void *kaddr, void *uaddr, size_t len); int umem_strnlen(const char *uaddr, size_t maxlen, size_t *len);
Diagnosticvoid diag_init(void); void diag_print(char *buf);
Machinevoid machine_init(void); void machine_idle(void); void machine_reset(void);
Memory Locationint kern_area(void *addr); int user_area(void *addr); void *phys_to_virt(void *p_addr); void *virt_to_phys(void *v_addr);
|
||||||
Copyright© 2005-2007 Kohsuke Ohtani |