Created
November 7, 2009 01:36
-
-
Save ldunn/228440 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* krnllib.c for Dux */ | |
| #include <stdint.h> | |
| void puts ( char *str ) | |
| { | |
| // Call syscall 0 (printk) with str as the arg | |
| __asm__ __volatile__ (" \ | |
| mov $0, %%eax; \ | |
| mov %0, %%ebx; \ | |
| int $0x80; \ | |
| " : : "m" (str) : "eax", "ebx"); | |
| } | |
| void puthex ( uint32_t num ) | |
| { | |
| __asm__ __volatile__ (" \ | |
| mov $1, %%eax; \ | |
| mov %0, %%ebx; \ | |
| int $0x80; \ | |
| " : : "m" (num) : "eax", "ebx"); | |
| } | |
| void putdec ( uint32_t num ) | |
| { | |
| __asm__ __volatile__ (" \ | |
| mov $2, %%eax; \ | |
| mov %0, %%ebx; \ | |
| int $0x80; \ | |
| " : : "m" (num) : "eax", "ebx"); | |
| } | |
| void shutdown () | |
| { | |
| __asm__ __volatile__ (" \ | |
| mov $3, %%eax; \ | |
| int $0x80; \ | |
| " : : : "eax"); | |
| } | |
| void reboot () | |
| { | |
| __asm__ __volatile__ (" \ | |
| mov $4, %%eax; \ | |
| int $0x80; \ | |
| " : : : "eax"); | |
| } | |
| void clear_screen () | |
| { | |
| __asm__ __volatile__ (" \ | |
| mov $5, %%eax; \ | |
| int $0x80; \ | |
| " : : : "eax"); | |
| } | |
| void malloc (unsigned int size, unsigned int flags) | |
| { | |
| __asm__ __volatile__ (" \ | |
| mov $6, %%eax; \ | |
| int $0x80; \ | |
| " : : "m" (size), "m" (flags) : "eax", "ebx", "ecx"); | |
| __asm__ __volatile__ (" \ | |
| mov $6, %%eax; \ | |
| mov %0, %%ebx; \ | |
| mov %1, %%ecx; \ | |
| int $0x80; \ | |
| " : : "m" (size), "m" (flags) : "eax", "ebx", "ecx"); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment