Ignore:
Timestamp:
Sep 17, 2006, 2:44:18 PM (13 years ago)
Author:
Jean-Yves Lamoureux
Message:
  • Updated kernel 'driver', still not working, but most of the work is done
Location:
libcaca/trunk/kernel
Files:
2 edited

Legend:

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

    r944 r1048  
    3030#define LOWER(x) (IS_UPPER(x)?(x-('a'-'A')):x)
    3131
     32/* Our default seed for random number generator */
     33static int seed = 0x68743284;
     34
    3235/* Our memory mapping */
    3336static uint32_t *freemem = (uint32_t*) 0x00200000;
     
    9598}
    9699
     100int getpid(void)
     101{
     102    return 0x1337;
     103}
     104
     105void srand(unsigned int s)
     106{
     107    seed = rand();
     108}
     109
     110int time(void *dummy)
     111{
     112    return rand();
     113}
     114
    97115int rand(void)
    98116{
    99     static int seed = 0x68743284;
    100117    seed = (seed * 0x7f32ba17) ^ 0xf893a735;
    101118    return seed % RAND_MAX;
     
    158175}
    159176
     177int memcmp(const char *s1, const char *s2, size_t n)
     178{
     179    while(n) {
     180        if(*s1 != *s2) return *s1-*s2;
     181        *s1++;
     182        *s2++;
     183        n--;
     184    }
     185    return 0;
     186}
     187
     188
    160189/* stdarg.h functions */
    161190int vsnprintf(char *str, size_t size, const char *format, va_list ap)
     
    182211    /* FIXME */
    183212    return NULL;
     213}
     214
     215size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream)
     216{
     217    return 0;
    184218}
    185219
     
    299333}
    300334
     335
     336/* XXX FIXME Converts only from little endian to big endian (x86) */
     337unsigned int htonl(unsigned int hostlong)
     338{
     339    return ((hostlong&0xFFFF0000)>>16)|((hostlong&0x0000FFFFFF)<<16);
     340}
     341
     342/* XXX FIXME Converts only from little endian to big endian (x86) */
     343unsigned short htons(unsigned short hostlong)
     344{
     345    return ((hostlong&0xFF00)>>8)|((hostlong&0x00FF)<<8);
     346}
     347
     348
     349
    301350#endif /* __KERNEL__ */
  • libcaca/trunk/kernel/kernel.h

    r769 r1048  
    1818 */
    1919
     20#ifndef __KERNEL_H_
     21#define __KERNEL_H_
    2022/* Various defines */
    2123#define NULL ((void *)0)
     
    4547/* Various typedefs -- some are x86-specific */
    4648#define CUSTOM_INTTYPES
    47 typedef unsigned char uint8_t;
    48 typedef unsigned short uint16_t;
    49 typedef unsigned long int uint32_t;
    50 typedef long int intptr_t;
    51 typedef long unsigned int uintptr_t;
    52 
    5349typedef unsigned int size_t;
    5450
     
    8278int abs(int j);
    8379void exit(int status);
     80void srand(unsigned int s);
     81int stdint;
     82int stdout;
     83int stderr;
    8484
    8585/* string.h functions */
     
    8888size_t strlen(const char *s);
    8989int strcasecmp(const char *s1, const char *s2);
    90 
     90int memcmp(const char *s1, const char *s2, size_t n);
    9191/* stdarg.h functions */
    9292typedef void * va_list;
     
    9999int feof(FILE *stream);
    100100char *fgets(char *s, int size, FILE *stream);
     101size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);
    101102int fclose(FILE *fp);
    102103int printf(const char *format, ...);
     
    106107/* unistd.h functions */
    107108void usleep(unsigned long usec);
     109int getpid(void);
     110
    108111
    109112/* time.h functions */
    110113int gettimeofday(struct timeval *tv, struct timezone *tz);
     114int time(void *);
    111115
    112116/* math.h functions */
     
    115119double sqrt(double x);
    116120
     121/* arpa/inet.h functions */
     122unsigned int htonl(unsigned int hostlong);
     123unsigned short htons(unsigned short hostlong);
     124
     125#endif /* __KERNEL_H_ */
Note: See TracChangeset for help on using the changeset viewer.