Przeglądaj źródła

* Updated kernel 'driver', still not working, but most of the work is done

tags/v0.99.beta14
Jean-Yves Lamoureux jylam 18 lat temu
rodzic
commit
1b821e2588
31 zmienionych plików z 209 dodań i 119 usunięć
  1. +1
    -1
      caca/driver_vga.c
  2. +4
    -1
      common.h
  3. +3
    -2
      configure.ac
  4. +2
    -1
      cucul/buffer.c
  5. +7
    -7
      cucul/cucul.c
  6. +50
    -1
      kernel/kernel.c
  7. +16
    -7
      kernel/kernel.h
  8. +0
    -1
      src/Makefile.am
  9. +5
    -3
      src/cacadraw.c
  10. +4
    -2
      src/cacaplay.c
  11. +2
    -0
      src/cacaview.c
  12. +8
    -4
      src/common-image.c
  13. +3
    -1
      src/img2irc.c
  14. +5
    -5
      test/demo.c
  15. +5
    -3
      test/demo0.c
  16. +4
    -2
      test/dithering.c
  17. +5
    -4
      test/event.c
  18. +7
    -6
      test/export.c
  19. +12
    -10
      test/font.c
  20. +6
    -5
      test/font2tga.c
  21. +6
    -6
      test/frames.c
  22. +4
    -5
      test/gamma.c
  23. +6
    -5
      test/hsv.c
  24. +7
    -4
      test/import.c
  25. +5
    -4
      test/input.c
  26. +3
    -3
      test/spritedit.c
  27. +7
    -8
      test/text.c
  28. +6
    -6
      test/transform.c
  29. +6
    -5
      test/truecolor.c
  30. +6
    -5
      test/unicode.c
  31. +4
    -2
      tools/optipal.c

+ 1
- 1
caca/driver_vga.c Wyświetl plik

@@ -133,7 +133,7 @@ static void vga_handle_resize(caca_display_t *dp)
dp->resize.h = dp->cv->height;
}

static int vga_get_event(caca_display_t *dp, caca_event-t *ev)
static int vga_get_event(caca_display_t *dp, caca_event_t *ev)
{
/* FIXME */
ev->type = CACA_EVENT_NONE;


+ 4
- 1
common.h Wyświetl plik

@@ -17,7 +17,7 @@
* function prototypes that are sometimes missing.
*/

#if defined(HAVE_INTTYPES_H)
#if defined(HAVE_INTTYPES_H) && !defined(__KERNEL__)
# include <inttypes.h>
#else
typedef signed char int8_t;
@@ -69,3 +69,6 @@ static inline uint32_t hton32(uint32_t x)
}
#endif

#if defined(__KERNEL__)
#undef HAVE_ERRNO_H
#endif

+ 3
- 2
configure.ac Wyświetl plik

@@ -209,9 +209,9 @@ fi
if test "${enable_vga}" = "yes"; then
ac_cv_my_have_vga="yes"
CPPFLAGS="${CPPFLAGS} -I. -D__KERNEL__ -nostdinc -include kernel/kernel.h"
CFLAGS="${CFLAGS} -fno-builtin -O2 -Wall"
CFLAGS="${CFLAGS} -fno-builtin -O2 -Wall -I../kernel/"
CCASFLAGS="${CCASFLAGS} -I."
LDFLAGS="${LDFLAGS} -nostdlib -Wl,-N -Wl,-Ttext -Wl,100000"
LDFLAGS="${LDFLAGS} -nostdlib -Wl,-N -Wl,-Ttext -Wl,100000 "
AC_DEFINE(USE_VGA, 1, Define to 1 to activate the VGA backend driver)
CACA_DRIVERS="${CACA_DRIVERS} vga"
fi
@@ -225,6 +225,7 @@ else
AC_MSG_RESULT([${CACA_DRIVERS}])
fi


AC_SUBST(MATH_LIBS)
AC_SUBST(CACA_LIBS)



+ 2
- 1
cucul/buffer.c Wyświetl plik

