diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index d8e3d698..a6ed0c13 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -32,6 +32,15 @@ extern "C" { #endif #ifdef CONFIG_ROCKCREEK +typedef struct { + uint32_t addr; // address of the initrd + uint32_t size; // size of the initrd + int32_t argc; // number of RCCE arguments + char** argv; // RCCE arguments +} bootinfo_t; + +extern bootinfo_t* bootinfo; + int scc_init(void); #endif diff --git a/arch/x86/mm/page.c b/arch/x86/mm/page.c index b8c37884..8f8ab109 100644 --- a/arch/x86/mm/page.c +++ b/arch/x86/mm/page.c @@ -698,6 +698,12 @@ int arch_paging_init(void) // map SCC's bootinfo map_region(SCC_BOOTINFO, SCC_BOOTINFO, 1, MAP_KERNEL_SPACE); + // map the initial ramdisk + npages = bootinfo->size / PAGE_SIZE; + if (bootinfo->size % PAGE_SIZE) + npages++; + map_region(bootinfo->addr, bootinfo->addr, npages, MAP_KERNEL_SPACE); + // map SCC's configuration registers viraddr = map_region(CRB_X0_Y0, CRB_X0_Y0, (CRB_OWN-CRB_X0_Y0+16*1024*1024)/PAGE_SIZE, MAP_KERNEL_SPACE|MAP_NO_CACHE); kprintf("Map configuration registers at 0x%x\n", viraddr); diff --git a/arch/x86/scc/scc_init.c b/arch/x86/scc/scc_init.c index 1f7d0c5a..3279c967 100644 --- a/arch/x86/scc/scc_init.c +++ b/arch/x86/scc/scc_init.c @@ -10,12 +10,7 @@ * * 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. - */ + * WITHOUT WARRANTIES OR COND */ #include #include @@ -27,14 +22,7 @@ #ifdef CONFIG_ROCKCREEK -typedef struct { - uint32_t addr; // address of the initrd - uint32_t size; // size of the initrd - int32_t argc; // number of RCCE arguments - char** argv; // RCCE arguments -} bootinfo_t; - -static bootinfo_t* bootinfo = (bootinfo_t*) SCC_BOOTINFO; +bootinfo_t* bootinfo = (bootinfo_t*) SCC_BOOTINFO; /* PSE bit for Pentium+ equals MPE (message buffer enable) flag in RCK! So, use it to create _PAGE_MPB symbol... */ #define _CR4_MPE 0x00000800 diff --git a/fs/initrd.c b/fs/initrd.c index b836d79e..c3094b44 100644 --- a/fs/initrd.c +++ b/fs/initrd.c @@ -23,6 +23,7 @@ #include #include #include +#include static vfs_node_t initrd_root; @@ -213,8 +214,10 @@ int initrd_init(void) { dir_block_t* dir_block; vfs_node_t* tmp; -#ifdef CONFIG_MULTIBOOT +#if defined(CONFIG_ROCKCREEK) || defined(CONFIG_MULTIBOOT) uint32_t i, j, k, l; +#endif +#ifdef CONFIG_MULTIBOOT uint32_t mods_count = 0; multiboot_module_t* mmodule = NULL; @@ -256,6 +259,10 @@ int initrd_init(void) #ifdef CONFIG_MULTIBOOT for(i=0; iaddr; +#endif initrd_file_desc_t* file_desc; vfs_node_t* new_node; @@ -328,6 +335,7 @@ int initrd_init(void) next_file: file_desc++; } +#if defined(CONFIG_ROCKCREEK) || defined(CONFIG_MULTIBOOT) } #endif diff --git a/mm/memory.c b/mm/memory.c index d920aed3..cf7f5e48 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -126,6 +126,13 @@ int mmu_init(void) if (mb_info && (mb_info->flags & MULTIBOOT_INFO_MODS)) { multiboot_module_t* mmodule = (multiboot_module_t*) mb_info->mods_addr; + /* + * Mark the mb_info as used. + */ + page_set_mark((size_t)mb_info / PAGE_SIZE); + atomic_int32_inc(&total_allocated_pages); + atomic_int32_dec(&total_available_pages); + for(i=0; imods_count; i++, mmodule++) { for(addr=mmodule->mod_start; addrmod_end; addr+=PAGE_SIZE) { page_set_mark(addr / PAGE_SIZE); @@ -150,6 +157,23 @@ int mmu_init(void) atomic_int32_inc(&total_pages); atomic_int32_inc(&total_available_pages); } + + /* + * Mark the bootinfo as used. + */ + page_set_mark((size_t)bootinfo / PAGE_SIZE); + atomic_int32_inc(&total_allocated_pages); + atomic_int32_dec(&total_available_pages); + + /* + * The init ram disk are already loaded. + * Therefore, we set these pages as used. + */ + for(addr=bootinfo->addr; addr < bootinfo->addr+bootinfo->size; addr+=PAGE_SIZE) { + page_set_mark(addr / PAGE_SIZE); + atomic_int32_inc(&total_allocated_pages); + atomic_int32_dec(&total_available_pages); + } #else #error Currently, MetalSVM supports only the Multiboot specification or the RockCreek processor! #endif