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/>.
30 #include "partition.h"
34 #include "../drivers/char/video/video.h"
41 /* kernel attributes */
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); })
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
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
88 char key
[KBD_MAX_QUAUE
];
90 //unsigned char state[KBD_MAX_QUAUE];
94 unsigned short mem_ext
;
96 /* fs directory structure */
108 unsigned char *file_cache
;
109 unsigned long file_cache_id
;
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 ();
127 extern void *pmalloc (size_t size
);
128 extern void pfree (void *blk
);
129 extern void *palign (void *p
);
132 extern void *swmalloc (unsigned size
);
133 extern unsigned swfree (void *ptr
, unsigned size
);
134 extern unsigned int swmem_init ();
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
);
142 extern unsigned int init_console ();
143 extern void console (int i
);
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 ();
150 extern bool exec (partition_t
*p
, unsigned char *fi
);
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);
165 extern unsigned char vgagui
;
167 extern void uptime (void);
170 extern unsigned read_dir (int aa
);
171 extern unsigned long read_file (int aa
);
174 extern int ls (unsigned char *fi
);
177 extern int cd (unsigned char *fi
);
180 extern int cp (unsigned char *fi
, unsigned char *fo
);
183 extern int cat (unsigned char *fi
);
186 extern int read (unsigned fd
, void *buf
, unsigned len
);
189 extern FILE *fopen (const char *filename
, const char *mode
);
192 extern char *fgets (char *string
, int n
, FILE *file
);
195 extern int fclose (FILE *file
);
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
);