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/>.
29 #include "partition.h"
33 #include "../drivers/char/video/video.h"
40 /* kernel attributes */
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); })
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
76 partition_t
*curr_part
;
78 unsigned int fd_count
;
82 page_dir_t
*page_cover_curr
;
84 unsigned char *kbd_layout
[2];
86 extern unsigned short *vesafb
;
88 #define KBD_MAX_QUAUE 16
91 char key
[KBD_MAX_QUAUE
];
93 unsigned state
[KBD_MAX_QUAUE
];
97 unsigned short mem_ext
;
99 /* fs directory structure */
111 unsigned char *file_cache
;
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 ();
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
);
131 extern unsigned int init_console ();
132 extern void console (int i
);
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 ();
139 extern bool exec (partition_t
*p
, unsigned char *fi
);
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);
157 extern void read_dir (int aa
);
158 extern unsigned long read_file (int aa
);
161 extern int ls (unsigned char* fi
);
164 extern int cd (unsigned char* fi
);
167 extern int cat (partition_t
*p
, unsigned char *fi
);
169 extern int read (unsigned fd
, void *buf
, unsigned len
);
172 extern FILE *fopen (const char *filename
, const char *mode
);
175 extern char *fgets (char *string
, int n
, FILE *file
);
178 extern int fclose (FILE *file
);
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
);