Initial commit

This commit is contained in:
Bahadir Balban
2008-01-13 13:53:52 +00:00
commit e2b791a3d8
789 changed files with 95825 additions and 0 deletions

View File

@@ -0,0 +1,107 @@
/*
* Mock-up memory layout definitions for test purposes.
*
* Copyright (C) 2007 Bahadir Balban
*
*/
#ifndef __BASICLAYOUT_H__
#define __BASICLAYOUT_H__
#ifndef __ASSEMBLY__
#include INC_GLUE(memory.h)
#endif
#include INC_PLAT(offsets.h)
#define RESERVED_AREA_START 0x0
#define RESERVED_AREA_END 0x00400000
#define RESERVED_AREA_SIZE (RESERVED_AREA_END - RESERVED_AREA_START)
#define RESERVED_AREA_SECTIONS (RESERVED_AREA_SIZE / ARM_SECTION_SIZE)
/* 0x00400000 */
#define USER_AREA_START 0x00400000
#define USER_AREA_END 0xF0000000
#define USER_AREA_SIZE (USER_AREA_END - USER_AREA_START)
#define USER_AREA_SECTIONS (USER_AREA_SIZE / ARM_SECTION_SIZE)
/* 0xf0000000 */
#define KERNEL_AREA_START 0xF0000000
#define KERNEL_AREA_END 0xF4000000
#define KERNEL_AREA_SIZE (KERNEL_AREA_END - KERNEL_AREA_START)
#define KERNEL_AREA_SECTIONS (KERNEL_AREA_SIZE / ARM_SECTION_SIZE)
/* Kernel offset is taken as virtual memory base */
#define VIRT_ADDR_BASE KERNEL_AREA_START
/* 0xf4000000 */
#define UNCACHE_AREA_START 0xF4000000
#define UNCACHE_AREA_END 0xF8000000
#define UNCACHE_AREA_SIZE (UNCACHE_AREA_END - UNCACHE_AREA_START)
#define UNCACHE_AREA_SECTIONS (UNCACHE_AREA_SIZE / ARM_SECTION_SIZE)
/* The page tables are the main clients of uncached virtual memory */
#define PGTABLE_ADDR_BASE UNCACHE_AREA_START
/* 0xf8000000 */
#define VAR_AREA_START 0xF8000000
#define VAR_AREA_END 0xF9000000
#define VAR_AREA_SIZE (VAR_AREA_END - VAR_AREA_START)
#define VAR_AREA_SECTIONS (VAR_AREA_SIZE / ARM_SECTION_SIZE)
/* 0xf9000000 */
#define IO_AREA_START 0xF9000000
#define IO_AREA_END 0xFF000000
#define IO_AREA_SIZE (IO_AREA_END - IO_AREA_START)
#define IO_AREA_SECTIONS (IO_AREA_SIZE / ARM_SECTION_SIZE)
/* 0xff000000 */
#define MISC_AREA_START 0xFF000000
#define MISC_AREA_END 0xFFF00000
#define MISC_AREA_SIZE (MISC_AREA_END - MISC_AREA_START)
#define MISC_AREA_SECTIONS (MISC_AREA_SIZE / ARM_SECTION_SIZE)
/* First page in MISC area is used for KIP/UTCB reference page */
#define USER_KIP_PAGE MISC_AREA_START
/* 0xfff00000 */
#define EXCPT_AREA_START 0xFFF00000
#define EXCPT_AREA_END (EXCPT_AREA_START + ARM_SECTION_SIZE)
#define EXCPT_AREA_SIZE (EXCPT_AREA_END - EXCPT_AREA_START)
/* 1MB IO Areas in the Virtual Address space. Define more if needed */
#define IO_AREA0_VADDR (IO_AREA_START + (ARM_SECTION_SIZE*0))
#define IO_AREA1_VADDR (IO_AREA_START + (ARM_SECTION_SIZE*1))
#define IO_AREA2_VADDR (IO_AREA_START + (ARM_SECTION_SIZE*2))
#define IO_AREA3_VADDR (IO_AREA_START + (ARM_SECTION_SIZE*3))
#define IO_AREA4_VADDR (IO_AREA_START + (ARM_SECTION_SIZE*4))
#define IO_AREA5_VADDR (IO_AREA_START + (ARM_SECTION_SIZE*5))
#define IO_AREA6_VADDR (IO_AREA_START + (ARM_SECTION_SIZE*6))
#define IO_AREA7_VADDR (IO_AREA_START + (ARM_SECTION_SIZE*7))
/*
* Address of start of arm_high_vector - exception handling code
*/
#define ARM_HIGH_VECTOR_VADDR (EXCPT_AREA_START | 0x000f0000 )
#define ARM_SYSCALL_VECTOR (0xffffff00)
/*
* These offsets depend on where the platform defines its physical memory
* and how the system defines the virtual memory regions in arm/basiclayout.h
*/
//#define KERNEL_OFFSET (VIRT_ADDR_BASE - PHYS_ADDR_BASE)
//#define PGTABLE_OFFSET (PGTABLE_ADDR_BASE - PGTABLE_PHYS_ADDR_BASE)
/* Use a more predictible offset by just changing the top nibble */
#define KERNEL_OFFSET VIRT_ADDR_BASE
#define PGTABLE_OFFSET PGTABLE_ADDR_BASE
/*
* Convenience macros for converting between address types.
*/
#if defined(__KERNEL__)
#define phys_to_virt(addr) ((unsigned int)addr)
#define phys_to_ptab(addr) ((unsigned int)addr)
#define virt_to_phys(addr) ((unsigned int)addr)
#define virt_to_ptab(addr) (phys_to_ptab(virt_to_phys(addr)))
#endif
#endif /* __BASICLAYOUT_H__ */

