Ignore:
Timestamp:
Dec 20, 2009, 2:33:11 PM (10 years ago)
Author:
Jean-Yves Lamoureux
Message:
  • Total kernel rewrite
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/kernel/kernel.h

    r4148 r4154  
    22 *  libcaca      Canvas for ultrafast compositing of Unicode letters
    33 *  libcaca       Colour ASCII-Art library
    4  *  Copyright (c) 2006 Sam Hocevar <sam@hocevar.net>
     4 *  Copyright (c) 2006 Sam Hocevar <sam@zoy.org>
    55 *                All Rights Reserved
    66 *
     
    1919 */
    2020
    21 /* Various defines */
    22 #define NULL ((void *)0)
    23 #define EOF (-1)
    24 #define BUFSIZ 4096
    25 #define RAND_MAX ((unsigned int)0x8000000)
    26 #define INT_MAX ((int)0x7fffffff)
    27 #define M_PI 3.14159265358979323846
    28 #define __BYTE_ORDER 1
    29 #define __BIG_ENDIAN 2
    3021
    31 /* Assembly code for outb and inb */
    32 extern inline void outb(unsigned char val, unsigned short port);
    33 extern inline unsigned char inb(unsigned short port);
    3422
    35 extern inline void outb(unsigned char val, unsigned short port)
    36 {
    37     __asm__ __volatile__ ("outb %b0,%w1" : : "a" (val), "Nd" (port));
    38 }
    3923
    40 extern inline unsigned char inb(unsigned short port)
    41 {
    42     unsigned char tmp;
    43     __asm__ __volatile__ ("inb %w1,%0" : "=a" (tmp) : "Nd" (port));
    44     return tmp;
    45 }
     24extern void init_gdt(void);
     25void init_pic(void);
     26void init_idt(void);
     27void putcar(unsigned char c);
     28void dump_gdt(void);
    4629
    47 /* Various typedefs -- some are x86-specific */
    48 #define CUSTOM_INTTYPES
    49 typedef unsigned int size_t;
     30void disable_interrupt(char i);
     31void enable_interrupt(char i);
    5032
    51 typedef struct file
    52 {
    53     void *mem;
    54 } FILE;
    5533
    56 struct timeval {
    57     int tv_sec;
    58     int tv_usec;
    59 };
     34#define cli             __asm__("cli"::)
     35#define sti             __asm__("sti"::)
    6036
    61 struct timezone {
    62     int tz_minuteswest;
    63     int tz_dsttime;
    64 };
    6537
    66 /* Multiboot kernel entry point */
    67 void cmain(unsigned long int magic, unsigned long int addr);
    6838
    6939/* The application's entry point */
    7040int main(int argc, char *argv[]);
    7141
    72 /* stdlib.h functions */
    73 void *malloc(size_t size);
    74 void free(void *ptr);
    75 void *realloc(void *ptr, size_t size);
    76 char *getenv(const char *name);
    77 int rand(void);
    78 int abs(int j);
    79 void exit(int status);
    80 void srand(unsigned int s);
    81 int atexit(void (*function)(void));
    82 FILE *stdin, *stdout, *stderr;
    83 
    84 /* string.h functions */
    85 void *memset(void *s, int c, size_t n);
    86 void *memcpy(void *dest, const void *src, size_t n);
    87 void *memmove(void *dest, const void *src, size_t n);
    88 size_t strlen(const char *s);
    89 int strcmp(const char *s1, const char *s2);
    90 int strcasecmp(const char *s1, const char *s2);
    91 int memcmp(const void *s1, const void *s2, size_t n);
    92 char *strdup(const char *s);
    93 char *strchr(const char *s, int c);
    94 
    95 /* stdarg.h functions */
    96 typedef void * va_list;
    97 #define va_start(v,a) v = (void *)((uintptr_t)(&a) + sizeof(a))
    98 #define va_end(v)
    99 int vsnprintf(char *str, size_t size, const char *format, va_list ap);
    100 
    101 /* stdio.h functions */
    102 FILE *fopen(const char *path, const char *mode);
    103 int feof(FILE *stream);
    104 char *fgets(char *s, int size, FILE *stream);
    105 size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);
    106 int fclose(FILE *fp);
    107 int printf(const char *format, ...);
    108 int fprintf(FILE *stream, const char *format, ...);
    109 int fflush(FILE *stream);
    110 int sprintf(char *str, const char *format, ...);
    111 int sscanf(const char *str, const char *format, ...);
    112 
    113 /* unistd.h functions */
    114 void usleep(unsigned long usec);
    115 int getpid(void);
    116 
    117 /* time.h functions */
    118 int gettimeofday(struct timeval *tv, struct timezone *tz);
    119 int time(void *);
    120 
    121 /* math.h functions */
    122 double cos(double x);
    123 double sin(double x);
    124 double sqrt(double x);
    125 
    126 /* errno.h functions */
    127 #define ENOENT   2 /* No such file or directory */
    128 #define ENOMEM  12 /* Out of memory */
    129 #define EBUSY   16 /* Device or resource busy */
    130 #define ENODEV  19 /* No such device */
    131 #define EINVAL  22 /* Invalid argument */
    132 #define ENOTTY  25 /* Not a typewriter */
    133 #define ENOSYS  38 /* Function not implemented */
    134 extern int errno;
    135 
    136 /* arpa/inet.h functions */
    137 unsigned int htonl(unsigned int hostlong);
    138 unsigned short htons(unsigned short hostlong);
    139 
Note: See TracChangeset for help on using the changeset viewer.