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"
35 #include "../drivers/char/video/video.h"
42 /* kernel attributes */
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); })
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
;
80 page_dir_t
*page_cover_curr
;
82 unsigned char *kbd_layout
[2];
84 extern unsigned short *vesafb
;
86 #define KBD_MAX_QUAUE 16
89 char key
[KBD_MAX_QUAUE
];
91 //unsigned char state[KBD_MAX_QUAUE];
95 unsigned short mem_ext
;
97 /* fs directory structure */
109 unsigned char *file_cache
;
110 unsigned long file_cache_id
;
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 ();
128 extern void *pmalloc (size_t size
);
129 extern void pfree (void *blk
);
130 extern void *palign (void *p
);
133 extern void *swmalloc (unsigned size
);
134 extern unsigned swfree (void *ptr
, unsigned size
);
135 extern unsigned int swmem_init ();
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
);
143 extern unsigned int init_console ();
144 extern void console (int i
);
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 ();
151 extern bool exec (partition_t
*p
, unsigned char *fi
);
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);
166 extern unsigned char vgagui
;
168 extern void uptime (void);
171 extern unsigned read_dir (int aa
);
172 extern unsigned long read_file (int aa
);
175 extern int ls (unsigned char *fi
);
178 extern int cd (unsigned char *fi
);
181 extern int cp (unsigned char *fi
, unsigned char *fo
);
184 extern int cat (unsigned char *fi
);
187 extern int read (unsigned fd
, void *buf
, unsigned len
);
190 extern FILE *fopen (const char *filename
, const char *mode
);
193 extern char *fgets (char *string
, int n
, FILE *file
);
196 extern int fclose (FILE *file
);
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
);