Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2263 → Rev 2262

/branches/arm/kernel/arch/arm32/include/drivers/init.h
File deleted
/branches/arm/kernel/arch/arm32/include/drivers/gxemul.h
41,22 → 41,6
#define GXEMUL_IRQC_MAX_IRQ 8
#define GXEMUL_TIMER_FREQ 2
 
 
/** Struct containing mappings of gxemul HW devices into kernel part
* * of virtual address space. */
typedef struct {
uintptr_t videoram;
uintptr_t kbd;
uintptr_t rtc;
uintptr_t rtc_freq;
uintptr_t rtc_ack;
uintptr_t irqc;
uintptr_t irqc_mask;
uintptr_t irqc_unmask;
} gxemul_hw_map_t;
 
 
void gxemul_hw_map_init(void);
void gxemul_console(devno_t devno);
void gxemul_kbd_release(void);
void gxemul_kbd_grab(void);
68,7 → 52,6
void gxemul_timer_irq_init(void);
void gxemul_timer_start(uint32_t frequency);
 
size_t gxemul_get_memory_size(void);
 
 
/branches/arm/kernel/arch/arm32/include/mm/page.h
93,6 → 93,7
#define SET_FRAME_FLAGS_ARCH(ptl3, i, x) set_pt_level1_flags((pte_level1_t *)(ptl3), (index_t)(i), (x))
 
#define PTE_VALID_ARCH(pte) (*((uint32_t *) (pte)) != 0)
// TODO: ?? != 0
#define PTE_PRESENT_ARCH(pte) ( ((pte_level0_t *)(pte))->descriptor_type != 0 )
 
/* pte should point into ptl3 */
118,10 → 119,11
}
 
/** Returns level 0 page table entry flags.
/**
* Returns level 0 page table entry flags.
*
* \param pt level 0 page table
* \param i index of the entry to return
* \param pt level 0 page table
* \param i index of the entry to return
*/
static inline int get_pt_level0_flags(pte_level0_t *pt, index_t i)
{
137,10 → 139,11
;
}
 
/** Returns level 1 page table entry flags.
/**
* Returns level 1 page table entry flags.
*
* \param pt level 1 page table
* \param i index of the entry to return
* \param pt level 1 page table
* \param i index of the entry to return
*/
static inline int get_pt_level1_flags(pte_level1_t *pt, index_t i)
{
159,11 → 162,14
;
}
 
/** Sets flags of level 0 page table entry.
/**
* Sets flags of level 0 page table entry.
*
* \param pt level 0 page table
* \param i index of the entry to be changed
* \param flags new flags
* \param pt level 0 page table
* \param i index of the entry to be changed
* \param flags new flags
*
* TODO: why should_be_zero set to 1?
*/
static inline void set_pt_level0_flags(pte_level0_t *pt, index_t i, int flags)
{
171,8 → 177,10
 
if (flags & PAGE_NOT_PRESENT) {
p->descriptor_type = PTE_DESCRIPTOR_NOT_PRESENT;
// ensures that the entry will be recognized as valid when PTE_VALID_ARCH applied
p->should_be_zero = 1;
// TODO: remove in final version
// For Michal: Have to be here ... ensures this entry contains at least 1 non zero bit
// all zero bits signals PTE_VALID_ARCH , it's different from not_present
} else {
p->descriptor_type = PTE_DESCRIPTOR_COARSE_TABLE;
p->should_be_zero = 0;
179,15 → 187,16
}
}
 
