/branches/arm/kernel/arch/arm32/src/exception.c |
---|
148,6 → 148,7 |
*/ |
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++) { |
163,6 → 164,7 |
} |
} |
} |
#endif |
/* TODO remove after testing the above code |
noirq = 0; |
if (i == CONSOLE_IRQ) { |
/branches/arm/kernel/arch/arm32/src/console.c |
---|
38,7 → 38,9 |
void console_init(devno_t devno) |
{ |
#if MACHINE == MACHINE_GXEMUL_TESTARM |
gxemul_console(devno); |
#endif |
} |
/** Acquire console back for kernel |
46,7 → 48,9 |
*/ |
void arch_grab_console(void) |
{ |
#if MACHINE == MACHINE_GXEMUL_TESTARM |
gxemul_kbd_grab(); |
#endif |
} |
/** Return console to userspace |
54,7 → 58,9 |
*/ |
void arch_release_console(void) |
{ |
#if MACHINE == MACHINE_GXEMUL_TESTARM |
gxemul_kbd_release(); |
#endif |
} |
/** @} |
/branches/arm/kernel/arch/arm32/src/arm32.c |
---|
38,11 → 38,15 |
#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; |
53,12 → 57,9 |
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 */ |
65,7 → 66,6 |
setup_exception_stacks(); |
} |
#include <ddi/irq.h> |
void arch_pre_mm_init(void) |
{ |
aux_printf("arch_pre_mm_init\n"); |
75,20 → 75,21 |
/* Initialize dispatch table */ |
exception_init(); |
} |
void arch_post_mm_init(void) |
{ |
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 |
aux_printf("arch_post_mm_init start()\n"); |
drivers_init(); |
interrupt_init(); |
/* TODO */ |
console_init(device_assign_devno()); |
//fb_init(0x12000000, 640, 480, 1920, VISUAL_RGB_8_8_8); |
interrupts_enable(); |
while(1); |
// while(1); |
aux_printf("machine:\n", MACHINE ); |
aux_printf("arch_post_mm_init end()\n"); |
} |
void arch_post_cpu_init(void) |
/branches/arm/kernel/arch/arm32/src/mm/memory_init.c |
---|
34,15 → 34,12 |
#include <arch/mm/memory_init.h> |
#include <arch/mm/page.h> |
#include "../aux_print/printf.h" |
#include <arch/drivers/gxemul.h> |
#define GXEMUL_MP_ADDRESS 0x11000000 |
#define GXEMUL_MP_MEMSIZE_OFFSET 0x0090 |
size_t get_memory_size(void) |
{ |
//TODO preprocessor don't work |
#if MACHINE == gxemul |
return *((int*)(GXEMUL_MP_ADDRESS+GXEMUL_MP_MEMSIZE_OFFSET)); |
#if MACHINE == MACHINE_GXEMUL_TESTARM |
return gxemul_get_memory_size(); |
#endif |
} |
/branches/arm/kernel/arch/arm32/src/mm/page.c |
---|
115,19 → 115,14 |
// 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); |
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); |
/* 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/interrupt.c |
---|
93,8 → 93,10 |
{ |
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/drivers/gxemul.c |
---|
1,5 → 1,5 |
/* |
* Copyright (c) 2005-2007 Ondrej Palkovsky, Michal Kebrt, Petr Stepan |
* Copyright (c) 2007 Michal Kebrt, Petr Stepan |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
40,21 → 40,26 |
#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_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 |
#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 |
/** 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; |
71,10 → 76,25 |
.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_VIDEORAM) = ch; |
*((char *) gxemul_hw_map.videoram) = ch; |
} |
/* Called from getc(). */ |
97,7 → 117,7 |
char ch; |
while (1) { |
ch = *((volatile char *) GXEMUL_KBD_ADDRESS); |
ch = *((volatile char *) gxemul_hw_map.kbd); |
if (ch) { |
if (ch == '\r') |
return '\n'; |
116,7 → 136,7 |
else { |
char ch = 0; |
ch = *((char *) GXEMUL_KBD_ADDRESS); |
ch = *((char *) gxemul_hw_map.kbd); |
if (ch =='\r') |
ch = '\n'; |
if (ch == 0x7f) |
134,7 → 154,7 |
void gxemul_kbd_grab(void) |
{ |
ipl_t ipl = interrupts_disable(); |
spinlock_lock(&msim_irq.lock); |
spinlock_lock(&gxemul_irq.lock); |
gxemul_irq.notif_cfg.notify = false; |
spinlock_unlock(&gxemul_irq.lock); |
interrupts_restore(ipl); |
151,10 → 171,10 |
} |
/** Return console object representing msim console */ |
/** Return console object representing gxemul console */ |
void gxemul_console(devno_t devno) |
{ |
chardev_initialize("msim_console", &console, &gxemul_ops); |
chardev_initialize("gxemul_console", &console, &gxemul_ops); |
stdin = &console; |
stdout = &console; |
171,13 → 191,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_KBD_ADDRESS); |
sysinfo_set_item_val("kbd.address.virtual", NULL, gxemul_hw_map.kbd); |
} |
/** Return the mask of active interrupts. */ |
inline uint32_t gxemul_irqc_get_sources(void) |
{ |
return *(uint32_t*) GXEMUL_IRQC; |
return *(uint32_t*) gxemul_hw_map.irqc; |
} |
/** Masks interrupt. |
186,7 → 206,7 |
*/ |
inline void gxemul_irqc_mask(uint32_t irq) |
{ |
*(uint32_t*) GXEMUL_IRQC_MASK = irq; |
*(uint32_t*) gxemul_hw_map.irqc_mask = irq; |
} |
/** Unmasks interrupt. |
195,7 → 215,7 |
*/ |
inline void gxemul_irqc_unmask(uint32_t irq) |
{ |
*(uint32_t*) GXEMUL_IRQC_UNMASK = irq; |
*(uint32_t*) gxemul_hw_map.irqc_unmask = irq; |
} |
205,7 → 225,7 |
*/ |
void gxemul_timer_start(uint32_t frequency) |
{ |
*(uint32_t*) GXEMUL_RTC_FREQ = frequency; |
*(uint32_t*) gxemul_hw_map.rtc_freq = frequency; |
} |
static irq_ownership_t gxemul_timer_claim(void) |
237,7 → 257,7 |
spinlock_lock(&irq->lock); |
/* acknowledge tick */ |
*(uint32_t*) GXEMUL_RTC_ACK = 0; |
*(uint32_t*) gxemul_hw_map.rtc_ack = 0; |
/* TODO what's that? * |
if (virtual_timer_fnc != NULL) |
259,6 → 279,10 |
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/drivers/init.c |
---|
0,0 → 1,46 |
/* |
* Copyright (c) 2007 Michal Kebrt |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup arm32 |
* @{ |
*/ |
/** @file |
*/ |
#include <arch/drivers/init.h> |
#include <arch/drivers/gxemul.h> |
void drivers_init(void) { |
#if MACHINE == MACHINE_GXEMUL_TESTARM |
gxemul_hw_map_init(); |
#endif |
} |
/** @} |
*/ |