Ignore:
Timestamp:
Dec 20, 2009, 3:02:02 PM (10 years ago)
Author:
Jean-Yves Lamoureux
Message:
  • Fix indentation and add licensing and copyright headers to kernel
Location:
libcaca/trunk/kernel/boot
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/kernel/boot/gdt.c

    r4154 r4158  
    1 /*
     1/*
     2 *  libcaca       
     3 *  libcaca       Colour ASCII-Art library
     4 *  Copyright (c) 2006 Sam Hocevar <sam@hocevar.net>
     5 *                2009 Jean-Yves Lamoureux <jylam@lnxscene.org>
     6 *                All Rights Reserved
     7 *
     8 *  $Id: kernel.h 4154 2009-12-20 13:33:11Z jylam $
     9 *
     10 *  This library is free software. It comes without any warranty, to
     11 *  the extent permitted by applicable law. You can redistribute it
     12 *  and/or modify it under the terms of the Do What The Fuck You Want
     13 *  To Public License, Version 2, as published by Sam Hocevar. See
     14 *  http://sam.zoy.org/wtfpl/COPYING for more details.
     15 */
     16
     17/*
    218 *'freely' inspired by http://jojo.ouvaton.org/dossiers/boot_sector/tutorial02.html
    319 * (actually, that's mostly copied, with minor compilation fixes)
     
    622#include "klibc.h"
    723
    8 #define GDTBASE 0x800   /* Physical address of GDT */
    9 #define GDTSIZE 0xFF    /* Maximum table size (in entries) */
     24#define GDTBASE 0x800           /* Physical address of GDT */
     25#define GDTSIZE 0xFF            /* Maximum table size (in entries) */
    1026
    11 /* Segment descriptor  */
    12 struct gdtdesc {
    13         u16 lim0_15;   
    14         u16 base0_15;
    15         u8 base16_23;
    16         u8 acces;
    17         u8 lim16_19 : 4;
    18         u8 other : 4;
    19         u8 base24_31;
    20 }  __attribute__ ((packed));
     27/* Segment descriptor */
     28struct gdtdesc
     29{
     30    u16 lim0_15;
     31    u16 base0_15;
     32    u8 base16_23;
     33    u8 acces;
     34    u8 lim16_19:4;
     35    u8 other:4;
     36    u8 base24_31;
     37} __attribute__ ((packed));
    2138
    22 /* GDTR register  */
    23 struct gdtr {
    24         u16 limite ;
    25         u32 base ;
    26 }  __attribute__ ((packed));
     39/* GDTR register */
     40struct gdtr
     41{
     42    u16 limite;
     43    u32 base;
     44} __attribute__ ((packed));
    2745struct gdtr kgdtr;
    2846
    2947
    30 struct gdtdesc kgdt[GDTSIZE] = {{0, 0, 0, 0, 0, 0, 0}};
     48struct gdtdesc kgdt[GDTSIZE] = { {0, 0, 0, 0, 0, 0, 0} };
     49
    3150unsigned int kgdtptr = 1;
    3251
    33 void init_code_desc(u32 base, u32 limite, struct gdtdesc* desc);
    34 void init_data_desc(u32 base, u32 limite, struct gdtdesc* desc);
     52void init_code_desc(u32 base, u32 limite, struct gdtdesc *desc);
     53void init_data_desc(u32 base, u32 limite, struct gdtdesc *desc);
    3554void add_gdt_desc(struct gdtdesc desc);
    3655void init_gdt(void);
     
    3857
    3958
    40 void init_gdt_desc(u32 base, u32 limite, u8 acces, u8 other, struct gdtdesc* desc) {
    41         desc->lim0_15 = (limite & 0xffff);
    42         desc->base0_15 = (base & 0xffff);
    43         desc->base16_23 = (base & 0xff0000)>>16;
    44         desc->acces = acces;
    45         desc->lim16_19 = (limite & 0xf0000)>>16;
    46         desc->other = (other & 0xf);
    47         desc->base24_31 = (base & 0xff000000)>>24;
    48         return;
     59void init_gdt_desc(u32 base, u32 limite, u8 acces, u8 other,
     60                   struct gdtdesc *desc)
     61{
     62    desc->lim0_15 = (limite & 0xffff);
     63    desc->base0_15 = (base & 0xffff);
     64    desc->base16_23 = (base & 0xff0000) >> 16;
     65    desc->acces = acces;
     66    desc->lim16_19 = (limite & 0xf0000) >> 16;
     67    desc->other = (other & 0xf);
     68    desc->base24_31 = (base & 0xff000000) >> 24;
     69    return;
    4970}
    5071
    5172
    52 void init_code_desc(u32 base, u32 limite, struct gdtdesc* desc) {
    53         init_gdt_desc(base, limite, 0x9B, 0x0D, desc);
     73void init_code_desc(u32 base, u32 limite, struct gdtdesc *desc)
     74{
     75    init_gdt_desc(base, limite, 0x9B, 0x0D, desc);
    5476}
    5577
    56 void init_data_desc(u32 base, u32 limite, struct gdtdesc* desc) {
    57         init_gdt_desc(base, limite, 0x93, 0x0D, desc);
     78void init_data_desc(u32 base, u32 limite, struct gdtdesc *desc)
     79{
     80    init_gdt_desc(base, limite, 0x93, 0x0D, desc);
    5881}
    5982
    60 void add_gdt_desc(struct gdtdesc desc) {
    61         kgdt[kgdtptr] = desc;
    62         kgdtptr++;
     83void add_gdt_desc(struct gdtdesc desc)
     84{
     85    kgdt[kgdtptr] = desc;
     86    kgdtptr++;
    6387}
    6488
    65 void init_gdt(void) {
    66         struct gdtdesc code, data, stack;
    67    
    68         /* initialisation des descripteurs de segment */
    69         init_code_desc(0x0, 0xFFFFF, &code);
    70         init_data_desc(0x0, 0xFFFFF, &data);
    71         init_gdt_desc(0, 0x10, 0x97, 0x0D, &stack);
    72         add_gdt_desc(code);
    73         add_gdt_desc(data);
    74         add_gdt_desc(stack);
    75    
    76         /* initialisation de la structure pour GDTR */
    77         kgdtr.limite = GDTSIZE*8;
    78         kgdtr.base = GDTBASE;
    79    
    80         /* recopie de la GDT a son adresse */   
    81         memcpy((void*)kgdtr.base, kgdt, kgdtr.limite);
    82    
    83         /* chargement du registre GDTR */
    84         asm("lgdtl (kgdtr)");
    85    
    86         /* initialisation des segments */
    87         asm("   movw $0x10,%ax  \n \
     89void init_gdt(void)
     90{
     91    struct gdtdesc code, data, stack;
     92
     93    /* initialisation des descripteurs de segment */
     94    init_code_desc(0x0, 0xFFFFF, &code);
     95    init_data_desc(0x0, 0xFFFFF, &data);
     96    init_gdt_desc(0, 0x10, 0x97, 0x0D, &stack);
     97    add_gdt_desc(code);
     98    add_gdt_desc(data);
     99    add_gdt_desc(stack);
     100
     101    /* initialisation de la structure pour GDTR */
     102    kgdtr.limite = GDTSIZE * 8;
     103    kgdtr.base = GDTBASE;
     104
     105    /* recopie de la GDT a son adresse */
     106    memcpy((void *)kgdtr.base, kgdt, kgdtr.limite);
     107
     108    /* chargement du registre GDTR */
     109    asm("lgdtl (kgdtr)");
     110
     111    /* initialisation des segments */
     112    asm("       movw $0x10,%ax  \n \
    88113                movw %ax, %ds   \n \
    89114                movw %ax, %es   \n \
     
    98123                next:   \n");
    99124}
    100 
    101 
  • libcaca/trunk/kernel/boot/idt.c

    r4154 r4158  
    1 /*
     1/*
     2 *  libcaca       
     3 *  libcaca       Colour ASCII-Art library
     4 *  Copyright (c) 2006 Sam Hocevar <sam@hocevar.net>
     5 *                2009 Jean-Yves Lamoureux <jylam@lnxscene.org>
     6 *                All Rights Reserved
     7 *
     8 *  $Id: kernel.h 4154 2009-12-20 13:33:11Z jylam $
     9 *
     10 *  This library is free software. It comes without any warranty, to
     11 *  the extent permitted by applicable law. You can redistribute it
     12 *  and/or modify it under the terms of the Do What The Fuck You Want
     13 *  To Public License, Version 2, as published by Sam Hocevar. See
     14 *  http://sam.zoy.org/wtfpl/COPYING for more details.
     15 */
     16
     17/*
    218 *'freely' inspired by http://jojo.ouvaton.org/dossiers/boot_sector/tutorial02.html
    319 * (actually, that's mostly copied, with minor compilation fixes)
     
    622#include "klibc.h"
    723
    8 #define IDTBASE 0               /* GDT Physical address */
    9 #define IDTSIZE 256             /* Max descriptor count */
    10 #define INTGATE 0x8E00  /* Interruptions */
    11 #define TRAPGATE 0x8F00 /* Syscalls */
    12 #define TASKGATE 0x8500 /* Task switching */
     24#define IDTBASE 0               /* GDT Physical address */
     25#define IDTSIZE 256             /* Max descriptor count */
     26#define INTGATE 0x8E00          /* Interruptions */
     27#define TRAPGATE 0x8F00         /* Syscalls */
     28#define TASKGATE 0x8500         /* Task switching */
    1329
    1430/* segment descriptor */
    15 struct idtdesc {
    16         u16 offset0_15;
    17         u16 select;
     31struct idtdesc
     32{
     33    u16 offset0_15;
     34    u16 select;
    1835    u16 type;
    19         u16 offset16_31;       
    20 }  __attribute__ ((packed));
     36    u16 offset16_31;
     37} __attribute__ ((packed));
    2138
    2239/* IDTR register */
    23 struct idtr {
    24         u16 limite;
    25         u32 base;
    26 }  __attribute__ ((packed));
     40struct idtr
     41{
     42    u16 limite;
     43    u32 base;
     44} __attribute__ ((packed));
    2745
    2846struct idtr kidtr;
    2947
    3048/* IDT table */
    31 struct idtdesc kidt[IDTSIZE] = {{0, 0, 0, 0}};
     49struct idtdesc kidt[IDTSIZE] = { {0, 0, 0, 0} };
    3250
    3351/* pointer on a free IDT entry */
     
    6583
    6684
    67 void init_idt_desc(u32 offset, u16 select, u16 type, struct idtdesc* desc) {
    68         desc->offset0_15 = (offset & 0xffff);
    69         desc->select = select;
    70         desc->type = type;
    71         desc->offset16_31 = (offset & 0xffff0000) >> 16;
    72         return;
     85void init_idt_desc(u32 offset, u16 select, u16 type, struct idtdesc *desc)
     86{
     87    desc->offset0_15 = (offset & 0xffff);
     88    desc->select = select;
     89    desc->type = type;
     90    desc->offset16_31 = (offset & 0xffff0000) >> 16;
     91    return;
    7392}
    7493
    7594
    76 void add_idt_desc(struct idtdesc desc) {
    77         kidt[kidtptr++] = desc;
    78         return;
     95void add_idt_desc(struct idtdesc desc)
     96{
     97    kidt[kidtptr++] = desc;
     98    return;
    7999}
    80100
    81101
    82 void init_idt(void) {
    83         struct idtdesc desc;
    84         int i;
     102void init_idt(void)
     103{
     104    struct idtdesc desc;
     105    int i;
    85106
    86    
    87         for(i=0;i<IDTSIZE;i++) {
    88                 init_idt_desc((u32)default_int, 0x08, INTGATE, &desc);
    89                 add_idt_desc(desc);
    90         }
    91107
    92         init_idt_desc((u32)k_int0, 0x08, INTGATE, &kidt[0]);
    93         init_idt_desc((u32)k_int1, 0x08, INTGATE, &kidt[1]);
    94         init_idt_desc((u32)k_int2, 0x08, INTGATE, &kidt[2]);
    95         init_idt_desc((u32)k_int3, 0x08, INTGATE, &kidt[3]);
    96         init_idt_desc((u32)k_int4, 0x08, INTGATE, &kidt[4]);
    97         init_idt_desc((u32)k_int5, 0x08, INTGATE, &kidt[5]);
    98         init_idt_desc((u32)k_int6, 0x08, INTGATE, &kidt[6]);
    99         init_idt_desc((u32)k_int7, 0x08, INTGATE, &kidt[7]);
    100         init_idt_desc((u32)k_int8, 0x08, INTGATE, &kidt[8]);
    101         init_idt_desc((u32)k_int9, 0x08, INTGATE, &kidt[9]);
    102         init_idt_desc((u32)k_int10, 0x08, INTGATE, &kidt[10]);
    103         init_idt_desc((u32)k_int11, 0x08, INTGATE, &kidt[11]);
    104         init_idt_desc((u32)k_int12, 0x08, INTGATE, &kidt[12]);
    105         init_idt_desc((u32)k_int13, 0x08, INTGATE, &kidt[13]);
    106         init_idt_desc((u32)k_int14, 0x08, INTGATE, &kidt[14]);
    107         init_idt_desc((u32)k_int15, 0x08, INTGATE, &kidt[15]);
    108         init_idt_desc((u32)k_int16, 0x08, INTGATE, &kidt[16]);
    109         init_idt_desc((u32)k_int17, 0x08, INTGATE, &kidt[17]);
    110         init_idt_desc((u32)k_int18, 0x08, INTGATE, &kidt[18]);
    111    
    112         init_idt_desc((u32)k_irq0, 0x08, INTGATE, &kidt[32]);
    113         init_idt_desc((u32)k_irq1, 0x08, INTGATE, &kidt[33]);
    114         init_idt_desc((u32)k_irq2, 0x08, INTGATE, &kidt[34]);
    115         init_idt_desc((u32)k_irq3, 0x08, INTGATE, &kidt[35]);
    116         init_idt_desc((u32)k_irq4, 0x08, INTGATE, &kidt[36]);
    117         init_idt_desc((u32)k_irq5, 0x08, INTGATE, &kidt[37]);
    118         init_idt_desc((u32)k_irq6, 0x08, INTGATE, &kidt[38]);
    119         init_idt_desc((u32)k_irq7, 0x08, INTGATE, &kidt[39]);
    120         init_idt_desc((u32)k_irq8, 0x08, INTGATE, &kidt[40]);
    121    
    122     kidtr.limite = IDTSIZE*8;
    123         kidtr.base = IDTBASE;
    124    
    125         memcpy((void*)kidtr.base, kidt, kidtr.limite);
     108    for (i = 0; i < IDTSIZE; i++)
     109    {
     110        init_idt_desc((u32) default_int, 0x08, INTGATE, &desc);
     111        add_idt_desc(desc);
     112    }
     113
     114    init_idt_desc((u32) k_int0, 0x08, INTGATE, &kidt[0]);
     115    init_idt_desc((u32) k_int1, 0x08, INTGATE, &kidt[1]);
     116    init_idt_desc((u32) k_int2, 0x08, INTGATE, &kidt[2]);
     117    init_idt_desc((u32) k_int3, 0x08, INTGATE, &kidt[3]);
     118    init_idt_desc((u32) k_int4, 0x08, INTGATE, &kidt[4]);
     119    init_idt_desc((u32) k_int5, 0x08, INTGATE, &kidt[5]);
     120    init_idt_desc((u32) k_int6, 0x08, INTGATE, &kidt[6]);
     121    init_idt_desc((u32) k_int7, 0x08, INTGATE, &kidt[7]);
     122    init_idt_desc((u32) k_int8, 0x08, INTGATE, &kidt[8]);
     123    init_idt_desc((u32) k_int9, 0x08, INTGATE, &kidt[9]);
     124    init_idt_desc((u32) k_int10, 0x08, INTGATE, &kidt[10]);
     125    init_idt_desc((u32) k_int11, 0x08, INTGATE, &kidt[11]);
     126    init_idt_desc((u32) k_int12, 0x08, INTGATE, &kidt[12]);
     127    init_idt_desc((u32) k_int13, 0x08, INTGATE, &kidt[13]);
     128    init_idt_desc((u32) k_int14, 0x08, INTGATE, &kidt[14]);
     129    init_idt_desc((u32) k_int15, 0x08, INTGATE, &kidt[15]);
     130    init_idt_desc((u32) k_int16, 0x08, INTGATE, &kidt[16]);
     131    init_idt_desc((u32) k_int17, 0x08, INTGATE, &kidt[17]);
     132    init_idt_desc((u32) k_int18, 0x08, INTGATE, &kidt[18]);
     133
     134    init_idt_desc((u32) k_irq0, 0x08, INTGATE, &kidt[32]);
     135    init_idt_desc((u32) k_irq1, 0x08, INTGATE, &kidt[33]);
     136    init_idt_desc((u32) k_irq2, 0x08, INTGATE, &kidt[34]);
     137    init_idt_desc((u32) k_irq3, 0x08, INTGATE, &kidt[35]);
     138    init_idt_desc((u32) k_irq4, 0x08, INTGATE, &kidt[36]);
     139    init_idt_desc((u32) k_irq5, 0x08, INTGATE, &kidt[37]);
     140    init_idt_desc((u32) k_irq6, 0x08, INTGATE, &kidt[38]);
     141    init_idt_desc((u32) k_irq7, 0x08, INTGATE, &kidt[39]);
     142    init_idt_desc((u32) k_irq8, 0x08, INTGATE, &kidt[40]);
     143
     144    kidtr.limite = IDTSIZE * 8;
     145    kidtr.base = IDTBASE;
     146
     147    memcpy((void *)kidtr.base, kidt, kidtr.limite);
    126148#define printf(format, ...) { char __str[255]; sprintf (__str, format, __VA_ARGS__); print(__str);}
    127149
    128150    printf("Loading IDT from 0x%x\n", kidtr);
    129151#undef printf
    130    
     152
    131153    asm("lidtl (kidtr)");
    132154}
  • libcaca/trunk/kernel/boot/interruptions.c

    r4154 r4158  
     1/*
     2 *  libcaca       
     3 *  libcaca       Colour ASCII-Art library
     4 *  Copyright (c) 2006 Sam Hocevar <sam@hocevar.net>
     5 *                2009 Jean-Yves Lamoureux <jylam@lnxscene.org>
     6 *                All Rights Reserved
     7 *
     8 *  $Id: kernel.h 4154 2009-12-20 13:33:11Z jylam $
     9 *
     10 *  This library is free software. It comes without any warranty, to
     11 *  the extent permitted by applicable law. You can redistribute it
     12 *  and/or modify it under the terms of the Do What The Fuck You Want
     13 *  To Public License, Version 2, as published by Sam Hocevar. See
     14 *  http://sam.zoy.org/wtfpl/COPYING for more details.
     15 */
     16
     17
    118#include "kernel.h"
    219#include "klibc.h"
     
    421
    522
    6 void idt_default_int(void) {
    7         print("!! Unknown interrupt\n");
     23void idt_default_int(void)
     24{
     25    print("!! Unknown interrupt\n");
    826}
    927
    10 void idt_int0(void) {
    11         print("!! Divide by 0\n ");
     28void idt_int0(void)
     29{
     30    print("!! Divide by 0\n ");
    1231}
    13 void idt_int1(void) {
    14         print("!! Debug exception ");
     32
     33void idt_int1(void)
     34{
     35    print("!! Debug exception ");
    1536}
    16 void idt_int2(void) {
    17         print("!! NMI ");
     37
     38void idt_int2(void)
     39{
     40    print("!! NMI ");
    1841}
    19 void idt_int3(void) {
    20         print("!! Breakpoint ");
     42
     43void idt_int3(void)
     44{
     45    print("!! Breakpoint ");
    2146}
    22 void idt_int4(void) {
    23         print("!! Overflow ");
     47
     48void idt_int4(void)
     49{
     50    print("!! Overflow ");
    2451}
    25 void idt_int5(void) {
    26         print("!! BoundCheck ");
     52
     53void idt_int5(void)
     54{
     55    print("!! BoundCheck ");
    2756}
    28 void idt_int6(void) {
    29         print("!! Invalid Opcode ");
     57
     58void idt_int6(void)
     59{
     60    print("!! Invalid Opcode ");
    3061}
    31 void idt_int7(void) {
    32         print("!! Coprocessor not available ");
     62
     63void idt_int7(void)
     64{
     65    print("!! Coprocessor not available ");
    3366}
    34 void idt_int8(void) {
    35         print("!! Double Fault ");
     67
     68void idt_int8(void)
     69{
     70    print("!! Double Fault ");
    3671}
    37 void idt_int9(void) {
    38         print("!! Coprocessor segment overrun ");
     72
     73void idt_int9(void)
     74{
     75    print("!! Coprocessor segment overrun ");
    3976}
    40 void idt_int10(void) {
    41         print("!! Invalid TSS ");
     77
     78void idt_int10(void)
     79{
     80    print("!! Invalid TSS ");
    4281}
    43 void idt_int11(void) {
    44         print("!! Segment not present ");
     82
     83void idt_int11(void)
     84{
     85    print("!! Segment not present ");
    4586}
    46 void idt_int12(void) {
    47         print("!! Stack exception ");
     87
     88void idt_int12(void)
     89{
     90    print("!! Stack exception ");
    4891}
    49 void idt_int13(void) {
    50         print("!! General protection exception ");
     92
     93void idt_int13(void)
     94{
     95    print("!! General protection exception ");
    5196}
    52 void idt_int14(void) {
    53         print("!! Page fault ");
     97
     98void idt_int14(void)
     99{
     100    print("!! Page fault ");
    54101}
    55 void idt_int15(void) {
    56         print("!! Intel reserved int ");
     102
     103void idt_int15(void)
     104{
     105    print("!! Intel reserved int ");
    57106}
    58 void idt_int16(void) {
    59         print("!! Coprocessor error ");
     107
     108void idt_int16(void)
     109{
     110    print("!! Coprocessor error ");
    60111}
    61 void idt_int17(void) {
    62         print("!! Intel reserved (2) ");
     112
     113void idt_int17(void)
     114{
     115    print("!! Intel reserved (2) ");
    63116}
    64 void idt_int18(void) {
    65         print("i18 ");
     117
     118void idt_int18(void)
     119{
     120    print("i18 ");
    66121}
    67122
    68123
    69124/* Used by Channel0 timer */
    70 void idt_irq0(void) {
     125void idt_irq0(void)
     126{
    71127    ticks++;
    72128}
    73 void idt_irq2(void) {
    74         print("IRQ 2");
     129
     130void idt_irq2(void)
     131{
     132    print("IRQ 2");
    75133}
    76 void idt_irq3(void) {
    77         print("IRQ 3");
     134
     135void idt_irq3(void)
     136{
     137    print("IRQ 3");
    78138}
    79 void idt_irq4(void) {
    80         print("IRQ 4");
     139
     140void idt_irq4(void)
     141{
     142    print("IRQ 4");
    81143}
    82 void idt_irq5(void) {
    83         print("IRQ 5");
     144
     145void idt_irq5(void)
     146{
     147    print("IRQ 5");
    84148}
    85 void idt_irq6(void) {
    86         print("IRQ 6");
     149
     150void idt_irq6(void)
     151{
     152    print("IRQ 6");
    87153}
    88 void idt_irq7(void) {
    89         print("IRQ 7");
     154
     155void idt_irq7(void)
     156{
     157    print("IRQ 7");
    90158}
    91 void idt_irq8(void) {
    92         print("IRQ 8");
     159
     160void idt_irq8(void)
     161{
     162    print("IRQ 8");
    93163}
    94164
     
    97167
    98168/* Keyboard irq is 1 */
    99 void kbd_int(void) {
    100         unsigned char i;
    101         do {
    102                 i=inb(0x64);
    103         } while((i & 0x01) == 0);
    104    
    105         i=inb(0x60);
    106         i--;
    107    
    108         if(i<0x80){
    109                 putcar(kbdmap[i*4]);
    110         }
     169void kbd_int(void)
     170{
     171    unsigned char i;
     172    do
     173    {
     174        i = inb(0x64);
     175    }
     176    while ((i & 0x01) == 0);
     177
     178    i = inb(0x60);
     179    i--;
     180
     181    if (i < 0x80)
     182    {
     183        putcar(kbdmap[i * 4]);
     184    }
    111185}
    112 
  • libcaca/trunk/kernel/boot/pic.c

    r4154 r4158  
     1/*
     2 *  libcaca       
     3 *  libcaca       Colour ASCII-Art library
     4 *  Copyright (c) 2006 Sam Hocevar <sam@hocevar.net>
     5 *                2009 Jean-Yves Lamoureux <jylam@lnxscene.org>
     6 *                All Rights Reserved
     7 *
     8 *  $Id: kernel.h 4154 2009-12-20 13:33:11Z jylam $
     9 *
     10 *  This library is free software. It comes without any warranty, to
     11 *  the extent permitted by applicable law. You can redistribute it
     12 *  and/or modify it under the terms of the Do What The Fuck You Want
     13 *  To Public License, Version 2, as published by Sam Hocevar. See
     14 *  http://sam.zoy.org/wtfpl/COPYING for more details.
     15 */
     16
     17
    118#include "klibc.h"
    219
     
    1027void init_pic(void)
    1128{
    12         /* MASTER */
    13     outbp(PIC_MASTER_ICW1,0x11); // Init 8259A-1
     29    /* MASTER */
     30    outbp(PIC_MASTER_ICW1, 0x11);      // Init 8259A-1
    1431    /* ICW2 - start vector = 32 */
    15     outbp(PIC_MASTER_ICW2,0x20); // IRQ 0-7 mapped to 0x20-0x27
     32    outbp(PIC_MASTER_ICW2, 0x20);      // IRQ 0-7 mapped to 0x20-0x27
    1633    /* IICW3 */
    17     outbp(PIC_MASTER_ICW2,0x04); // 8259A-1 has slave
     34    outbp(PIC_MASTER_ICW2, 0x04);      // 8259A-1 has slave
    1835    /* ICW4 */
    19     outbp(PIC_MASTER_ICW2,0x01);
     36    outbp(PIC_MASTER_ICW2, 0x01);
    2037    /* Int mask */
    21     outbp(PIC_MASTER_ICW2,0xFF);
    22    
    23         /* SLAVE */
    24     outbp(PIC_SLAVE_ICW1,0x11);
    25         /* ICW2 - start vector = 96 */
    26     outbp(PIC_SLAVE_ICW2,0x70);     
    27         /* ICW3 */
    28     outbp(PIC_SLAVE_ICW2,0x02);
    29         /* ICW4 */
    30     outbp(PIC_SLAVE_ICW2,0x01);
    31         /* Int Mask */
    32     outbp(PIC_SLAVE_ICW2,0xFF);
    33    
    34    
    35         /* Unmask irqs */
    36     outbp(0x21,0xFD);
    37    
     38    outbp(PIC_MASTER_ICW2, 0xFF);
     39
     40    /* SLAVE */
     41    outbp(PIC_SLAVE_ICW1, 0x11);
     42    /* ICW2 - start vector = 96 */
     43    outbp(PIC_SLAVE_ICW2, 0x70);
     44    /* ICW3 */
     45    outbp(PIC_SLAVE_ICW2, 0x02);
     46    /* ICW4 */
     47    outbp(PIC_SLAVE_ICW2, 0x01);
     48    /* Int Mask */
     49    outbp(PIC_SLAVE_ICW2, 0xFF);
     50
     51
     52    /* Unmask irqs */
     53    outbp(0x21, 0xFD);
     54
    3855}
    3956
     
    4663void disable_interrupt(char irq)
    4764{
    48         unsigned int mask = 1 << irq;
    49        
    50         cached_irq_mask |= mask;
    51     if (irq & 8) {
    52                 outb(0xA1, cached_A1);
    53     } else {
    54                 outb(0x21, cached_21);
     65    unsigned int mask = 1 << irq;
     66
     67    cached_irq_mask |= mask;
     68    if (irq & 8)
     69    {
     70        outb(0xA1, cached_A1);
     71    }
     72    else
     73    {
     74        outb(0x21, cached_21);
    5575    }
    5676}
     
    5878void enable_interrupt(char irq)
    5979{
    60         unsigned int mask = ~(1 << irq);
    61    
    62         cached_irq_mask &= mask;
    63         if (irq & 8) {
    64                 outb(0xA1, cached_A1);
    65     } else {
    66                 outb(0x21, cached_21);
     80    unsigned int mask = ~(1 << irq);
     81
     82    cached_irq_mask &= mask;
     83    if (irq & 8)
     84    {
     85        outb(0xA1, cached_A1);
     86    }
     87    else
     88    {
     89        outb(0x21, cached_21);
    6790    }
    6891
    6992}
    70 
    71 
    72 
    73 
  • libcaca/trunk/kernel/boot/stage2.c

    r4154 r4158  
     1/*
     2 *  libcaca       
     3 *  libcaca       Colour ASCII-Art library
     4 *  Copyright (c) 2006 Sam Hocevar <sam@hocevar.net>
     5 *                2009 Jean-Yves Lamoureux <jylam@lnxscene.org>
     6 *                All Rights Reserved
     7 *
     8 *  $Id: kernel.h 4154 2009-12-20 13:33:11Z jylam $
     9 *
     10 *  This library is free software. It comes without any warranty, to
     11 *  the extent permitted by applicable law. You can redistribute it
     12 *  and/or modify it under the terms of the Do What The Fuck You Want
     13 *  To Public License, Version 2, as published by Sam Hocevar. See
     14 *  http://sam.zoy.org/wtfpl/COPYING for more details.
     15 */
     16
    117#include "kernel.h"
    218#include "klibc.h"
     
    521
    622
    7 /* Entry point
    8  * bootsect.asm loaded this file at 0x0100:0x0, which is mapped
    9  * at 0x8:0x1000 (selector+8bytes, offset 1000 (0x100 + 0x0)
    10  */
     23/* Entry point bootsect.asm loaded this file at 0x0100:0x0, which is mapped
     24   at 0x8:0x1000 (selector+8bytes, offset 1000 (0x100 + 0x0) */
    1125
    1226/* 0x1000 */
    13 void _start(void) {
     27void _start(void)
     28{
     29    clearscreen();
    1430
    15         clearscreen();
    16    
    1731    init_gdt();
    1832    print("Loading IDT\n");
     
    2236    print("Running kmain()\n");
    2337    sti;
    24         kmain(); /* Call kernel's kmain() */
    2538   
    26     while(1) { /* Never return */
    27                 print("hlt;\n");
     39    kmain();                    /* Call kernel's kmain() */
     40
     41    while (1)
     42    {                           /* Never return */
     43        print("hlt;\n");
    2844    }
    2945}
    30 
  • libcaca/trunk/kernel/boot/stage2.h

    r4154 r4158  
     1/*
     2 *  libcaca       
     3 *  libcaca       Colour ASCII-Art library
     4 *  Copyright (c) 2006 Sam Hocevar <sam@hocevar.net>
     5 *                2009 Jean-Yves Lamoureux <jylam@lnxscene.org>
     6 *                All Rights Reserved
     7 *
     8 *  $Id: kernel.h 4154 2009-12-20 13:33:11Z jylam $
     9 *
     10 *  This library is free software. It comes without any warranty, to
     11 *  the extent permitted by applicable law. You can redistribute it
     12 *  and/or modify it under the terms of the Do What The Fuck You Want
     13 *  To Public License, Version 2, as published by Sam Hocevar. See
     14 *  http://sam.zoy.org/wtfpl/COPYING for more details.
     15 */
     16
     17
     18
    119extern int _start(void);
Note: See TracChangeset for help on using the changeset viewer.