kernel

hobby kernel
git clone git://git.evenfri.xyz/kernel.git
Log | Files | Refs | README | LICENSE

fns.h (1543B)


      1 #ifndef fns_h
      2 #define fns_h
      3 
      4 #include <stdint.h>
      5 #include <stddef.h>
      6 
      7 #include <dat.h>
      8 
      9 /* input/output ports */
     10 static inline void io_wait() {
     11   asm volatile ("outb %%al, $0x80" : : "a"(0));
     12 }
     13 
     14 static inline void outb(uint16_t port, uint8_t val) {
     15   asm volatile ("outb %0, %1" : : "a"(val), "Nd"(port));
     16 }
     17 
     18 static inline uint8_t inb(uint16_t port) {
     19   uint8_t ret;
     20   asm volatile ("inb %1, %0" : "=a"(ret) : "Nd"(port));
     21   return ret;
     22 }
     23 
     24 /* string */
     25 size_t strlen(const char* str);
     26 
     27 /* stdio */
     28 int printk(const char* restrict format, ...);
     29 
     30 /* vga */
     31 static inline uint8_t vga_entry_color(enum vga_color fg, enum vga_color bg) {
     32 	return fg | bg << 4;
     33 }
     34 
     35 static inline uint16_t vga_entry(unsigned char uc, uint8_t color) {
     36 	return (uint16_t) uc | (uint16_t) color << 8;
     37 }
     38 
     39 /* vga cursor */
     40 void vga_cursor_enable(uint8_t s, uint8_t e);
     41 void vga_cursor_disable(void);
     42 void vga_cursor_update(int x, int y);
     43 uint16_t vga_cursor_get_pos(void);
     44 
     45 /* gdt */
     46 extern void gdt_init(void);
     47 
     48 /* idt */
     49 void idt_register(unsigned char vec, int_handler handler);
     50 void idt_init(void);
     51 
     52 /* tty */
     53 void tty_init(void);
     54 void tty_set_color(uint8_t color);
     55 void tty_clear(void);
     56 void tty_putchar(char c);
     57 void tty_write(const char* data, size_t size);
     58 
     59 /* vfs */
     60 size_t vfs_read(unsigned int fd, void *buf, size_t size);
     61 size_t vfs_write(unsigned int fd, void *buf, size_t size);
     62 
     63 /* syscall */
     64 void syscall_init();
     65 
     66 /* pit */
     67 void pit_init(uint32_t freq);
     68 void pit_sleep(uint32_t ticks_to_wait);
     69 
     70 /* panic */
     71 void kpanic(const char *msg);
     72 
     73 #endif /* fns_h */