add the SCC support of a initial ramdisk

This commit is contained in:
Stefan Lankes 2011-04-13 11:03:34 -07:00
parent 4da0a6e15e
commit eeb49cdb90
5 changed files with 50 additions and 15 deletions

View file

@ -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

View file

@ -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);

View file

@ -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 <metalsvm/stdio.h>
#include <metalsvm/errno.h>
@ -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

View file

@ -23,6 +23,7 @@
#include <metalsvm/fs.h>
#include <metalsvm/errno.h>
#include <asm/multiboot.h>
#include <asm/processor.h>
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; i<mods_count; i++) {
initrd_header_t* header = (initrd_header_t*) mmodule[i].mod_start;
#elif defined(CONFIG_ROCKCREEK)
for(i=0; i<1; i++) {
initrd_header_t* header = (initrd_header_t*) bootinfo->addr;
#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

View file

@ -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; i<mb_info->mods_count; i++, mmodule++) {
for(addr=mmodule->mod_start; addr<mmodule->mod_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