mirror of
https://github.com/drasko/codezero.git
synced 2026-02-05 22:43:15 +01:00
Kernel updates since December 2009
This commit is contained in:
26
include/l4/glue/arm/cache.h
Normal file
26
include/l4/glue/arm/cache.h
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Generic cache api calls
|
||||
*
|
||||
* Copyright (C) 2010 B Labs Ltd.
|
||||
*
|
||||
* Author: Bahadir Balban
|
||||
*/
|
||||
#ifndef __GLUE_CACHE_H__
|
||||
#define __GLUE_CACHE_H__
|
||||
|
||||
#include INC_SUBARCH(mmu_ops.h)
|
||||
|
||||
/* Lowest byte is reserved for and used by capability permissions */
|
||||
#define ARCH_INVALIDATE_ICACHE 0x10
|
||||
#define ARCH_INVALIDATE_DCACHE 0x20
|
||||
#define ARCH_CLEAN_DCACHE 0x30
|
||||
#define ARCH_CLEAN_INVALIDATE_DCACHE 0x40
|
||||
#define ARCH_INVALIDATE_TLB 0x50
|
||||
|
||||
void arch_invalidate_dcache(unsigned long start, unsigned long end);
|
||||
void arch_clean_invalidate_dcache(unsigned long start, unsigned long end);
|
||||
void arch_invalidate_icache(unsigned long start, unsigned long end);
|
||||
void arch_invalidate_tlb(unsigned long start, unsigned long end);
|
||||
void arch_clean_dcache(unsigned long start, unsigned long end);
|
||||
|
||||
#endif /* __GLUE_CACHE_H__ */
|
||||
51
include/l4/glue/arm/debug.h
Normal file
51
include/l4/glue/arm/debug.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* ARM-specific syscall type accounting.
|
||||
*
|
||||
* Copyright (C) 2010 B Labs Ltd.
|
||||
*
|
||||
* Author: Bahadir Balban
|
||||
*/
|
||||
|
||||
#ifndef __ARM_DEBUG_H__
|
||||
#define __ARM_DEBUG_H__
|
||||
|
||||
#include INC_SUBARCH(perfmon.h)
|
||||
|
||||
#if defined (CONFIG_DEBUG_ACCOUNTING)
|
||||
|
||||
extern struct system_accounting system_accounting;
|
||||
|
||||
static inline void
|
||||
system_account_syscall_type(unsigned long swi_address)
|
||||
{
|
||||
*(((u64 *)&system_accounting.syscalls) +
|
||||
((swi_address & 0xFF) >> 2)) += 1;
|
||||
}
|
||||
|
||||
#else /* End of CONFIG_DEBUG_ACCOUNTING */
|
||||
|
||||
static inline void system_account_syscall_type(unsigned long swi_address) { }
|
||||
|
||||
#endif /* End of !CONFIG_DEBUG_ACCOUNTING */
|
||||
|
||||
|
||||
#if defined (CONFIG_DEBUG_PERFMON_KERNEL)
|
||||
|
||||
static inline void
|
||||
system_measure_syscall_start(void)
|
||||
{
|
||||
/* To avoid non-voluntary rescheduling during call */
|
||||
perfmon_reset_start_cyccnt();
|
||||
}
|
||||
|
||||
/* Defined in arm/glue/debug.c */
|
||||
void system_measure_syscall_end(unsigned long swi_address);
|
||||
|
||||
#else /* End of CONFIG_DEBUG_PERFMON_KERNEL */
|
||||
|
||||
static inline void system_measure_syscall_start(void) { }
|
||||
static inline void system_measure_syscall_end(unsigned long swi_address) { }
|
||||
|
||||
#endif /* End of !CONFIG_DEBUG_PERFMON_KERNEL */
|
||||
|
||||
#endif /* __ARM_DEBUG_H__ */
|
||||
@@ -1,3 +1,8 @@
|
||||
/*
|
||||
* Copyright (C) 2010 B Labs Ltd.
|
||||
* Author: Prem Mallappa <prem.mallappa@b-labs.co.uk>
|
||||
*/
|
||||
|
||||
#ifndef __ARM_GLUE_INIT_H__
|
||||
#define __ARM_GLUE_INIT_H__
|
||||
|
||||
@@ -8,5 +13,14 @@ void switch_to_user(struct ktcb *inittask);
|
||||
void timer_start(void);
|
||||
|
||||
extern struct address_space init_space;
|
||||
void init_kernel_mappings(void);
|
||||
void start_virtual_memory(void);
|
||||
void finalize_virtual_memory(void);
|
||||
void init_finalize(void);
|
||||
|
||||
void remove_section_mapping(unsigned long vaddr);
|
||||
|
||||
void vectors_init(void);
|
||||
void setup_idle_caps(void);
|
||||
void setup_idle_task(void);
|
||||
#endif /* __ARM_GLUE_INIT_H__ */
|
||||
|
||||
18
include/l4/glue/arm/ipi.h
Normal file
18
include/l4/glue/arm/ipi.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef __IPI_H__
|
||||
#define __IPI_H__
|
||||
|
||||
/*
|
||||
* Copyright 2010 B Labs.Ltd.
|
||||
*
|
||||
* Author: Prem Mallappa <prem.mallappa@b-labs.co.uk>
|
||||
*
|
||||
* Description:
|
||||
*/
|
||||
|
||||
|
||||
#include <l4/generic/irq.h>
|
||||
|
||||
int ipi_handler(struct irq_desc *desc);
|
||||
|
||||
|
||||
#endif /* __IPI_H__ */
|
||||
89
include/l4/glue/arm/mapping.h
Normal file
89
include/l4/glue/arm/mapping.h
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Generic mapping operations
|
||||
*
|
||||
* Operations on address space mappings that
|
||||
* all subarchitectures support generically.
|
||||
*
|
||||
* Copyright (C) 2008 - 2010 B Labs Ltd.
|
||||
* Written by Bahadir Balban
|
||||
*/
|
||||
|
||||
#ifndef __ARM_GLUE_MAPPING_H__
|
||||
#define __ARM_GLUE_MAPPING_H__
|
||||
|
||||
#include INC_SUBARCH(mm.h)
|
||||
|
||||
#define TASK_PGD(x) (x)->space->pgd
|
||||
|
||||
unsigned int space_flags_to_ptflags(unsigned int flags);
|
||||
|
||||
void add_mapping_pgd(unsigned long paddr, unsigned long vaddr,
|
||||
unsigned int size, unsigned int flags,
|
||||
pgd_table_t *pgd);
|
||||
|
||||
void add_mapping(unsigned long paddr, unsigned long vaddr,
|
||||
unsigned int size, unsigned int flags);
|
||||
|
||||
void add_boot_mapping(unsigned long paddr, unsigned long vaddr,
|
||||
unsigned int size, unsigned int flags);
|
||||
|
||||
int remove_mapping(unsigned long vaddr);
|
||||
int remove_mapping_pgd(pgd_table_t *pgd, unsigned long vaddr);
|
||||
void remove_mapping_pgd_all_user(pgd_table_t *pgd);
|
||||
|
||||
int check_mapping_pgd(unsigned long vaddr, unsigned long size,
|
||||
unsigned int flags, pgd_table_t *pgd);
|
||||
|
||||
int check_mapping(unsigned long vaddr, unsigned long size,
|
||||
unsigned int flags);
|
||||
|
||||
void copy_pgd_kern_all(pgd_table_t *);
|
||||
|
||||
struct address_space;
|
||||
int delete_page_tables(struct address_space *space);
|
||||
int copy_user_tables(struct address_space *new, struct address_space *orig);
|
||||
void remap_as_pages(void *vstart, void *vend);
|
||||
|
||||
void copy_pgds_by_vrange(pgd_table_t *to, pgd_table_t *from,
|
||||
unsigned long start, unsigned long end);
|
||||
|
||||
/*
|
||||
* TODO: Some of these may be made inline by
|
||||
* removing their signature from here completely
|
||||
* and creating an arch-specific mapping.h which
|
||||
* has inline definitions or just signatures.
|
||||
*/
|
||||
|
||||
pte_t virt_to_pte(unsigned long vaddr);
|
||||
pte_t *virt_to_ptep(unsigned long vaddr);
|
||||
pte_t virt_to_pte_from_pgd(pgd_table_t *pgd, unsigned long vaddr);
|
||||
unsigned long virt_to_phys_by_pgd(pgd_table_t *pgd, unsigned long vaddr);
|
||||
|
||||
void arch_prepare_pte(u32 paddr, u32 vaddr, unsigned int flags,
|
||||
pte_t *ptep);
|
||||
|
||||
void arch_write_pte(pte_t *ptep, pte_t pte, u32 vaddr);
|
||||
|
||||
void arch_prepare_write_pte(u32 paddr, u32 vaddr,
|
||||
unsigned int flags, pte_t *ptep);
|
||||
|
||||
pmd_t *arch_pick_pmd(pgd_table_t *pgd, unsigned long vaddr);
|
||||
|
||||
void arch_write_pmd(pmd_t *pmd_entry, u32 pmd_phys, u32 vaddr);
|
||||
|
||||
int arch_check_pte_access_perms(pte_t pte, unsigned int flags);
|
||||
|
||||
pgd_table_t *arch_realloc_page_tables(void);
|
||||
|
||||
void arch_copy_pgd_kernel_entries(pgd_table_t *to);
|
||||
|
||||
int is_global_pgdi(int i);
|
||||
|
||||
struct ktcb;
|
||||
void arch_space_switch(struct ktcb *task);
|
||||
|
||||
int pgd_count_boot_pmds();
|
||||
|
||||
void idle_task(void);
|
||||
|
||||
#endif /* __ARM_GLUE_MAPPING_H__ */
|
||||
@@ -27,19 +27,24 @@
|
||||
/* ARM-specific offset in KIP that tells the address of UTCB page */
|
||||
#define UTCB_KIP_OFFSET 0x50
|
||||
|
||||
#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))
|
||||
#define IO_AREA0_VADDR IO_AREA_START
|
||||
#define IO_AREA1_VADDR (IO_AREA_START + (SZ_1MB*1))
|
||||
#define IO_AREA2_VADDR (IO_AREA_START + (SZ_1MB*2))
|
||||
#define IO_AREA3_VADDR (IO_AREA_START + (SZ_1MB*3))
|
||||
#define IO_AREA4_VADDR (IO_AREA_START + (SZ_1MB*4))
|
||||
#define IO_AREA5_VADDR (IO_AREA_START + (SZ_1MB*5))
|
||||
#define IO_AREA6_VADDR (IO_AREA_START + (SZ_1MB*6))
|
||||
#define IO_AREA7_VADDR (IO_AREA_START + (SZ_1MB*7))
|
||||
|
||||
/*
|
||||
* IO_AREA8_VADDR
|
||||
* The beginning page in this slot is used for userspace uart mapping
|
||||
*/
|
||||
|
||||
#define ARM_HIGH_VECTOR 0xFFFF0000
|
||||
#define ARM_SYSCALL_VECTOR 0xFFFFFF00
|
||||
|
||||
#define KERNEL_OFFSET (KERNEL_AREA_START - PHYS_MEM_START)
|
||||
#define KERNEL_OFFSET (KERNEL_AREA_START - PLATFORM_PHYS_MEM_START)
|
||||
|
||||
/* User tasks define them differently */
|
||||
#if defined (__KERNEL__)
|
||||
@@ -49,7 +54,7 @@
|
||||
|
||||
#define KERN_ADDR(x) ((x >= KERNEL_AREA_START) && (x < KERNEL_AREA_END))
|
||||
#define UTCB_ADDR(x) ((x >= UTCB_AREA_START) && (x < UTCB_AREA_END))
|
||||
#define PRIVILEGED_ADDR(x) (KERN_ADDR(x) || (x >= ARM_HIGH_VECTOR) || \
|
||||
#define is_kernel_address(x) (KERN_ADDR(x) || (x >= ARM_HIGH_VECTOR) || \
|
||||
(x >= IO_AREA_START && x < IO_AREA_END))
|
||||
|
||||
#endif /* __MEMLAYOUT_H__ */
|
||||
|
||||
@@ -11,35 +11,32 @@
|
||||
#include INC_SUBARCH(mm.h)
|
||||
|
||||
/* Generic definitions */
|
||||
#define PAGE_SIZE ARM_PAGE_SIZE
|
||||
#define PAGE_MASK ARM_PAGE_MASK
|
||||
#define PAGE_BITS ARM_PAGE_BITS
|
||||
|
||||
/*
|
||||
* This defines the largest size defined by this architecture that is
|
||||
* easily mappable. ARM supports 1MB mappings so it fits well. If it's
|
||||
* unsupported by the arch then a reasonable size could be 1MB.
|
||||
*/
|
||||
#define SECTION_SIZE ARM_SECTION_SIZE
|
||||
#define SECTION_MASK ARM_SECTION_MASK
|
||||
#define SECTION_BITS ARM_SECTION_BITS
|
||||
#define PFN_SHIFT 12
|
||||
#define PAGE_BITS PFN_SHIFT
|
||||
#define PAGE_SIZE SZ_4K
|
||||
#define PAGE_MASK (PAGE_SIZE - 1)
|
||||
|
||||
/* Aligns to the upper page (ceiling) FIXME: Must add a wraparound checker. */
|
||||
#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)) & \
|
||||
#define page_align_up(addr) ((((unsigned long)(addr)) + PAGE_MASK) & \
|
||||
(~PAGE_MASK))
|
||||
|
||||
#define is_aligned(val, size) (!(((unsigned long)(val)) & ((size) - 1)))
|
||||
/* Aligns to the lower page (floor) */
|
||||
#define page_align(addr) (((unsigned long)(addr)) & \
|
||||
(~PAGE_MASK))
|
||||
|
||||
#define is_aligned(val, size) (!(((unsigned long)(val)) & (((unsigned long)size) - 1)))
|
||||
#define is_page_aligned(val) (!(((unsigned long)(val)) & PAGE_MASK))
|
||||
#define page_boundary(x) is_page_aligned(x)
|
||||
|
||||
/* Align to given size */
|
||||
#define align(addr, size) (((unsigned int)(addr)) & (~(size-1)))
|
||||
/*
|
||||
* Align to given size.
|
||||
*
|
||||
* Note it must be an alignable size i.e. one that is a power of two.
|
||||
* E.g. 0x1000 would work but 0x1010 would not.
|
||||
*/
|
||||
#define align(addr, size) (((unsigned int)(addr)) & (~((unsigned long)size-1)))
|
||||
#define align_up(addr, size) ((((unsigned long)(addr)) + \
|
||||
((size) - 1)) & (~((size) - 1)))
|
||||
((size) - 1)) & (~(((unsigned long)size) - 1)))
|
||||
|
||||
/* The bytes left until the end of the page that x is in */
|
||||
#define TILL_PAGE_ENDS(x) (PAGE_SIZE - ((unsigned long)(x) & PAGE_MASK))
|
||||
@@ -58,6 +55,8 @@
|
||||
#define BITWISE_GETWORD(x) ((x) >> WORD_BITS_LOG2) /* Divide by 32 */
|
||||
#define BITWISE_GETBIT(x) (1 << ((x) % WORD_BITS))
|
||||
|
||||
/* Minimum stack alignment restriction across functions, exceptions */
|
||||
#define STACK_ALIGNMENT 8
|
||||
|
||||
/* Endianness conversion */
|
||||
static inline void be32_to_cpu(unsigned int x)
|
||||
@@ -75,31 +74,6 @@ static inline void be32_to_cpu(unsigned int x)
|
||||
p[2] = tmp;
|
||||
}
|
||||
|
||||
void paging_init(void);
|
||||
|
||||
unsigned int space_flags_to_ptflags(unsigned int flags);
|
||||
|
||||
void add_mapping_pgd(unsigned int paddr, unsigned int vaddr,
|
||||
unsigned int size, unsigned int flags,
|
||||
pgd_table_t *pgd);
|
||||
void add_mapping(unsigned int paddr, unsigned int vaddr,
|
||||
unsigned int size, unsigned int flags);
|
||||
int remove_mapping(unsigned long vaddr);
|
||||
int remove_mapping_pgd(unsigned long vaddr, pgd_table_t *pgd);
|
||||
int remove_mapping_pgd_all_user(pgd_table_t *pgd);
|
||||
void prealloc_phys_pagedesc(void);
|
||||
|
||||
int check_mapping_pgd(unsigned long vaddr, unsigned long size,
|
||||
unsigned int flags, pgd_table_t *pgd);
|
||||
|
||||
int check_mapping(unsigned long vaddr, unsigned long size,
|
||||
unsigned int flags);
|
||||
|
||||
void copy_pgd_kern_all(pgd_table_t *);
|
||||
pte_t virt_to_pte(unsigned long virtual);
|
||||
pte_t virt_to_pte_from_pgd(unsigned long virtual, pgd_table_t *pgd);
|
||||
unsigned long virt_to_phys_by_pgd(unsigned long vaddr, pgd_table_t *pgd);
|
||||
|
||||
struct ktcb;
|
||||
void task_init_registers(struct ktcb *task, unsigned long pc);
|
||||
|
||||
|
||||
46
include/l4/glue/arm/smp.h
Normal file
46
include/l4/glue/arm/smp.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright 2010 B Labs Ltd.
|
||||
*
|
||||
* Authors: Prem Mallappa, Bahadir Balban
|
||||
*
|
||||
* SMP support
|
||||
*/
|
||||
#ifndef __GLUE_ARM_SMP_H__
|
||||
#define __GLUE_ARM_SMP_H__
|
||||
|
||||
#include INC_ARCH(scu.h)
|
||||
|
||||
struct cpuinfo {
|
||||
u32 ncpus;
|
||||
u32 flags;
|
||||
volatile u32 cpu_spinning;
|
||||
void (*send_ipi)(int cpu, int ipi_cmd);
|
||||
void (*smp_spin)(void);
|
||||
void (*smp_finish)(void);
|
||||
|
||||
} __attribute__ ((__packed__));
|
||||
|
||||
extern struct cpuinfo cpuinfo;
|
||||
|
||||
#if defined(CONFIG_SMP)
|
||||
|
||||
void smp_attach(void);
|
||||
void smp_start_cores(void);
|
||||
|
||||
#else
|
||||
static inline void smp_attach(void) {}
|
||||
static inline void smp_start_cores(void) {}
|
||||
#endif
|
||||
|
||||
void init_smp(void);
|
||||
void arch_smp_spin(void);
|
||||
void arch_send_ipi(u32 cpu, int ipi);
|
||||
void platform_smp_init(int ncpus);
|
||||
int platform_smp_start(int cpu, void (*start)(int));
|
||||
void secondary_init_platform(void);
|
||||
|
||||
extern unsigned long secondary_run_signal;
|
||||
|
||||
#define CPUID_TO_MASK(cpu) (1 << (cpu))
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user