/** Sets flags of level 1 page table entry.
/**
* Sets flags of level 1 page table entry.
*
* We use same access rights for the whole page. When page is not preset we
* store 1 in acess_rigts_3 so that at least one bit is 1 (to mark correct
* page entry, see #PAGE_VALID_ARCH).
* We use same access rights for the whole page. When page is not preset then
* store 1 in acess_rigts_3.
* TODO: why access_right_3?
*
* \param pt level 1 page table
* \param i index of the entry to be changed
* \param flags new flags
* \param pt level 1 page table
* \param i index of the entry to be changed
* \param flags new flags
*/
static inline void set_pt_level1_flags(pte_level1_t *pt, index_t i, int flags)
{
/branches/arm/kernel/arch/arm32/src/exception.c
148,7 → 148,6
*/
static void irq_exception(int exc_no, istate_t* istate)
{
#if MACHINE == MACHINE_GXEMUL_TESTARM
uint32_t sources = gxemul_irqc_get_sources();
int i = 0;
for (; i < GXEMUL_IRQC_MAX_IRQ; i++) {
164,7 → 163,6
}
}
}
#endif
/* TODO remove after testing the above code
noirq = 0;
if (i == CONSOLE_IRQ) {
/branches/arm/kernel/arch/arm32/src/drivers/init.c
File deleted
/branches/arm/kernel/arch/arm32/src/drivers/gxemul.c
1,5 → 1,5
/*
* Copyright (c) 2007 Michal Kebrt, Petr Stepan
* Copyright (c) 2005-2007 Ondrej Palkovsky, Michal Kebrt, Petr Stepan
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
40,26 → 40,21
#include <sysinfo/sysinfo.h>
#include <print.h>
#include <ddi/device.h>
#include <mm/page.h>
 
/** Address of devices. */
#define GXEMUL_VIDEORAM 0x10000000
#define GXEMUL_KBD 0x10000000
#define GXEMUL_RTC 0x15000000
#define GXEMUL_RTC_FREQ_OFFSET 0x100
#define GXEMUL_RTC_ACK_OFFSET 0x110
#define GXEMUL_IRQC 0x16000000
#define GXEMUL_IRQC_MASK_OFFSET 0x4
#define GXEMUL_IRQC_UNMASK_OFFSET 0x8
#define GXEMUL_MP 0x11000000
#define GXEMUL_MP_MEMSIZE_OFFSET 0x0090
#define GXEMUL_VIDEORAM 0x10000000
#define GXEMUL_KBD_ADDRESS 0x10000000
#define GXEMUL_RTC 0x15000000
#define GXEMUL_RTC_FREQ 0x15000100
#define GXEMUL_RTC_ACK 0x15000110
#define GXEMUL_IRQC 0x16000000
#define GXEMUL_IRQC_MASK 0x16000004
#define GXEMUL_IRQC_UNMASK 0x16000008
 
 
/** IRQs */
#define GXEMUL_KBD_IRQ 2
#define GXEMUL_TIMER_IRQ 4
 
static gxemul_hw_map_t gxemul_hw_map;
static chardev_t console;
static irq_t gxemul_irq;
static irq_t gxemul_timer_irq;
76,25 → 71,10
.read = gxemul_do_read,
};
 
 
/** Initializes #gxemul_hw_map. */
void gxemul_hw_map_init(void)
{
gxemul_hw_map.videoram = hw_map(GXEMUL_VIDEORAM, PAGE_SIZE);
gxemul_hw_map.kbd = hw_map(GXEMUL_KBD, PAGE_SIZE);
gxemul_hw_map.rtc = hw_map(GXEMUL_RTC, PAGE_SIZE);
gxemul_hw_map.irqc = hw_map(GXEMUL_IRQC, PAGE_SIZE);
 
gxemul_hw_map.rtc_freq = gxemul_hw_map.rtc + GXEMUL_RTC_FREQ_OFFSET;
gxemul_hw_map.rtc_ack = gxemul_hw_map.rtc + GXEMUL_RTC_ACK_OFFSET;
gxemul_hw_map.irqc_mask = gxemul_hw_map.irqc + GXEMUL_IRQC_MASK_OFFSET;
gxemul_hw_map.irqc_unmask = gxemul_hw_map.irqc + GXEMUL_IRQC_UNMASK_OFFSET;
}
 
/** Putchar that works with gxemul */
void gxemul_write(chardev_t *dev, const char ch)
{
*((char *) gxemul_hw_map.videoram) = ch;
*((char *) GXEMUL_VIDEORAM) = ch;
}
 
/* Called from getc(). */
117,7 → 97,7
char ch;
 
