source: trunk/kernel/arch/ibmpc/arch_init.c @ 126

Last change on this file since 126 was 11, checked in by alain, 8 years ago

Merge all FS related files in one single vfs directory.

File size: 2.5 KB
RevLine 
[1]1/*
2 * arch_init.c - architecture intialization operations (see kern/hal-arch.h)
3 *
4 * Copyright (c) 2008,2009,2010,2011,2012 Ghassan Almaless
5 * Copyright (c) 2011,2012 UPMC Sorbonne Universites
6 *
7 * This file is part of ALMOS-kernel.
8 *
9 * ALMOS-kernel is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 2.0 of the License.
12 *
13 * ALMOS-kernel is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with ALMOS-kernel; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23#include <config.h>
24#include <types.h>
25#include <hardware.h>
26#include <cpu.h>
[11]27#include <chdev.h>
[1]28#include <driver.h>
29#include <list.h>
30#include <pic.h>
31#include <tty.h>
32#include <scheduler.h>
33#include <kdmsg.h>
34#include <devfs.h>
35#include <cluster.h>
36#include <rt_timer.h>
37#include <pci-bus.h>
38#include <kmem.h>
39#include <ata.h>
40
41/* TODO: dynamicly calculate this value on each icu bind operation */
42#define ICU_MASK     0x3  // interrupt enabled for frist 2 devices
43
44struct device_s __sys_dma;
45struct device_s __fb_screen;
46struct device_s __sys_blk;
47struct device_s rt_timer;
48
49static void ioCluster_init(struct cluster_s *cluster, uint_t id)
50{
51        struct device_s *pic;
52        int i;
53
54        /* First of all: Initialize TTYs */
55        ibmpc_tty_init(&ttys_tbl[0], __tty_addr, 1, 0);   // IRQ 0 is taken by Timer 0
56
57        boot_dmsg("\nSetup Terminal \t\t\t\tOK\n");
58   
59        cluster_init(cluster, id, __CPU_NR);
60
61        boot_dmsg("Setup PIC      ");
62        pic = kbootMem_calloc(sizeof(*pic));
63        ibmpc_pic_init(pic, __pic_addr, 0);
64        ibmpc_pic_bind(pic, &ttys_tbl[0]);
65        devfs_register(&ttys_tbl[0]);
66
67        for(i=0; i < __CPU_NR; i++)
68                arch_cpu_set_irq_entry(&cluster->cpu_tbl[i], 0, &pic->action);
69
70        boot_dmsg("\t\t\t\tOK\nSetup Timer    ");
71        rt_timer_init(TIC, 1);
72        ibmpc_pic_bind(pic, &rt_timer);
73
74        boot_dmsg("\t\t\t\tOK\nSetup H.D.D    ");
75        ibmpc_ata_init(&__sys_blk, (void*)ATA0_DRIVE0, 14);
76        ibmpc_pic_bind(pic, &__sys_blk);
77
78        boot_dmsg("\t\t\t\tOK\nActivating IRQs");
79        pic->op.icu.set_mask(pic, ICU_MASK, 0, 0);
80        boot_dmsg("\t\t\t\tOK\n");
81}
82
83
84error_t arch_init(void)
85{
86        kdmsg_init();
87        ioCluster_init(&clusters_tbl[IO_CLUSTER_ID], IO_CLUSTER_ID);
88
89        return 0;
90}
Note: See TracBrowser for help on using the repository browser.