Changeset 1048


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
Files:
31 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/caca/driver_vga.c

    r1006 r1048  
    134134}
    135135
    136 static int vga_get_event(caca_display_t *dp, caca_event-t *ev)
     136static int vga_get_event(caca_display_t *dp, caca_event_t *ev)
    137137{
    138138    /* FIXME */
  • libcaca/trunk/common.h

    r865 r1048  
    1818 */
    1919
    20 #if defined(HAVE_INTTYPES_H)
     20#if defined(HAVE_INTTYPES_H) && !defined(__KERNEL__)
    2121#   include <inttypes.h>
    2222#else
     
    7070#endif
    7171
     72#if defined(__KERNEL__)
     73#undef HAVE_ERRNO_H
     74#endif
  • libcaca/trunk/configure.ac

    r1021 r1048  
    210210  ac_cv_my_have_vga="yes"
    211211  CPPFLAGS="${CPPFLAGS} -I. -D__KERNEL__ -nostdinc -include kernel/kernel.h"
    212   CFLAGS="${CFLAGS} -fno-builtin -O2 -Wall"
     212  CFLAGS="${CFLAGS} -fno-builtin -O2 -Wall -I../kernel/"
    213213  CCASFLAGS="${CCASFLAGS} -I."
    214   LDFLAGS="${LDFLAGS} -nostdlib -Wl,-N -Wl,-Ttext -Wl,100000"
     214  LDFLAGS="${LDFLAGS} -nostdlib -Wl,-N -Wl,-Ttext -Wl,100000 "
    215215  AC_DEFINE(USE_VGA, 1, Define to 1 to activate the VGA backend driver)
    216216  CACA_DRIVERS="${CACA_DRIVERS} vga"
     
    225225  AC_MSG_RESULT([${CACA_DRIVERS}])
    226226fi
     227
    227228
    228229AC_SUBST(MATH_LIBS)
  • libcaca/trunk/cucul/buffer.c

    r896 r1048  
    6363 *          if an error occurred.
    6464 */
     65#if !defined(__KERNEL__)
    6566cucul_buffer_t *cucul_load_file(char const *file)
    6667{
     
    99100    return buf;
    100101}
    101 
     102#endif
    102103/** \brief Get the buffer size.
    103104 *
  • libcaca/trunk/cucul/cucul.c

    r1022 r1048  
    9999    if(ret < 0)
    100100    {
    101 #if defined(HAVE_ERRNO_H)
     101#if defined(HAVE_ERRNO_H) && !defined(__KERNEL__)
    102102        int saved_errno = errno;
    103103#endif
     
    105105        free(cv->allchars);
    106106        free(cv);
    107 #if defined(HAVE_ERRNO_H)
     107#if defined(HAVE_ERRNO_H) && !defined(__KERNEL__)
    108108        errno = saved_errno;
    109109#endif
     
    117117
    118118nomem:
    119 #if defined(HAVE_ERRNO_H)
     119#if defined(HAVE_ERRNO_H) && !defined(__KERNEL__)
    120120    errno = ENOMEM;
    121121#endif
     
    153153    if(cv->refcount)
    154154    {
    155 #if defined(HAVE_ERRNO_H)
     155#if defined(HAVE_ERRNO_H) && !defined(__KERNEL__)
    156156        errno = EBUSY;
    157157#endif
     
    247247    if(cv->refcount)
    248248    {
    249 #if defined(HAVE_ERRNO_H)
     249#if defined(HAVE_ERRNO_H) && !defined(__KERNEL__)
    250250        errno = EBUSY;
    251251#endif
     
    317317            if(!cv->allchars[f] || !cv->allattr[f])
    318318            {
    319 #if defined(HAVE_ERRNO_H)
     319#if defined(HAVE_ERRNO_H) && !defined(__KERNEL__)
    320320                errno = ENOMEM;
    321321#endif
     
    406406            if(!cv->allchars[f] || !cv->allattr[f])
    407407            {
    408 #if defined(HAVE_ERRNO_H)
     408#if defined(HAVE_ERRNO_H) && !defined(__KERNEL__)
    409409                errno = ENOMEM;
    410410#endif
  • 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_ */
  • libcaca/trunk/src/Makefile.am

    r1023 r1048  
    4747fcntl_programs =
    4848endif
    49 
  • libcaca/trunk/src/cacadraw.c

    r945 r1048  
    1515#include "common.h"
    1616
    17 #include <stdio.h>
    18 #include <string.h>
    19 #include <stdlib.h>
     17#if !defined(__KERNEL__)
     18#   include <stdio.h>
     19#   include <string.h>
     20#   include <stdlib.h>
     21#endif
    2022
    2123#include "cucul.h"
  • libcaca/trunk/src/cacaplay.c

    r896 r1048  
    1515#include "common.h"
    1616
    17 #include <stdio.h>
    18 #include <stdlib.h>
     17#if !defined(__KERNEL__)
     18  #include <stdio.h>
     19  #include <stdlib.h>
     20#endif
    1921
    2022#include "cucul.h"
  • libcaca/trunk/src/cacaview.c

    r859 r1048  
    1515#include "common.h"
    1616
     17#if !defined(__KERNEL__)
    1718#include <stdio.h>
    1819#include <string.h>
    1920#include <stdlib.h>
     21#endif
    2022
    2123#if defined(HAVE_SLEEP)
  • libcaca/trunk/src/common-image.c

    r859 r1048  
    1515#include "common.h"
    1616
    17 #include <stdio.h>
    18 #include <string.h>
    19 #include <stdlib.h>
     17#if !defined(__KERNEL__)
     18#   include <stdio.h>
     19#   include <string.h>
     20#   include <stdlib.h>
     21#endif
    2022
    2123#if defined(HAVE_IMLIB2_H)
    2224#   include <Imlib2.h>
    2325#else
    24 #   include <stdio.h>
     26#   if !defined(__KERNEL__)
     27#      include <stdio.h>
     28#   endif
    2529#endif
    2630
  • libcaca/trunk/src/img2irc.c

    r859 r1048  
    1515#include "common.h"
    1616
    17 #include <stdio.h>
     17#if !defined(__KERNEL__)
     18#   include <stdio.h>
    1819#include <string.h>
    1920#include <stdlib.h>
     21#   endif
    2022
    2123#include "cucul.h"
  • libcaca/trunk/test/demo.c

    r964 r1048  
    1414#include "config.h"
    1515#include "common.h"
    16 
    17 #include <math.h>
    18 #include <string.h>
    19 #include <stdio.h>
    20 
     16#if !defined(__KERNEL__)
     17#   include <math.h>
     18#   include <string.h>
     19#   include <stdio.h>
     20#endif
    2121#include "caca.h"
    2222
  • libcaca/trunk/test/demo0.c

    r1019 r1048  
    2424#include "config.h"
    2525
    26 #include <math.h>
    27 #include <string.h>
    28 #include <stdio.h>
     26#if !defined(__KERNEL__)
     27#   include <math.h>
     28#   include <string.h>
     29#   include <stdio.h>
     30#endif
    2931
    3032#include "caca0.h"
  • libcaca/trunk/test/dithering.c

    r859 r1048  
    1515#include "common.h"
    1616
    17 #include <stdio.h>
     17#if !defined(__KERNEL__)
     18#   include <stdio.h>
     19#endif
    1820
    1921#include "cucul.h"
     
    3638char density[] = " ',+:;o&%w$W@#";
    3739
    38 int main(void)
     40int main(int argc, char *argv[])
    3941{
    4042    cucul_canvas_t *cv;
  • libcaca/trunk/test/event.c

    r898 r1048  
    1414#include "config.h"
    1515#include "common.h"
    16 
    17 #include <stdio.h>
    18 #include <string.h>
    19 #include <stdlib.h>
     16#if !defined(__KERNEL__)
     17#   include <stdio.h>
     18#   include <string.h>
     19#   include <stdlib.h>
     20#endif
    2021
    2122#include "cucul.h"
  • libcaca/trunk/test/export.c

    r1012 r1048  
    1515#include "common.h"
    1616
    17 #if defined(HAVE_INTTYPES_H)
    18 #   include <inttypes.h>
     17#if !defined(__KERNEL__)
     18#   if defined(HAVE_INTTYPES_H)
     19#      include <inttypes.h>
     20#   endif
     21#   include <stdio.h>
     22#   include <stdlib.h>
     23#   include <string.h>
    1924#endif
    20 
    21 #include <stdio.h>
    22 #include <stdlib.h>
    23 #include <string.h>
    2425
    2526#include "cucul.h"
  • libcaca/trunk/test/font.c

    r942 r1048  
    1515#include "common.h"
    1616
    17 #if defined(HAVE_INTTYPES_H)
    18 #   include <inttypes.h>
     17#if !defined(__KERNEL__)
     18#   if defined(HAVE_INTTYPES_H)
     19#      include <inttypes.h>
     20#   endif
     21
     22#   if defined(HAVE_ENDIAN_H)
     23#      include <endian.h>
     24#   endif
     25
     26#   include <stdio.h>
     27#   include <stdlib.h>
     28#   include <string.h>
    1929#endif
    20 
    21 #if defined(HAVE_ENDIAN_H)
    22 #   include <endian.h>
    23 #endif
    24 
    25 #include <stdio.h>
    26 #include <stdlib.h>
    27 #include <string.h>
    2830
    2931#include "cucul.h"
  • libcaca/trunk/test/font2tga.c

    r959 r1048  
    1515#include "common.h"
    1616
    17 #if defined(HAVE_INTTYPES_H)
    18 #   include <inttypes.h>
     17#if !defined(__KERNEL__)
     18#   if defined(HAVE_INTTYPES_H)
     19#      include <inttypes.h>
     20#   endif
     21#   include <stdio.h>
     22#   include <stdlib.h>
    1923#endif
    20 
    21 #include <stdio.h>
    22 #include <stdlib.h>
    2324
    2425#include "cucul.h"
  • libcaca/trunk/test/frames.c

    r964 r1048  
    1414#include "config.h"
    1515#include "common.h"
     16#if !defined(__KERNEL__)
     17#   if defined(HAVE_INTTYPES_H)
     18#      include <inttypes.h>
     19#   endif
    1620
    17 #if defined(HAVE_INTTYPES_H)
    18 #   include <inttypes.h>
     21#   include <stdio.h>
    1922#endif
    20 
    21 #include <stdio.h>
    22 
    2323#include "cucul.h"
    2424#include "caca.h"
    2525
    26 int main(void)
     26int main(int argc, char *argv[])
    2727{
    2828    cucul_canvas_t *cv;
  • libcaca/trunk/test/gamma.c

    r1031 r1048  
    1515#include "common.h"
    1616
    17 #if defined(HAVE_INTTYPES_H)
    18 #   include <inttypes.h>
    19 #endif
    20 
    2117#if !defined(__KERNEL__)
     18#   if defined(HAVE_INTTYPES_H)
     19#      include <inttypes.h>
     20#   endif
    2221#   include <stdio.h>
    2322#   include <math.h>
     
    2928uint32_t buffer[256 * 4];
    3029
    31 int main(void)
     30int main(int argc, char *argv[])
    3231{
    3332    caca_event_t ev;
  • libcaca/trunk/test/hsv.c

    r858 r1048  
    1515#include "common.h"
    1616
    17 #if defined(HAVE_INTTYPES_H)
    18 #   include <inttypes.h>
     17#if !defined(__KERNEL__)
     18#   if defined(HAVE_INTTYPES_H)
     19#      include <inttypes.h>
     20#   endif
     21#   include <stdio.h>
    1922#endif
    20 
    21 #include <stdio.h>
    2223
    2324#include "cucul.h"
     
    2627uint32_t buffer[256*256];
    2728
    28 int main(void)
     29int main(int argc, char *argv[])
    2930{
    3031    cucul_canvas_t *cv;
  • libcaca/trunk/test/import.c

    r903 r1048  
    1515#include "common.h"
    1616
    17 #if defined(HAVE_INTTYPES_H)
    18 #   include <inttypes.h>
     17
     18#if !defined(__KERNEL__)
     19#   if defined(HAVE_INTTYPES_H)
     20#      include <inttypes.h>
     21#   endif
     22#   include <stdio.h>
     23#   include <stdlib.h>
    1924#endif
    2025
    21 #include <stdio.h>
    22 #include <stdlib.h>
    2326
    2427#include "cucul.h"
  • libcaca/trunk/test/input.c

    r980 r1048  
    1515#include "common.h"
    1616
    17 #if defined(HAVE_INTTYPES_H)
     17#if !defined(__KERNEL__)
     18#   if defined(HAVE_INTTYPES_H)
    1819#   include <inttypes.h>
     20#   endif
     21#   include <string.h>
    1922#endif
    20 
    21 #include <string.h>
    2223
    2324#include "cucul.h"
     
    3334} textentry;
    3435
    35 int main(void)
     36int main(int argc, char *argv[])
    3637{
    3738    textentry entries[TEXT_ENTRIES];
  • libcaca/trunk/test/spritedit.c

    r859 r1048  
    1414#include "config.h"
    1515#include "common.h"
    16 
    17 #include <stdio.h>
    18 
     16#if !defined(__KERNEL__)
     17#   include <stdio.h>
     18#endif
    1919#include "cucul.h"
    2020#include "caca.h"
  • libcaca/trunk/test/text.c

    r942 r1048  
    1414#include "config.h"
    1515#include "common.h"
    16 
    17 #if defined(HAVE_INTTYPES_H)
    18 #   include <inttypes.h>
     16#if !defined(__KERNEL__)
     17#   if defined(HAVE_INTTYPES_H)
     18#      include <inttypes.h>
     19#   endif
     20#   include <stdio.h>
     21#   include <string.h>
    1922#endif
    20 
    21 #include <stdio.h>
    22 #include <string.h>
    23 
    2423#include "cucul.h"
    2524
     
    3231  "   `----'   \n"
    3332
    34 int main(void)
     33int main(int argc, char *argv[])
    3534{
    3635    cucul_canvas_t *cv;
  • libcaca/trunk/test/transform.c

    r858 r1048  
    1414#include "config.h"
    1515#include "common.h"
    16 
    17 #if defined(HAVE_INTTYPES_H)
    18 #   include <inttypes.h>
     16#if !defined(__KERNEL__)
     17#   if defined(HAVE_INTTYPES_H)
     18#      include <inttypes.h>
     19#   endif
     20#   include <stdio.h>
    1921#endif
    20 
    21 #include <stdio.h>
    2222
    2323#include "cucul.h"
     
    4545};
    4646
    47 int main(void)
     47int main(int argc, char *argv[])
    4848{
    4949    cucul_canvas_t *cv, *normal, *flip, *flop, *rotate;
  • libcaca/trunk/test/truecolor.c

    r858 r1048  
    1515#include "common.h"
    1616
    17 #if defined(HAVE_INTTYPES_H)
    18 #   include <inttypes.h>
     17#if !defined(__KERNEL__)
     18#   if defined(HAVE_INTTYPES_H)
     19#      include <inttypes.h>
     20#   endif
     21#   include <stdio.h>
    1922#endif
    20 
    21 #include <stdio.h>
    2223
    2324#include "cucul.h"
    2425#include "caca.h"
    2526
    26 int main(void)
     27int main(int argc, char *argv[])
    2728{
    2829    cucul_canvas_t *cv;
  • libcaca/trunk/test/unicode.c

    r858 r1048  
    1515#include "common.h"
    1616
    17 #if defined(HAVE_INTTYPES_H)
    18 #   include <inttypes.h>
     17#if !defined(__KERNEL__)
     18#   if defined(HAVE_INTTYPES_H)
     19#      include <inttypes.h>
     20#   endif
     21#   include <stdio.h>
    1922#endif
    20 
    21 #include <stdio.h>
    2223
    2324#include "cucul.h"
    2425#include "caca.h"
    2526
    26 int main(void)
     27int main(int argc, char *argv[])
    2728{
    2829    cucul_canvas_t *cv;
  • libcaca/trunk/tools/optipal.c

    r859 r1048  
    1515#include "common.h"
    1616
    17 #include <stdio.h>
     17#if !defined(__KERNEL__)
     18#   include <stdio.h>
     19#endif
    1820
    1921#include "cucul.h" /* Only necessary for CUCUL_* macros */
     
    4547    while(0);
    4648
    47 int main(void)
     49int main(int argc, char *argv[])
    4850{
    4951    int i;
Note: See TracChangeset for help on using the changeset viewer.