missing files and previous update were fixed
[ZeXOS.git] / kernel / include / system.h
blob790efc8e8178bc71ef6d26d5df731501fa6e50c7
1 /*
2 * ZeX/OS
3 * Copyright (C) 2007 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com)
4 * Copyright (C) 2008 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com)
5 * Copyright (C) 2009 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com)
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #ifndef __SYSTEM_H
23 #define __SYSTEM_H
25 #include "fdc.h"
26 #include "mytypes.h"
27 #include "dev.h"
28 #include "user.h"
29 #include <tty.h>
30 #include "partition.h"
31 #include "file.h"
32 #include "time.h"
33 #include "_size_t.h"
34 #include "../drivers/char/video/video.h"
35 #include "elf.h"
36 #include "paging.h"
38 /* irq0 timer */
39 #define HZ 1000
41 /* kernel attributes */
42 unsigned kernel_attr;
44 #define KERNEL_LIVE 0x01
45 #define KERNEL_18HZ 0x02
46 #define KERNEL_NOHDD 0x04
47 #define KERNEL_NOATA 0x08
48 #define KERNEL_NOFLOPPY 0x10
49 #define KERNEL_NOCDROM 0x20
50 #define KERNEL_NOETH 0x40
51 #define KERNEL_NOVESA 0x80
54 #define swap16(x) ({unsigned _x = (x); (((_x)>>8)&0xff) | (((_x)<<8)&0xff00); })
56 #define swap32(x) ({\
57 unsigned _x = (x); \
58 (((_x)>>24)&0xff)\
60 (((_x)>>8)&0xff00)\
62 (((_x)<<8)&0xff0000)\
64 (((_x)<<24)&0xff000000);\
67 #define swap64(_v) (((unsigned long)swap32((unsigned)(_v))<<32)|(unsigned long)swap32((unsigned)((_v)>>32)))
69 unsigned debug; // developer mode
71 unsigned long long ctps; // cpu ticks per second
73 tty_t *currtty;
75 partition_t *curr_part;
77 unsigned int fd_count;
79 page_dir_t *page_cover_curr;
81 unsigned char *kbd_layout[2];
83 extern unsigned short *vesafb;
85 #define KBD_MAX_QUAUE 16
86 typedef struct
88 char key[KBD_MAX_QUAUE];
89 int p;
90 //unsigned char state[KBD_MAX_QUAUE];
91 } kbd_quaue;
93 /* memory vars */
94 unsigned short mem_ext;
96 /* fs directory structure */
97 struct dir {
98 char name[10];
99 int read;
100 int hidden;
101 int system;
102 int volume;
103 int dir;
104 int bin;
105 unsigned int start;
106 } dir[223];
108 unsigned char *file_cache;
109 unsigned long file_cache_id;
111 /** externs **/
113 /* init.c */
114 extern int init ();
116 /* kmem.c */
117 extern void *malloc (unsigned size);
118 extern void *realloc(void *blk, unsigned size);
119 extern void free (void *blk);
120 extern void *kmalloc (unsigned size);
121 extern void *krealloc(void *blk, unsigned size);
122 extern void kfree (void *blk);
124 extern unsigned int init_mm ();
126 /* pmem.c */
127 extern void *pmalloc (size_t size);
128 extern void pfree (void *blk);
129 extern void *palign (void *p);
131 /* swmem.c */
132 extern void *swmalloc (unsigned size);
133 extern unsigned swfree (void *ptr, unsigned size);
134 extern unsigned int swmem_init ();
136 /* protmem.c */
137 extern void *memcpy_to_user (void *dest, const void *src, size_t count);
138 extern void *memcpy_from_user (void *dest, const void *src, size_t count);
139 extern unsigned memtest_data (void *src, void *data, size_t offset);
141 /* console.c */
142 extern unsigned int init_console ();
143 extern void console (int i);
145 /* elf.c */
146 extern int exec_elf (unsigned char *image, unsigned *entry, unsigned *elf_data, unsigned *elf_data_off, unsigned *elf_bss);
147 extern int flush_elf ();
149 /* exec.c */
150 extern bool exec (partition_t *p, unsigned char *fi);
152 /* keyboard.c */
153 extern unsigned keyboard_setlayout (char *layout);
154 extern unsigned keyboard_getlayout (char *layout);
156 extern char getkey ();
157 extern void setkey (char key);
159 extern unsigned int init_tasks (void);
160 extern unsigned sched_lock ();
161 extern unsigned sched_unlock ();
162 extern void schedule (void);
164 /* video.c */
165 extern unsigned char vgagui;
167 extern void uptime (void);
169 /* fat.c */
170 extern unsigned read_dir (int aa);
171 extern unsigned long read_file (int aa);
173 /* ls.c */
174 extern int ls (unsigned char *fi);
176 /* cd.c */
177 extern int cd (unsigned char *fi);
179 /* cp.c */
180 extern int cp (unsigned char *fi, unsigned char *fo);
182 /* cat.c */
183 extern int cat (unsigned char *fi);
185 /* read.c */
186 extern int read (unsigned fd, void *buf, unsigned len);
188 /* fopen.c */
189 extern FILE *fopen (const char *filename, const char *mode);
191 /* fputs.c */
192 extern char *fgets (char *string, int n, FILE *file);
194 /* fclose.c */
195 extern int fclose (FILE *file);
197 /* keyboard.c */
198 extern unsigned int init_keyboard ();
200 /* arch depend rtc.c */
201 extern tm *rtc_getcurrtime ();
203 /* arch depend task.c */
204 extern unsigned arch_task_init (task_t *task, unsigned entry);
205 extern unsigned arch_task_set (task_t *task);
206 extern unsigned arch_task_switch (task_t *task);
208 /* arch depend arch.c */
209 extern unsigned int_enable ();
210 extern unsigned int_disable ();
211 extern unsigned arch_cpu_hlt ();
212 extern unsigned init_arch ();
214 /* arch depend elf*.c */
215 extern unsigned arch_elf_detect (elf_file_t *file);
217 #endif