
- now, we could map file in subdirectories git-svn-id: http://svn.lfbs.rwth-aachen.de/svn/scc/trunk/MetalSVM@119 315a16e6-25f9-4109-90ae-ca3045a26c18
182 lines
4.4 KiB
C
182 lines
4.4 KiB
C
/*
|
|
* 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 <metalsvm/stddef.h>
|
|
#include <metalsvm/stdio.h>
|
|
#include <metalsvm/string.h>
|
|
#include <metalsvm/time.h>
|
|
#include <metalsvm/mmu.h>
|
|
#include <metalsvm/tasks.h>
|
|
#include <metalsvm/processor.h>
|
|
#include <metalsvm/fs.h>
|
|
#include <asm/irq.h>
|
|
#include <asm/irqflags.h>
|
|
#include <asm/kb.h>
|
|
#ifdef CONFIG_PCI
|
|
#include <asm/pci.h>
|
|
#endif
|
|
#ifdef CONFIG_LWIP
|
|
#include <lwip/sys.h>
|
|
#include <lwip/stats.h>
|
|
#include <lwip/udp.h>
|
|
#include <lwip/tcp.h>
|
|
#include <lwip/dhcp.h>
|
|
#include <lwip/netif.h>
|
|
#include <netif/etharp.h>
|
|
#endif
|
|
#ifdef CONFIG_ROCKCREEK
|
|
#include <asm/scc.h>
|
|
#endif
|
|
|
|
extern int test_init(void);
|
|
extern const void kernel_start;
|
|
extern const void kernel_end;
|
|
|
|
static void list_fs(vfs_node_t* node, uint32_t depth)
|
|
{
|
|
int j, i = 0;
|
|
dirent_t* dirent = NULL;
|
|
|
|
while ((dirent = readdir_fs(node, i)) != 0) {
|
|
for(j=0; j<depth; j++)
|
|
kputs(" ");
|
|
kprintf("%s\n", dirent->name);
|
|
|
|
if (strcmp(dirent->name, ".") && strcmp(dirent->name, "..")) {
|
|
vfs_node_t *new_node = finddir_fs(node, dirent->name);
|
|
if (new_node) {
|
|
if (new_node->type == FS_FILE) {
|
|
char buff[16] = {[0 ... 15] = 0x00};
|
|
|
|
read_fs(new_node, (uint8_t*)buff, 8, 0);
|
|
for(j=0; j<depth+1; j++)
|
|
kputs(" ");
|
|
kprintf("content: %s\n", buff);
|
|
} else list_fs(new_node, depth+1);
|
|
}
|
|
}
|
|
|
|
i++;
|
|
}
|
|
}
|
|
|
|
static void list_root(void) {
|
|
kprintf("List of the file system:\n/\n");
|
|
list_fs(fs_root, 1);
|
|
}
|
|
|
|
#if defined(CONFIG_LWIP) && defined(CONFIG_ROCKCREEK)
|
|
err_t sccpcif_init(struct netif* netif);
|
|
|
|
int STDCALL scc_pc_task(void* arg)
|
|
{
|
|
struct netif netif;
|
|
struct ip_addr ipaddr;
|
|
struct ip_addr netmask;
|
|
struct ip_addr gw;
|
|
|
|
sleep(10);
|
|
kputs("LWIP task is started\n");
|
|
|
|
/* Set network address variables */
|
|
IP4_ADDR(&gw, 192,168,1,254);
|
|
IP4_ADDR(&ipaddr, 192,168,1,scc_info.pid+1);
|
|
IP4_ADDR(&netmask, 255,255,255,0);
|
|
|
|
stats_init(); /* Clears the structure where runtime statistics are gathered */
|
|
sys_init();
|
|
mem_init(); /* Initializes the dynamic memory heap defined by MEM_SIZE. */
|
|
memp_init(); /* Initializes the memory pools defined by MEMP_NUM_x */
|
|
pbuf_init(); /* Initializes the pbuf memory pool defined by PBUF_POOL_SIZE. */
|
|
etharp_init(); /* Initializes the ARP table and queue. */
|
|
ip_init();
|
|
udp_init(); /* Clears the UDP PCB list */
|
|
tcp_init(); /* Clears the TCP PCB list and clears some internal TCP timers. */
|
|
|
|
/* Bring up the network interface */
|
|
if (!netif_add(&netif, &ipaddr, &netmask, &gw, NULL, sccpcif_init, ip_input)) {
|
|
kputs("Unable to add network interface\n");
|
|
return -1;
|
|
}
|
|
|
|
netif_set_default(&netif);
|
|
|
|
if (netif_is_up(&netif)) {
|
|
kputs("Network interface is not up\n");
|
|
return -1;
|
|
}
|
|
|
|
while(1) {
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
#endif
|
|
|
|
int main(void)
|
|
{
|
|
#ifdef CONFIG_LWIP
|
|
tid_t pc_id;
|
|
#endif
|
|
|
|
kprintf("Here is MetalSVM %s\n", METALSVM_VERSION);
|
|
|
|
system_init();
|
|
irq_init();
|
|
timer_init();
|
|
#ifdef CONFIG_KEYBOARD
|
|
keyboard_init();
|
|
#endif
|
|
mmu_init();
|
|
multitasking_init();
|
|
koutput_init();
|
|
initrd_init();
|
|
|
|
irq_enable();
|
|
|
|
kprintf("Kernel starts at %p and ends at %p\n", &kernel_start, &kernel_end);
|
|
|
|
detect_cpu_frequency();
|
|
kprintf("Processor frequency: %d MHz\n", get_cpu_frequency()/1000000);
|
|
kprintf("Total memory: %u MBytes\n", atomic_int32_read(&total_pages)/((1024*1024)/PAGE_SIZE));
|
|
kprintf("Current allocated memory: %u KBytes\n", atomic_int32_read(&total_allocated_pages)*(PAGE_SIZE/1024));
|
|
kprintf("Current available memory: %u MBytes\n", atomic_int32_read(&total_available_pages)/((1024*1024)/PAGE_SIZE));
|
|
#ifdef CONFIG_PCI
|
|
print_pci_adapters();
|
|
#endif
|
|
|
|
timer_set_frequency(TIMER_FREQ);
|
|
|
|
sleep(5);
|
|
list_root();
|
|
test_init();
|
|
|
|
#ifdef CONFIG_LWIP
|
|
create_kernel_task(&pc_id, scc_pc_task, NULL);
|
|
#endif
|
|
|
|
current_task->status = TASK_IDLE;
|
|
reschedule();
|
|
|
|
while(1) {
|
|
NOP8;
|
|
}
|
|
|
|
return 0;
|
|
}
|