Kernel 0.5.0 ! Lot of fixes, fast, no few new features, etc ..
[ZeXOS.git] / kernel / include / system.h
blob5683004592ceee2cc83d951094032459a367df7d
1 /*
2 * ZeX/OS
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/>.
20 #ifndef __SYSTEM_H
21 #define __SYSTEM_H
23 #include "fdc.h"
24 #include "mytypes.h"
25 #include "dev.h"
26 #include "user.h"
27 #include "tty.h"
28 #include "partition.h"
29 #include "../drivers/char/video/video.h"
31 /* irq0 timer */
32 #define HZ 1000
34 /* kernel attributes */
35 unsigned kernel_attr;
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
47 tty_t *currtty;
49 /* keys */
50 char key;
51 unsigned key_state;
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 */
60 struct regs
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" \
70 "movw %0,%%dx\n\t" \
71 "movl %%eax,%1\n\t" \
72 "movl %%edx,%2" \
73 : \
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))
80 struct dir{
81 char name[10];
82 int read;
83 int hidden;
84 int system;
85 int volume;
86 int dir;
87 int bin;
88 unsigned int start;
89 } dir[223];
91 unsigned char *file_cache;
93 /** externs **/
95 /* init.c */
96 extern int init ();
98 /* memory.c */
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 ();
105 /* console.c */
106 extern unsigned int init_console ();
108 /* elf.c */
109 extern int exec_elf (unsigned char *image, unsigned *entry);
110 extern int flush_elf ();
112 /* exec.c */
113 extern bool exec (unsigned char *fi);
115 /* gtd.c */
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();
119 /* idt.c */
120 extern void idt_set_gate(unsigned char num, unsigned long base, unsigned short sel, unsigned char flags);
121 extern unsigned int idt_install();
123 /* isrs.c */
124 extern unsigned int isrs_install();
126 /* irq.c */
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 ();
131 /* timer.c */
132 extern void timer_wait (int ticks);
133 extern unsigned int timer_install ();
135 /* keyboard.c */
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);
145 /* fat.c */
146 extern void read_dir (int aa);
147 extern unsigned long read_file (int aa);
149 /* ls.c */
150 extern int ls (unsigned char* fi);
152 /* cd.c */
153 extern int cd (unsigned char* fi);
155 /* cat.c */
156 extern int cat (partition_t *p, unsigned char *fi);
158 #endif