@@ -62,6 +62,7 @@ cucul_buffer_t *cucul_load_memory(void *data, unsigned long int size)
* \return A \e libcucul buffer containing the file's contents, or NULL
* if an error occurred.
*/
#if !defined(__KERNEL__)
cucul_buffer_t *cucul_load_file(char const *file)
{
cucul_buffer_t *buf;
@@ -98,7 +99,7 @@ cucul_buffer_t *cucul_load_file(char const *file)

return buf;
}
#endif
/** \brief Get the buffer size.
*
* This function returns the length (in bytes) of the memory area stored


+ 7
- 7
cucul/cucul.c Wyświetl plik

@@ -98,13 +98,13 @@ cucul_canvas_t * cucul_create_canvas(unsigned int width, unsigned int height)

if(ret < 0)
{
#if defined(HAVE_ERRNO_H)
#if defined(HAVE_ERRNO_H) && !defined(__KERNEL__)
int saved_errno = errno;
#endif
free(cv->allattr);
free(cv->allchars);
free(cv);
#if defined(HAVE_ERRNO_H)
#if defined(HAVE_ERRNO_H) && !defined(__KERNEL__)
errno = saved_errno;
#endif
return NULL;
@@ -116,7 +116,7 @@ cucul_canvas_t * cucul_create_canvas(unsigned int width, unsigned int height)
return cv;

nomem:
#if defined(HAVE_ERRNO_H)
#if defined(HAVE_ERRNO_H) && !defined(__KERNEL__)
errno = ENOMEM;
#endif
return NULL;
@@ -152,7 +152,7 @@ int cucul_set_canvas_size(cucul_canvas_t *cv, unsigned int width,
{
if(cv->refcount)
{
#if defined(HAVE_ERRNO_H)
#if defined(HAVE_ERRNO_H) && !defined(__KERNEL__)
errno = EBUSY;
#endif
return -1;
@@ -246,7 +246,7 @@ int cucul_free_canvas(cucul_canvas_t *cv)

if(cv->refcount)
{
#if defined(HAVE_ERRNO_H)
#if defined(HAVE_ERRNO_H) && !defined(__KERNEL__)
errno = EBUSY;
#endif
return -1;
@@ -316,7 +316,7 @@ int _cucul_set_canvas_size(cucul_canvas_t *cv, unsigned int width,
new_size * sizeof(uint32_t));
if(!cv->allchars[f] || !cv->allattr[f])
{
#if defined(HAVE_ERRNO_H)
#if defined(HAVE_ERRNO_H) && !defined(__KERNEL__)
errno = ENOMEM;
#endif
return -1;
@@ -405,7 +405,7 @@ int _cucul_set_canvas_size(cucul_canvas_t *cv, unsigned int width,
new_size * sizeof(uint32_t));
if(!cv->allchars[f] || !cv->allattr[f])
{
#if defined(HAVE_ERRNO_H)
#if defined(HAVE_ERRNO_H) && !defined(__KERNEL__)
errno = ENOMEM;
#endif
return -1;


+ 50
- 1
kernel/kernel.c Wyświetl plik

@@ -29,6 +29,9 @@
#define UPPER(x) (IS_LOWER(x)?(x+('A'-'a')):x)
#define LOWER(x) (IS_UPPER(x)?(x-('a'-'A')):x)

/* Our default seed for random number generator */
static int seed = 0x68743284;

/* Our memory mapping */
static uint32_t *freemem = (uint32_t*) 0x00200000;

@@ -94,9 +97,23 @@ char *getenv(const char *name)
return NULL;
}

int getpid(void)
{
return 0x1337;
}

void srand(unsigned int s)
{
seed = rand();
}

int time(void *dummy)
{
return rand();
}

int rand(void)
{
static int seed = 0x68743284;
seed = (seed * 0x7f32ba17) ^ 0xf893a735;
return seed % RAND_MAX;
}
@@ -157,6 +174,18 @@ int strcasecmp(const char *s1, const char *s2)
return (int)UPPER(*s1) - (int)UPPER(*s2);
}

int memcmp(const char *s1, const char *s2, size_t n)
{
while(n) {
if(*s1 != *s2) return *s1-*s2;
*s1++;
*s2++;
n--;
}
return 0;
}


/* stdarg.h functions */
int vsnprintf(char *str, size_t size, const char *format, va_list ap)
{
@@ -183,6 +212,11 @@ char *fgets(char *s, int size, FILE *stream)
return NULL;
}

size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream)
{
return 0;
}

int fclose(FILE *fp)
{
/* FIXME */
@@ -298,4 +332,19 @@ double sqrt(double x)
return ret;
}


/* XXX FIXME Converts only from little endian to big endian (x86) */
unsigned int htonl(unsigned int hostlong)
{
return ((hostlong&0xFFFF0000)>>16)|((hostlong&0x0000FFFFFF)<<16);
}

/* XXX FIXME Converts only from little endian to big endian (x86) */
unsigned short htons(unsigned short hostlong)
{
return ((hostlong&0xFF00)>>8)|((hostlong&0x00FF)<<8);
}



