Merge commit 'origin/master' into pipes
[ZeXOS.git] / kernel / include / system.h
blob2c6e01c7c833dc9281c9bdca91f6ba147ad22da6
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 "_null.h"
34 #include "_size_t.h"
35 #include "../drivers/char/video/video.h"
36 #include "elf.h"
37 #include "paging.h"
39 /* irq0 timer */
40 #define HZ 1000
42 /* kernel attributes */
43 unsigned kernel_attr;
45 #define KERNEL_LIVE 0x01
46 #define KERNEL_18HZ 0x02
47 #define KERNEL_NOHDD 0x04
48 #define KERNEL_NOATA 0x08
49 #define KERNEL_NOFLOPPY 0x10
50 #define KERNEL_NOCDROM 0x20
51 #define KERNEL_NOETH 0x40
52 #define KERNEL_NOVESA 0x80
55 #define swap16(x) ({unsigned _x = (x); (((_x)>>8)&0xff) | (((_x)<<8)&0xff00); })
57 #define swap32(x) ({\
58 unsigned _x = (x); \
59 (((_x)>>24)&0xff)\
61 (((_x)>>8)&0xff00)\
63 (((_x)<<8)&0xff0000)\
65 (((_x)<<24)&0xff000000);\
68 #define swap64(_v) (((unsigned long)swap32((unsigned)(_v))<<32)|(unsigned long)swap32((unsigned)((_v)>>32)))
70 unsigned debug; // developer mode
72 unsigned long long ctps; // cpu ticks per second
74 tty_t *currtty;
76 partition_t *curr_part;
78 unsigned int fd_count;
80 page_dir_t *page_cover_curr;
82 unsigned char *kbd_layout[2];
84 extern unsigned short *vesafb;
86 #define KBD_MAX_QUAUE 16
87 typedef struct
89 char key[KBD_MAX_QUAUE];
90 int p;
91 //unsigned char state[KBD_MAX_QUAUE];
92 } kbd_quaue;
94 /* memory vars */
95 unsigned short mem_ext;
97 /* fs directory structure */
98 struct dir {
99 char name[10];
100 int read;
101 int hidden;
102 int system;
103 int volume;
104 int dir;
105 int bin;
106 unsigned int start;
107 } dir[223];
109 unsigned char *file_cache;
110 unsigned long file_cache_id;
112 /** externs **/
114 /* init.c */
115 extern int init ();
117 /* kmem.c */
118 extern void *malloc (unsigned size);
119 extern void *realloc(void *blk, unsigned size);
120 extern void free (void *blk);
121 extern void *kmalloc (unsigned size);
122 extern void *krealloc(void *blk, unsigned size);
123 extern void kfree (void *blk);
125 extern unsigned int init_mm ();
127 /* pmem.c */
128 extern void *pmalloc (size_t size);
129 extern void pfree (void *blk);
130 extern void *palign (void *p);
132 /* swmem.c */
133 extern void *swmalloc (unsigned size);
134 extern unsigned swfree (void *ptr, unsigned size);
135 extern unsigned int swmem_init ();
137 /* protmem.c */
138 extern void *memcpy_to_user (void *dest, const void *src, size_t count);
139 extern void *memcpy_from_user (void *dest, const void *src, size_t count);
140 extern unsigned memtest_data (void *src, void *data, size_t offset);
142 /* console.c */
143 extern unsigned int init_console ();
144 extern void console (int i);
146 /* elf.c */
147 extern int exec_elf (unsigned char *image, unsigned *entry, unsigned *elf_data, unsigned *elf_data_off, unsigned *elf_bss);
148 extern int flush_elf ();
150 /* exec.c */
151 extern bool exec (partition_t *p, unsigned char *fi);
153 /* keyboard.c */
154 extern unsigned keyboard_setlayout (char *layout);
155 extern unsigned keyboard_getlayout (char *layout);
157 extern char getkey ();
158 extern void setkey (char key);
160 extern unsigned int init_tasks (void);
161 extern unsigned sched_lock ();
162 extern unsigned sched_unlock ();
163 extern void schedule (void);
165 /* video.c */
166 extern unsigned char vgagui;
168 extern void uptime (void);
170 /* fat.c */
171 extern unsigned read_dir (int aa);
172 extern unsigned long read_file (int aa);
174 /* ls.c */
175 extern int ls (unsigned char *fi);
177 /* cd.c */
178 extern int cd (unsigned char *fi);
180 /* cp.c */
181 extern int cp (unsigned char *fi, unsigned char *fo);
183 /* cat.c */
184 extern int cat (unsigned char *fi);
186 /* read.c */
187 extern int read (unsigned fd, void *buf, unsigned len);
189 /* fopen.c */
190 extern FILE *fopen (const char *filename, const char *mode);
192 /* fputs.c */
193 extern char *fgets (char *string, int n, FILE *file);
195 /* fclose.c */
196 extern int fclose (FILE *file);
198 /* keyboard.c */
199 extern unsigned int init_keyboard ();
201 /* arch depend rtc.c */
202 extern tm *rtc_getcurrtime ();
204 /* arch depend task.c */
205 extern unsigned arch_task_init (task_t *task, unsigned entry);
206 extern unsigned arch_task_set (task_t *task);
207 extern unsigned arch_task_switch (task_t *task);
209 /* arch depend arch.c */
210 extern unsigned int_enable ();
211 extern unsigned int_disable ();
212 extern unsigned arch_cpu_hlt ();
213 extern unsigned init_arch ();
215 /* arch depend elf*.c */
216 extern unsigned arch_elf_detect (elf_file_t *file);
218 #endif