Update
[ZeXOS.git] / kernel / include / system.h
blob8d07ef65ce07f47d6b9f65d551e236a44bf5b074
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 #define MAX_VC 12
24 #include "fdc.h"
25 #include "mytypes.h"
26 #include "dev.h"
27 #include "user.h"
28 #include "tty.h"
29 #include "partition.h"
30 #include "../drivers/char/video/video.h"
32 tty_t *currtty;
34 #define CONSOLE_LOG 30
36 /* keys */
37 char key;
38 unsigned key_state;
40 unsigned debug; // developer mode
42 unsigned long long ctps; // cpu ticks per second
44 partition_t *curr_part;
46 /* This defines what the stack looks like after an ISR was running */
47 struct regs
49 unsigned int ds, es, fs, gs;
50 unsigned int edi, esi, ebp, esp, ebx, edx, ecx, eax;
51 unsigned int int_no, err_code;
52 unsigned int eip, cs, eflags, useresp, ss;
55 #define _set_gate(gate_addr,type,dpl,addr) \
56 __asm__ ("movw %%dx,%%ax\n\t" \
57 "movw %0,%%dx\n\t" \
58 "movl %%eax,%1\n\t" \
59 "movl %%edx,%2" \
60 : \
61 : "i" ((short) (0x8000+(dpl<<13)+(type<<8))), \
62 "o" (*((char *) (gate_addr))), \
63 "o" (*(4+(char *) (gate_addr))), \
64 "d" ((char *) (addr)),"a" (0x00080000))
67 struct dir{
68 char name[10];
69 int read;
70 int hidden;
71 int system;
72 int volume;
73 int dir;
74 int bin;
75 unsigned int start;
76 } dir[223];
78 unsigned char *file_cache;
80 /** externs **/
82 /* init.c */
83 extern int init ();
85 /* memory.c */
86 extern void *malloc (unsigned size);
87 extern void *realloc(void *blk, unsigned size);
88 extern void free (void *blk);
90 extern unsigned int init_mm ();
92 /* console.c */
93 extern unsigned int init_console ();
95 /* elf.c */
96 extern int exec_elf (unsigned char *image, unsigned *entry);
97 extern int flush_elf ();
99 /* exec.c */
100 extern bool exec (unsigned char *fi);
102 /* gtd.c */
103 extern void gdt_set_gate(int num, unsigned long base, unsigned long limit, unsigned char access, unsigned char gran);
104 extern unsigned int gdt_install();
106 /* idt.c */
107 extern void idt_set_gate(unsigned char num, unsigned long base, unsigned short sel, unsigned char flags);
108 extern unsigned int idt_install();
110 /* isrs.c */
111 extern unsigned int isrs_install();
113 /* irq.c */
114 extern void irq_install_handler (int irq, void (*handler)(struct regs *r));
115 extern void irq_uninstall_handler (int irq);
116 extern unsigned int irq_install ();
118 /* timer.c */
119 extern void timer_wait (int ticks);
120 extern unsigned int timer_install ();
122 /* keyboard.c */
123 extern unsigned int keyboard_install ();
125 extern unsigned int init_tasks (void);
126 extern void schedule (void);
127 extern unsigned int floppy_install (void);
128 extern void fda_print (int i);
129 extern void console (int i);
130 extern void uptime (void);
132 /* fat.c */
133 extern void read_dir (int aa);
134 extern unsigned long read_file (int aa);
136 /* ls.c */
137 extern int ls (unsigned char* fi);
139 /* cd.c */
140 extern int cd (unsigned char* fi);
142 /* cat.c */
143 extern int cat (partition_t *p, unsigned char *fi);
145 #endif