Kernel 0.5.9-r7; New iso9660 filesystem support, better exec () function, some change...
[ZeXOS.git] / kernel / include / system.h
blob74c11065af986aa4ae81c57f00baee0e404a6612
1 /*
2 * ZeX/OS
3 * Copyright (C) 2007 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com)
4 * Copyright (C) 2008 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com)
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #ifndef __SYSTEM_H
22 #define __SYSTEM_H
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 "file.h"
31 #include "time.h"
32 #include "_size_t.h"
33 #include "../drivers/char/video/video.h"
34 #include "elf.h"
35 #include "paging.h"
37 /* irq0 timer */
38 #define HZ 1000
40 /* kernel attributes */
41 unsigned kernel_attr;
43 #define KERNEL_LIVE 0x01
44 #define KERNEL_18HZ 0x02
45 #define KERNEL_NOHDD 0x04
46 #define KERNEL_NOATA 0x08
47 #define KERNEL_NOFLOPPY 0x10
48 #define KERNEL_NOCDROM 0x20
51 #define CONSOLE_LOG 16
53 //#define swap8(x) ({unsigned _x:4 = (x); (((_x)>>4)&0xf) | (((_x)<<4)&0xf0); })
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 tm *realtime;
82 page_dir_t *page_cover_curr;
84 unsigned char *kbd_layout[2];
86 extern unsigned short *vesafb;
88 #define KBD_MAX_QUAUE 16
89 typedef struct
91 char key[KBD_MAX_QUAUE];
92 int p;
93 unsigned state[KBD_MAX_QUAUE];
94 } kbd_quaue;
96 /* memory vars */
97 unsigned short mem_ext;
99 /* fs directory structure */
100 struct dir {
101 char name[10];
102 int read;
103 int hidden;
104 int system;
105 int volume;
106 int dir;
107 int bin;
108 unsigned int start;
109 } dir[223];
111 unsigned char *file_cache;
113 /** externs **/
115 /* init.c */
116 extern int init ();
118 /* kmem.c */
119 extern void *malloc (unsigned size);
120 extern void *realloc(void *blk, unsigned size);
121 extern void free (void *blk);
123 extern unsigned int init_mm ();
125 /* protmem.c */
126 extern void *memcpy_to_user (void *dest, const void *src, size_t count);
127 extern void *memcpy_from_user (void *dest, const void *src, size_t count);
128 extern unsigned memtest_data (void *src, void *data, size_t offset);
130 /* console.c */
131 extern unsigned int init_console ();
132 extern void console (int i);
134 /* elf.c */
135 extern int exec_elf (unsigned char *image, unsigned *entry, unsigned *elf_data, unsigned *elf_data_off, unsigned *elf_bss);
136 extern int flush_elf ();
138 /* exec.c */
139 extern bool exec (partition_t *p, unsigned char *fi);
141 /* keyboard.c */
142 extern unsigned keyboard_setlayout (char *layout);
143 extern unsigned keyboard_getlayout (char *layout);
145 extern char getkey ();
146 extern void setkey (char key);
148 extern unsigned int init_tasks (void);
149 extern unsigned sched_lock ();
150 extern unsigned sched_unlock ();
151 extern void schedule (void);
154 extern void uptime (void);
156 /* fat.c */
157 extern void read_dir (int aa);
158 extern unsigned long read_file (int aa);
160 /* ls.c */
161 extern int ls (unsigned char* fi);
163 /* cd.c */
164 extern int cd (unsigned char* fi);
166 /* cat.c */
167 extern int cat (partition_t *p, unsigned char *fi);
169 extern int read (unsigned fd, void *buf, unsigned len);
171 /* fopen.c */
172 extern FILE *fopen (const char *filename, const char *mode);
174 /* fputs.c */
175 extern char *fgets (char *string, int n, FILE *file);
177 /* fclose.c */
178 extern int fclose (FILE *file);
180 /* keyboard.c */
181 extern unsigned int keyboard_install ();
183 /* arch depend rtc.c */
184 extern tm *rtc_getcurrtime ();
186 /* arch depend task.c */
187 extern unsigned arch_task_init (task_t *task, unsigned entry);
188 extern unsigned arch_task_set (task_t *task);
189 extern unsigned arch_task_switch (task_t *task);
191 /* arch depend arch.c */
192 extern unsigned int_enable ();
193 extern unsigned int_disable ();
194 extern unsigned init_arch ();
196 /* arch depend elf*.c */
197 extern unsigned arch_elf_detect (elf_file_t *file);
199 #endif