#endif /* __KERNEL__ */

+ 16
- 7
kernel/kernel.h Wyświetl plik

@@ -17,6 +17,8 @@
* that must be used when building libcucul and libcaca into a kernel.
*/

#ifndef __KERNEL_H_
#define __KERNEL_H_
/* Various defines */
#define NULL ((void *)0)
#define BUFSIZ 4096
@@ -44,12 +46,6 @@ extern inline unsigned char inb(unsigned short port)

/* Various typedefs -- some are x86-specific */
#define CUSTOM_INTTYPES
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned long int uint32_t;
typedef long int intptr_t;
typedef long unsigned int uintptr_t;

typedef unsigned int size_t;

typedef struct file
@@ -81,13 +77,17 @@ char *getenv(const char *name);
int rand(void);
int abs(int j);
void exit(int status);
void srand(unsigned int s);
int stdint;
int stdout;
int stderr;

/* string.h functions */
void *memset(void *s, int c, size_t n);
void *memcpy(void *dest, const void *src, size_t n);
size_t strlen(const char *s);
int strcasecmp(const char *s1, const char *s2);
int memcmp(const char *s1, const char *s2, size_t n);
/* stdarg.h functions */
typedef void * va_list;
#define va_start(v,a) v = (void *)((uintptr_t)(&a) + sizeof(a))
@@ -98,6 +98,7 @@ int vsnprintf(char *str, size_t size, const char *format, va_list ap);
FILE *fopen(const char *path, const char *mode);
int feof(FILE *stream);
char *fgets(char *s, int size, FILE *stream);
size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);
int fclose(FILE *fp);
int printf(const char *format, ...);
int sprintf(char *str, const char *format, ...);
@@ -105,12 +106,20 @@ int sscanf(const char *str, const char *format, ...);

/* unistd.h functions */
void usleep(unsigned long usec);
int getpid(void);


/* time.h functions */
int gettimeofday(struct timeval *tv, struct timezone *tz);
int time(void *);

/* math.h functions */
double cos(double x);
double sin(double x);
double sqrt(double x);

/* arpa/inet.h functions */
unsigned int htonl(unsigned int hostlong);
unsigned short htons(unsigned short hostlong);

#endif /* __KERNEL_H_ */

+ 0
- 1
src/Makefile.am Wyświetl plik

@@ -46,4 +46,3 @@ fcntl_programs = cacaserver
else
fcntl_programs =
endif


+ 5
- 3
src/cacadraw.c Wyświetl plik

@@ -14,9 +14,11 @@
#include "config.h"
#include "common.h"

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#if !defined(__KERNEL__)
# include <stdio.h>
# include <string.h>
# include <stdlib.h>
#endif

#include "cucul.h"
#include "caca.h"


+ 4
- 2
src/cacaplay.c Wyświetl plik

@@ -14,8 +14,10 @@
#include "config.h"
#include "common.h"

#include <stdio.h>
#include <stdlib.h>
#if !defined(__KERNEL__)
#include <stdio.h>
#include <stdlib.h>
#endif

#include "cucul.h"
#include "caca.h"


+ 2
- 0
src/cacaview.c Wyświetl plik

@@ -14,9 +14,11 @@
#include "config.h"
#include "common.h"

#if !defined(__KERNEL__)
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#endif

#if defined(HAVE_SLEEP)
# include <windows.h>


+ 8
- 4
src/common-image.c Wyświetl plik

@@ -14,14 +14,18 @@
#include "config.h"
#include "common.h"

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#if !defined(__KERNEL__)
# include <stdio.h>
# include <string.h>
# include <stdlib.h>
#endif

#if defined(HAVE_IMLIB2_H)
# include <Imlib2.h>
#else
# include <stdio.h>
# if !defined(__KERNEL__)
# include <stdio.h>
# endif
#endif

#include "cucul.h"


+ 3
- 1
src/img2irc.c Wyświetl plik

@@ -14,9 +14,11 @@
#include "config.h"
#include "common.h"

#include <stdio.h>
#if !defined(__KERNEL__)
# include <stdio.h>
#include <string.h>
#include <stdlib.h>
# endif

#include "cucul.h"
#include "common-image.h"


+ 5
- 5
test/demo.c Wyświetl plik

@@ -13,11 +13,11 @@

#include "config.h"
#include "common.h"
#include <math.h>
#include <string.h>
#include <stdio.h>
#if !defined(__KERNEL__)
# include <math.h>
# include <string.h>
# include <stdio.h>
#endif
#include "caca.h"

