3 * Copyright (C) 2007 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com)
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
28 #include "partition.h"
29 #include "../drivers/char/video/video.h"
34 /* kernel attributes */
37 #define KERNEL_LIVE 0x01
38 #define KERNEL_SECURE 0x02
39 #define KERNEL_NOHDD 0x04
40 #define KERNEL_NOATA 0x08
41 #define KERNEL_NOFLOPPY 0x10
42 #define KERNEL_NOCDROM 0x20
45 #define CONSOLE_LOG 30
53 unsigned debug
; // developer mode
55 unsigned long long ctps
; // cpu ticks per second
57 partition_t
*curr_part
;
59 /* This defines what the stack looks like after an ISR was running */
62 unsigned int ds
, es
, fs
, gs
;
63 unsigned int edi
, esi
, ebp
, esp
, ebx
, edx
, ecx
, eax
;
64 unsigned int int_no
, err_code
;
65 unsigned int eip
, cs
, eflags
, useresp
, ss
;
68 #define _set_gate(gate_addr,type,dpl,addr) \
69 __asm__ ("movw %%dx,%%ax\n\t" \
74 : "i" ((short) (0x8000+(dpl<<13)+(type<<8))), \
75 "o" (*((char *) (gate_addr))), \
76 "o" (*(4+(char *) (gate_addr))), \
77 "d" ((char *) (addr)),"a" (0x00080000))
91 unsigned char *file_cache
;
99 extern void *malloc (unsigned size
);
100 extern void *realloc(void *blk
, unsigned size
);
101 extern void free (void *blk
);
103 extern unsigned int init_mm ();
106 extern unsigned int init_console ();
109 extern int exec_elf (unsigned char *image
, unsigned *entry
);
110 extern int flush_elf ();
113 extern bool exec (unsigned char *fi
);
116 extern void gdt_set_gate(int num
, unsigned long base
, unsigned long limit
, unsigned char access
, unsigned char gran
);
117 extern unsigned int gdt_install();
120 extern void idt_set_gate(unsigned char num
, unsigned long base
, unsigned short sel
, unsigned char flags
);
121 extern unsigned int idt_install();
124 extern unsigned int isrs_install();
127 extern void irq_install_handler (int irq
, void (*handler
)(struct regs
*r
));
128 extern void irq_uninstall_handler (int irq
);
129 extern unsigned int irq_install ();
132 extern void timer_wait (int ticks
);
133 extern unsigned int timer_install ();
136 extern unsigned int keyboard_install ();
138 extern unsigned int init_tasks (void);
139 extern void schedule (void);
140 extern unsigned int floppy_install (void);
141 extern void fda_print (int i
);
142 extern void console (int i
);
143 extern void uptime (void);
146 extern void read_dir (int aa
);
147 extern unsigned long read_file (int aa
);
150 extern int ls (unsigned char* fi
);
153 extern int cd (unsigned char* fi
);
156 extern int cat (partition_t
*p
, unsigned char *fi
);