From 2a6664f01a7d0a7d931fed0e77aa2052ec0631fe Mon Sep 17 00:00:00 2001 From: stefan Date: Tue, 10 Aug 2010 15:20:27 +0000 Subject: [PATCH] - first steps to intialize the a Rock Creek system git-svn-id: http://svn.lfbs.rwth-aachen.de/svn/scc/trunk/MetalSVM@59 315a16e6-25f9-4109-90ae-ca3045a26c18 --- arch/x86/include/asm/processor.h | 6 +++++ arch/x86/include/asm/rck.h | 45 ++++++++++++++++++++++++++++++++ arch/x86/kernel/Makefile | 2 +- arch/x86/kernel/rck.c | 44 +++++++++++++++++++++++++++++++ mm/memory.c | 17 ++++++++++-- 5 files changed, 111 insertions(+), 3 deletions(-) create mode 100644 arch/x86/include/asm/rck.h create mode 100644 arch/x86/kernel/rck.c diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index b9fc2c4d..0fa3b2b9 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -24,6 +24,9 @@ #ifdef CONFIG_PCI #include #endif +#ifdef CONFIG_ROCKCREEK +#include +#endif #ifdef __cplusplus extern "C" { @@ -47,6 +50,9 @@ void gdt_install(void); inline static int system_init(void) { +#ifdef CONFIG_ROCKCREEK + rck_init(); +#endif gdt_install(); #ifdef CONFIG_PCI pci_init(); diff --git a/arch/x86/include/asm/rck.h b/arch/x86/include/asm/rck.h new file mode 100644 index 00000000..a5b91d14 --- /dev/null +++ b/arch/x86/include/asm/rck.h @@ -0,0 +1,45 @@ +/* + * Copyright 2010 Stefan Lankes, Chair for Operating Systems, + * RWTH Aachen University + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of MetalSVM. + */ +#ifndef __ARCH_RCK_H__ +#define __ARCH_RCK_H__ + +#include + +#ifdef CONFIG_ROCKCREEK + +#define RCK_TILEID_CONFIG 0x0100 +#define RCK_GCU_CONFIG 0x0080 + +#define RCK_TILEID_SUBID(id) (id|0x07) +#define RCK_TILEID_X(id) ((id >> 3) | 0x0F) +#define RCK_TILEID_Y(id) ((id >> 7) | 0x0F) + +typedef struct { + uint32_t tile_id; + uint32_t pmem_low; + uint32_t pmem_high; +} rck_info_t; + +extern rck_info_t rck_info; + +int rck_init(void); + +#endif + +#endif diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile index f88b86a6..658b4476 100644 --- a/arch/x86/kernel/Makefile +++ b/arch/x86/kernel/Makefile @@ -1,4 +1,4 @@ -C_source = syscall.c gdt.c kb.c timer.c irq.c isrs.c idt.c vga.c multiboot.c pci.c +C_source = rck.c syscall.c gdt.c kb.c timer.c irq.c isrs.c idt.c vga.c multiboot.c pci.c ASM_source = entry.asm OBJS += $(patsubst %.c, %.o, $(filter %.c, $(C_source))) diff --git a/arch/x86/kernel/rck.c b/arch/x86/kernel/rck.c new file mode 100644 index 00000000..1a8b6a4e --- /dev/null +++ b/arch/x86/kernel/rck.c @@ -0,0 +1,44 @@ +/* + * Copyright 2010 Stefan Lankes, Chair for Operating Systems, + * RWTH Aachen University + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of MetalSVM. + */ + +#include +#include +#include + +#ifdef CONFIG_ROCKCREEK + +rck_info_t rck_info; + +int rck_init(void) +{ + kprintf("Initialize Rock Creek!\n"); + + rck_info.tile_id = inportl(RCK_TILEID_CONFIG); + kprintf("Core is running on %x (%2d, %2d)\n", rck_info.tile_id, RCK_TILEID_X(rck_info.tile_id), + RCK_TILEID_Y(rck_info.tile_id), RCK_TILEID_SUBID(rck_info.tile_id)); + + /* default values for 16 GB of System Memory */ + rck_info.pmem_low = 0x00; + rck_info.pmem_high = 0x13FFFFFF; + while(1); + + return 0; +} + +#endif diff --git a/mm/memory.c b/mm/memory.c index 31f0d567..7168e8e9 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -25,6 +25,9 @@ #ifdef CONFIG_MULTIBOOT #include #endif +#ifdef CONFIG_ROCKCREEK +#include +#endif /* * 0 => free @@ -79,6 +82,7 @@ int mmu_init(void) { size_t kernel_size; unsigned int i; + size_t addr; /* set whole address space as occupied */ memset(bitmap, 0xFF, sizeof(uint8_t)*BITMAP_SIZE); @@ -91,8 +95,8 @@ int mmu_init(void) while (mmap < mmap_end) { if (mmap->type == MULTIBOOT_MEMORY_AVAILABLE) { /* set the available memory as "unused" */ - size_t addr = mmap->addr; size_t end_addr = addr + mmap->len; + addr = mmap->addr; while (addr < end_addr) { page_clear_mark(addr / PAGE_SIZE); @@ -107,8 +111,17 @@ int mmu_init(void) kputs("Unable to initialize the memory management subsystem\n"); while(1) ; } +#elif defined(CONFIG_ROCKCREEK) + addr = rck_info.pmem_low; + + while(addr < rck_info.pmem_high) { + page_clear_mark(addr / PAGE_SIZE); + addr += PAGE_SIZE; + atomic_int32_inc(&total_pages); + atomic_int32_inc(&total_available_pages); + } #else - #error Currently, MetalSVM needs multiboot! + #error Currently, MetalSVM supports only Multiboot or the RockCreek processor! #endif /* kernel is aligned to page size */