static void display_menu(void);


+ 5
- 3
test/demo0.c Wyświetl plik

@@ -23,9 +23,11 @@

#include "config.h"

#include <math.h>
#include <string.h>
#include <stdio.h>
#if !defined(__KERNEL__)
# include <math.h>
# include <string.h>
# include <stdio.h>
#endif

#include "caca0.h"



+ 4
- 2
test/dithering.c Wyświetl plik

@@ -14,7 +14,9 @@
#include "config.h"
#include "common.h"

#include <stdio.h>
#if !defined(__KERNEL__)
# include <stdio.h>
#endif

#include "cucul.h"
#include "caca.h"
@@ -35,7 +37,7 @@ unsigned int points[] =

char density[] = " ',+:;o&%w$W@#";

int main(void)
int main(int argc, char *argv[])
{
cucul_canvas_t *cv;
caca_display_t *dp;


+ 5
- 4
test/event.c Wyświetl plik

@@ -13,10 +13,11 @@

#include "config.h"
#include "common.h"

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#if !defined(__KERNEL__)
# include <stdio.h>
# include <string.h>
# include <stdlib.h>
#endif

#include "cucul.h"
#include "caca.h"


+ 7
- 6
test/export.c Wyświetl plik

@@ -14,14 +14,15 @@
#include "config.h"
#include "common.h"

#if defined(HAVE_INTTYPES_H)
# include <inttypes.h>
#if !defined(__KERNEL__)
# if defined(HAVE_INTTYPES_H)
# include <inttypes.h>
# endif
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
#endif

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "cucul.h"

#define WIDTH 80


+ 12
- 10
test/font.c Wyświetl plik

@@ -14,18 +14,20 @@
#include "config.h"
#include "common.h"

#if defined(HAVE_INTTYPES_H)
# include <inttypes.h>
#if !defined(__KERNEL__)
# if defined(HAVE_INTTYPES_H)
# include <inttypes.h>
# endif

# if defined(HAVE_ENDIAN_H)
# include <endian.h>
# endif

# include <stdio.h>
# include <stdlib.h>
# include <string.h>
#endif

#if defined(HAVE_ENDIAN_H)
# include <endian.h>
#endif

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "cucul.h"
#include "caca.h"



+ 6
- 5
test/font2tga.c Wyświetl plik

@@ -14,13 +14,14 @@
#include "config.h"
#include "common.h"

#if defined(HAVE_INTTYPES_H)
# include <inttypes.h>
#if !defined(__KERNEL__)
# if defined(HAVE_INTTYPES_H)
# include <inttypes.h>
# endif
# include <stdio.h>
# include <stdlib.h>
#endif

#include <stdio.h>
#include <stdlib.h>

#include "cucul.h"

#define WIDTH 64


+ 6
- 6
test/frames.c Wyświetl plik

@@ -13,17 +13,17 @@

#include "config.h"
#include "common.h"
#if !defined(__KERNEL__)
# if defined(HAVE_INTTYPES_H)
# include <inttypes.h>
# endif

#if defined(HAVE_INTTYPES_H)
# include <inttypes.h>
# include <stdio.h>
#endif

#include <stdio.h>

#include "cucul.h"
#include "caca.h"

int main(void)
int main(int argc, char *argv[])
{
cucul_canvas_t *cv;
caca_display_t *dp;


+ 4
- 5
test/gamma.c Wyświetl plik

@@ -14,11 +14,10 @@
#include "config.h"
#include "common.h"

#if defined(HAVE_INTTYPES_H)
# include <inttypes.h>
#endif

#if !defined(__KERNEL__)
# if defined(HAVE_INTTYPES_H)
# include <inttypes.h>
# endif
# include <stdio.h>
# include <math.h>
#endif
@@ -28,7 +27,7 @@

uint32_t buffer[256 * 4];

int main(void)
int main(int argc, char *argv[])
{
caca_event_t ev;
cucul_canvas_t *cv, *cw, *mask;


+ 6
- 5
test/hsv.c Wyświetl plik

@@ -14,18 +14,19 @@
#include "config.h"
#include "common.h"

#if defined(HAVE_INTTYPES_H)
# include <inttypes.h>
#if !defined(__KERNEL__)
# if defined(HAVE_INTTYPES_H)
# include <inttypes.h>
# endif
# include <stdio.h>
#endif

#include <stdio.h>

#include "cucul.h"
#include "caca.h"

uint32_t buffer[256*256];

int main(void)
int main(int argc, char *argv[])
{
cucul_canvas_t *cv;
caca_display_t *dp;


+ 7
- 4
test/import.c Wyświetl plik

@@ -14,12 +14,15 @@
#include "config.h"
#include "common.h"

#if defined(HAVE_INTTYPES_H)
# include <inttypes.h>

#if !defined(__KERNEL__)
# if defined(HAVE_INTTYPES_H)
# include <inttypes.h>
# endif
# include <stdio.h>
# include <stdlib.h>
#endif

#include <stdio.h>
#include <stdlib.h>

#include "cucul.h"
#include "caca.h"


+ 5
- 4
test/input.c Wyświetl plik

@@ -14,12 +14,13 @@
#include "config.h"
#include "common.h"

#if defined(HAVE_INTTYPES_H)
#if !defined(__KERNEL__)
# if defined(HAVE_INTTYPES_H)
# include <inttypes.h>
# endif
# include <string.h>
#endif

#include <string.h>

#include "cucul.h"
#include "caca.h"

@@ -32,7 +33,7 @@ typedef struct textentry
unsigned int size, cursor;
} textentry;

int main(void)
int main(int argc, char *argv[])
{
textentry entries[TEXT_ENTRIES];
cucul_canvas_t *cv;


+ 3
- 3
test/spritedit.c Wyświetl plik

@@ -13,9 +13,9 @@

#include "config.h"
#include "common.h"
#include <stdio.h>
#if !defined(__KERNEL__)
# include <stdio.h>
#endif
#include "cucul.h"
#include "caca.h"



+ 7
- 8
test/text.c Wyświetl plik

@@ -13,14 +13,13 @@

#include "config.h"
#include "common.h"

#if defined(HAVE_INTTYPES_H)
# include <inttypes.h>
#if !defined(__KERNEL__)
# if defined(HAVE_INTTYPES_H)
# include <inttypes.h>
# endif
# include <stdio.h>
# include <string.h>
#endif

#include <stdio.h>
#include <string.h>

#include "cucul.h"

#define STRING \
@@ -31,7 +30,7 @@
" \\ `--' / \n" \
" `----' \n"

int main(void)
int main(int argc, char *argv[])
{
cucul_canvas_t *cv;
cucul_buffer_t *buffer;


+ 6
- 6
test/transform.c Wyświetl plik

@@ -13,13 +13,13 @@

#include "config.h"
#include "common.h"

#if defined(HAVE_INTTYPES_H)
# include <inttypes.h>
#if !defined(__KERNEL__)
# if defined(HAVE_INTTYPES_H)
# include <inttypes.h>
# endif
# include <stdio.h>
#endif

#include <stdio.h>

#include "cucul.h"
#include "caca.h"

@@ -44,7 +44,7 @@ static char const *duck[] =
NULL
};

int main(void)
int main(int argc, char *argv[])
{
cucul_canvas_t *cv, *normal, *flip, *flop, *rotate;
caca_display_t *dp;


+ 6
- 5
test/truecolor.c Wyświetl plik

@@ -14,16 +14,17 @@
#include "config.h"
#include "common.h"

#if defined(HAVE_INTTYPES_H)
# include <inttypes.h>
#if !defined(__KERNEL__)
# if defined(HAVE_INTTYPES_H)
# include <inttypes.h>
# endif
# include <stdio.h>
#endif

#include <stdio.h>

#include "cucul.h"
#include "caca.h"

int main(void)
int main(int argc, char *argv[])
{
cucul_canvas_t *cv;
caca_display_t *dp;


+ 6
- 5
test/unicode.c Wyświetl plik

@@ -14,16 +14,17 @@
#include "config.h"
#include "common.h"

#if defined(HAVE_INTTYPES_H)
# include <inttypes.h>
#if !defined(__KERNEL__)
# if defined(HAVE_INTTYPES_H)
# include <inttypes.h>
# endif
# include <stdio.h>
#endif

#include <stdio.h>

#include "cucul.h"
#include "caca.h"

int main(void)
int main(int argc, char *argv[])
{
cucul_canvas_t *cv;
caca_display_t *dp;


+ 4
- 2
tools/optipal.c Wyświetl plik

@@ -14,7 +14,9 @@
#include "config.h"
#include "common.h"

#include <stdio.h>
#if !defined(__KERNEL__)
# include <stdio.h>
#endif

#include "cucul.h" /* Only necessary for CUCUL_* macros */

@@ -44,7 +46,7 @@ static unsigned int const hue_list[] =
} \
while(0);

int main(void)
int main(int argc, char *argv[])
{
int i;



Ładowanie…
Anuluj
Zapisz