while (1) {
ch = *((volatile char *) gxemul_hw_map.kbd);
ch = *((volatile char *) GXEMUL_KBD_ADDRESS);
if (ch) {
if (ch == '\r')
return '\n';
136,7 → 116,7
else {
char ch = 0;
ch = *((char *) gxemul_hw_map.kbd);
ch = *((char *) GXEMUL_KBD_ADDRESS);
if (ch =='\r')
ch = '\n';
if (ch == 0x7f)
154,7 → 134,7
void gxemul_kbd_grab(void)
{
ipl_t ipl = interrupts_disable();
spinlock_lock(&gxemul_irq.lock);
spinlock_lock(&msim_irq.lock);
gxemul_irq.notif_cfg.notify = false;
spinlock_unlock(&gxemul_irq.lock);
interrupts_restore(ipl);
171,10 → 151,10
}
 
 
/** Return console object representing gxemul console */
/** Return console object representing msim console */
void gxemul_console(devno_t devno)
{
chardev_initialize("gxemul_console", &console, &gxemul_ops);
chardev_initialize("msim_console", &console, &gxemul_ops);
stdin = &console;
stdout = &console;
191,13 → 171,13
sysinfo_set_item_val("kbd", NULL, true);
sysinfo_set_item_val("kbd.devno", NULL, devno);
sysinfo_set_item_val("kbd.inr", NULL, GXEMUL_KBD_IRQ);
sysinfo_set_item_val("kbd.address.virtual", NULL, gxemul_hw_map.kbd);
sysinfo_set_item_val("kbd.address.virtual", NULL, GXEMUL_KBD_ADDRESS);
}
 
/** Return the mask of active interrupts. */
inline uint32_t gxemul_irqc_get_sources(void)
{
return *(uint32_t*) gxemul_hw_map.irqc;
return *(uint32_t*) GXEMUL_IRQC;
}
 
/** Masks interrupt.
206,7 → 186,7
*/
inline void gxemul_irqc_mask(uint32_t irq)
{
*(uint32_t*) gxemul_hw_map.irqc_mask = irq;
*(uint32_t*) GXEMUL_IRQC_MASK = irq;
}
 
/** Unmasks interrupt.
215,7 → 195,7
*/
inline void gxemul_irqc_unmask(uint32_t irq)
{
*(uint32_t*) gxemul_hw_map.irqc_unmask = irq;
*(uint32_t*) GXEMUL_IRQC_UNMASK = irq;
}
 
 
225,7 → 205,7
*/
void gxemul_timer_start(uint32_t frequency)
{
*(uint32_t*) gxemul_hw_map.rtc_freq = frequency;
*(uint32_t*) GXEMUL_RTC_FREQ = frequency;
}
 
static irq_ownership_t gxemul_timer_claim(void)
257,7 → 237,7
spinlock_lock(&irq->lock);
 
/* acknowledge tick */
*(uint32_t*) gxemul_hw_map.rtc_ack = 0;
*(uint32_t*) GXEMUL_RTC_ACK = 0;
/* TODO what's that? *
if (virtual_timer_fnc != NULL)
279,10 → 259,6
irq_register(&gxemul_timer_irq);
}
 
size_t gxemul_get_memory_size(void)
{
return *((int*)(GXEMUL_MP + GXEMUL_MP_MEMSIZE_OFFSET));
}
 
/** @}
*/
/branches/arm/kernel/arch/arm32/src/mm/page.c
115,14 → 115,19
 
// TODO: move to the kernel space
page_mapping_insert(AS_KERNEL, 0x00000000, 0x00000000, flags);
// TODO: remove when aux_printf not needed
page_mapping_insert(AS_KERNEL, 0x10000000, 0x10000000, flags);
page_mapping_insert(AS_KERNEL, 0x15000000, 0x15000000, flags);
page_mapping_insert(AS_KERNEL, 0x16000000, 0x16000000, flags);
 
exc_register(EXC_DATA_ABORT, "page_fault data abort", (iroutine) data_abourt);
exc_register(EXC_PREFETCH_ABORT, "page_fault prefetch abort", (iroutine) prefetch_abourt);
 
as_switch(NULL, AS_KERNEL);
exc_register(EXC_DATA_ABORT, "page_fault data abort", (iroutine) data_abourt);
exc_register(EXC_PREFETCH_ABORT, "page_fault prefetch abort", (iroutine) prefetch_abourt);
 
/* Sets mapping to kernel mapping. It's nessesary to hw_map changes take place immediately
* after hw_map function is called. */
as_switch( NULL, AS_KERNEL);
 
// note for Alf: kernel part of page table is copied in generic/mm/as_pt.c/ptl0_create
// TODO: register fault routine
}
 
/branches/arm/kernel/arch/arm32/src/mm/memory_init.c
34,12 → 34,15
 
#include <arch/mm/memory_init.h>
#include <arch/mm/page.h>
#include <arch/drivers/gxemul.h>
#include "../aux_print/printf.h"
 
#define GXEMUL_MP_ADDRESS 0x11000000
#define GXEMUL_MP_MEMSIZE_OFFSET 0x0090
size_t get_memory_size(void)
{
#if MACHINE == MACHINE_GXEMUL_TESTARM
return gxemul_get_memory_size();
//TODO preprocessor don't work
#if MACHINE == gxemul
return *((int*)(GXEMUL_MP_ADDRESS+GXEMUL_MP_MEMSIZE_OFFSET));
#endif
}
 
/branches/arm/kernel/arch/arm32/src/arm32.c
38,15 → 38,11
#include <config.h>
#include <arch/console.h>
#include <ddi/device.h>
#include <genarch/fb/fb.h>
#include <genarch/fb/visuals.h>
#include <ddi/irq.h>
 
#include "aux_print/printf.h"
#include <print.h>
#include <config.h>
#include <interrupt.h>
#include <arch/drivers/init.h>
 
bootinfo_t bootinfo;
 
57,9 → 53,12
 
init.cnt = bootinfo.cnt;
 
printf("Used memmory\n");
for (i = 0; i < bootinfo.cnt; ++i) {
init.tasks[i].addr = bootinfo.tasks[i].addr;
init.tasks[i].size = bootinfo.tasks[i].size;
 
// aux_printf("%L, %d\n", bootinfo.tasks[i].addr, bootinfo.tasks[i].size);
}
 
/* TODO this code just setups irq testing bed */
66,6 → 65,7
setup_exception_stacks();
}
 
#include <ddi/irq.h>
void arch_pre_mm_init(void)
{
aux_printf("arch_pre_mm_init\n");
75,21 → 75,20
/* Initialize dispatch table */
exception_init();
 
}
 
void arch_post_mm_init(void)
{
aux_printf("arch_post_mm_init start()\n");
drivers_init();
interrupt_init();
aux_printf("arch_post_mm_init\n");
interrupt_init(); // needs malloc ... so after mm init
console_init(device_assign_devno()); // need hash table of irq ... so after irq_init
console_init(device_assign_devno());
//fb_init(0x12000000, 640, 480, 1920, VISUAL_RGB_8_8_8);
/* TODO */
 
interrupts_enable();
// while(1);
aux_printf("machine:\n", MACHINE );
aux_printf("arch_post_mm_init end()\n");
while(1);
}
 
void arch_post_cpu_init(void)
/branches/arm/kernel/arch/arm32/src/interrupt.c
93,10 → 93,8
{
irq_init(IRQ_COUNT, IRQ_COUNT);
 
#if MACHINE == MACHINE_GXEMUL_TESTARM
gxemul_timer_irq_init();
gxemul_timer_start(GXEMUL_TIMER_FREQ);
#endif
}
 
 
/branches/arm/kernel/arch/arm32/src/console.c
38,9 → 38,7
 
void console_init(devno_t devno)
{
#if MACHINE == MACHINE_GXEMUL_TESTARM
gxemul_console(devno);
#endif
}
 
/** Acquire console back for kernel
48,9 → 46,7
*/
void arch_grab_console(void)
{
#if MACHINE == MACHINE_GXEMUL_TESTARM
gxemul_kbd_grab();
#endif
}
 
/** Return console to userspace
58,9 → 54,7
*/
void arch_release_console(void)
{
#if MACHINE == MACHINE_GXEMUL_TESTARM
gxemul_kbd_release();
#endif
}
 
/** @}
/branches/arm/kernel/arch/arm32/Makefile.inc
40,11 → 40,8
 
CFLAGS += -fno-zero-initialized-in-bss
 
MACHINE_gxemul_testarm = 1
DEFS += -D__32_BITS__ -DMACHINE=$(MACHINE) -DKERNEL_LOAD_ADDRESS=$(KERNEL_LOAD_ADDRESS)
 
DEFS += -D__32_BITS__ -DMACHINE=$(MACHINE_$(MACHINE)) -DKERNEL_LOAD_ADDRESS=$(KERNEL_LOAD_ADDRESS) \
-DMACHINE_GXEMUL_TESTARM=$(MACHINE_gxemul_testarm)
 
CONFIG_GXEMUL = y
DEFS += -DCONFIG_GXEMUL
 
85,7 → 82,6
arch/$(ARCH)/src/aux_print/io.c \
arch/$(ARCH)/src/console.c \
arch/$(ARCH)/src/drivers/gxemul.c \
arch/$(ARCH)/src/drivers/init.c \
arch/$(ARCH)/src/exception.c \
arch/$(ARCH)/src/mm/memory_init.c
/branches/arm/kernel/kernel.config
30,7 → 30,7
! [ARCH=amd64] MACHINE (choice)
 
# Machine type
@ "gxemul_testarm" GXEmul testarm
@ "gxemul" GXEmul
! [ARCH=arm32] MACHINE (choice)
 
# Machine type