View File

@@ -0,0 +1,84 @@
/*
* Memory related definitions for test purposes.
*
* Copyright (C) 2007 Bahadir Balban
*
*/
#ifndef __GLUE_TEST_MEMORY_H__
#define __GLUE_TEST_MEMORY_H__
/* ARM specific definitions */
#define TEST_SECTION_SIZE SZ_1MB
//#define TEST_PAGE_SIZE SZ_4K
//#define TEST_PAGE_MASK 0xFFF
//#define TEST_PAGE_BITS 12
#define TEST_PAGE_SIZE 128
#define TEST_PAGE_MASK (TEST_PAGE_SIZE-1)
#define TEST_PAGE_BITS 7
#define TEST_SECTION_MASK 0xFFFFF
/* Aligns to the upper page (ceiling) */
#define page_align_up(addr) ((((unsigned int)(addr)) + \
(PAGE_SIZE - 1)) & \
(~PAGE_MASK))
/* Aligns to the lower page (floor) */
#define page_align(addr) (((unsigned int)(addr)) & \
(~PAGE_MASK))
/* Align to given size */
#define align(addr, size) (((unsigned int)(addr)) & (~(size-1)))
/* Extract page frame number from address */
#define __pfn(x) (((unsigned long)(x)) >> PAGE_BITS)
#define __pfn_to_addr(x) (((unsigned long)(x)) << PAGE_BITS)
/* Extract physical address from page table entry (pte) */
#define __pte_to_addr(x) (((unsigned long)(x)) & ~PAGE_MASK)
/* Minimum excess needed for word alignment */
#define SZ_WORD sizeof(unsigned long)
#define WORD_BITS 32
#define BITWISE_GETWORD(x) ((x) >> 5) /* Divide by 32 */
#define BITWISE_GETBIT(x) (1 << ((x) % WORD_BITS))
#define align_up(addr, size) ((((unsigned long)(addr)) + ((size) - 1)) & (~((size) - 1)))
/* Generic definitions */
extern unsigned int PAGE_SIZE;
extern unsigned int PAGE_MASK;
extern unsigned int PAGE_BITS;
/* Type-checkable page table elements */
typedef u32 pgd_t;
typedef u32 pmd_t;
typedef u32 pte_t;
/* Page global directory made up of pgd_t entries */
typedef struct pgd_table {
pgd_t entry[SZ_4K];
} pgd_table_t;
/* Page middle directory made up of pmd_t entries */
typedef struct pmd_table {
pmd_t entry[256];
} pmd_table_t;
/* Number of pmd tables to describe all physical memory.
* TODO: Need more for IO etc. */
#define NUM_PMD_TABLES ((PHYS_MEM_END - PHYS_MEM_START) / PAGE_SIZE) \
/ PMD_NUM_PAGES
/* Page table related */
extern pgd_table_t kspace;
extern pmd_table_t pmd_tables[];
extern unsigned long pmdtab_i;
void paging_init(void);
void init_clear_ptab(void);
#endif /* __GLUE_TEST_MEMORY_H__ */

View File

@@ -0,0 +1,19 @@
#ifndef __GLUE__V4_ARM__UTCB_H__
#define __GLUE__V4_ARM__UTCB_H__
/*
* Userspace thread control block
*
* Copyright (C) 2005 Bahadir Balban
*
*/
#include <macros.h>
#include <config.h>
#include <types.h>
struct utcb {
u32 global_id;
u32 error_code;
};
#endif /* !__GLUE__V4_ARM__UTCB_H__ */