Add basic Casio syscalls (non-stdlib functionality) which are included into stdio.h
This commit is contained in:
parent
9e1879908d
commit
f0ae05e7c8
|
@ -8,7 +8,7 @@ AM_CCASFLAGS = $(INCLUDES) $(CFLAGS)
|
|||
|
||||
noinst_LIBRARIES = lib.a
|
||||
|
||||
lib_a_SOURCES = syscalls.c trap.S creat.c ftruncate.c truncate.c
|
||||
lib_a_SOURCES = syscalls.c trap.S creat.c ftruncate.c truncate.c casio_syscalls.c
|
||||
lib_a_CCASFLAGS = $(AM_CCASFLAGS)
|
||||
lib_a_CFLAGS = $(AM_CFLAGS)
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ lib_a_AR = $(AR) $(ARFLAGS)
|
|||
lib_a_LIBADD =
|
||||
am_lib_a_OBJECTS = lib_a-syscalls.$(OBJEXT) lib_a-trap.$(OBJEXT) \
|
||||
lib_a-creat.$(OBJEXT) lib_a-ftruncate.$(OBJEXT) \
|
||||
lib_a-truncate.$(OBJEXT)
|
||||
lib_a-truncate.$(OBJEXT) lib_a-casio_syscalls.$(OBJEXT)
|
||||
lib_a_OBJECTS = $(am_lib_a_OBJECTS)
|
||||
DEFAULT_INCLUDES = -I.@am__isrc@
|
||||
depcomp =
|
||||
|
@ -184,6 +184,7 @@ pdfdir = @pdfdir@
|
|||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
psdir = @psdir@
|
||||
runstatedir = @runstatedir@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
|
@ -197,7 +198,7 @@ AUTOMAKE_OPTIONS = cygnus
|
|||
INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
|
||||
AM_CCASFLAGS = $(INCLUDES) $(CFLAGS)
|
||||
noinst_LIBRARIES = lib.a
|
||||
lib_a_SOURCES = syscalls.c trap.S creat.c ftruncate.c truncate.c
|
||||
lib_a_SOURCES = syscalls.c trap.S creat.c ftruncate.c truncate.c casio_syscalls.c
|
||||
lib_a_CCASFLAGS = $(AM_CCASFLAGS)
|
||||
lib_a_CFLAGS = $(AM_CFLAGS)
|
||||
ACLOCAL_AMFLAGS = -I ../../.. -I ../../../..
|
||||
|
@ -296,6 +297,12 @@ lib_a-truncate.o: truncate.c
|
|||
lib_a-truncate.obj: truncate.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-truncate.obj `if test -f 'truncate.c'; then $(CYGPATH_W) 'truncate.c'; else $(CYGPATH_W) '$(srcdir)/truncate.c'; fi`
|
||||
|
||||
lib_a-casio_syscalls.o: casio_syscalls.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-casio_syscalls.o `test -f 'casio_syscalls.c' || echo '$(srcdir)/'`casio_syscalls.c
|
||||
|
||||
lib_a-casio_syscalls.obj: casio_syscalls.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-casio_syscalls.obj `if test -f 'casio_syscalls.c'; then $(CYGPATH_W) 'casio_syscalls.c'; else $(CYGPATH_W) '$(srcdir)/casio_syscalls.c'; fi`
|
||||
|
||||
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
#include <stddef.h>
|
||||
|
||||
#include <sys/casio_syscalls.h>
|
||||
|
||||
DEFINE_CASIO_SYSCALL_FN_PTR(GetKey, int, (unsigned int*), 0x90F)
|
||||
DEFINE_CASIO_SYSCALL_FN_PTR(PutKey, int, (int keycode, int mode), 0x910)
|
||||
DEFINE_CASIO_SYSCALL_FN_PTR(GetKeyWait, int, (int*column, int*row, int type_of_waiting, int timeout_period, int menu, unsigned short *keycode), 0x247)
|
||||
DEFINE_CASIO_SYSCALL_FN_PTR(Bdisp_AllClr_DDVRAM, void, (void), 0x144)
|
||||
DEFINE_CASIO_SYSCALL_FN_PTR(Bdisp_PutDisp_DD, void, (void), 0x028)
|
||||
DEFINE_CASIO_SYSCALL_FN_PTR(Print, void, (const unsigned char*), 0x808)
|
||||
DEFINE_CASIO_SYSCALL_FN_PTR(locate, void, (int, int), 0x807)
|
||||
DEFINE_CASIO_SYSCALL_FN_PTR(wait_ms, void, (unsigned int), 0x130) // TODO signature assumed
|
||||
|
||||
int GetKey(unsigned int* keycode) {
|
||||
return _GetKey_ptr(keycode);
|
||||
}
|
||||
|
||||
int PutKey(int keycode, int mode) {
|
||||
return _PutKey_ptr(keycode, mode);
|
||||
}
|
||||
|
||||
int GetKeyWait(int*column, int*row, int type_of_waiting, int timeout_period, int menu, unsigned short *keycode) {
|
||||
return _GetKeyWait_ptr(column, row, type_of_waiting, timeout_period, menu, keycode);
|
||||
}
|
||||
|
||||
void Bdisp_AllClr_DDVRAM(void) {
|
||||
_Bdisp_AllClr_DDVRAM_ptr();
|
||||
}
|
||||
|
||||
void Bdisp_PutDisp_DD(void) {
|
||||
_Bdisp_PutDisp_DD_ptr();
|
||||
}
|
||||
|
||||
void Print(const unsigned char* str) {
|
||||
_Print_ptr(str);
|
||||
}
|
||||
|
||||
void locate(int x, int y) {
|
||||
_locate_ptr(x, y);
|
||||
}
|
||||
|
||||
void wait_ms(unsigned int ms) { // TODO signature assumed
|
||||
_wait_ms_ptr(ms);
|
||||
}
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
#ifdef _CASIO_SYSCALLS_H
|
||||
#define _CASIO_SYSCALLS_H
|
||||
#else
|
||||
|
||||
// the following definitions are only needed once
|
||||
#define _CASIO_SYSCALLS_SCA 0xD201D002
|
||||
#define _CASIO_SYSCALLS_SCB 0x422B0009
|
||||
#define _CASIO_SYSCALLS_SCE 0x80010070
|
||||
// 0x80010070 is the fx-9860-syscall-entry point
|
||||
// 0x80020070 is the fx-CG-syscall-entry point (but remember: the syscall numbers are different!)
|
||||
|
||||
// for reference:
|
||||
// this are the assembler instructions, which represent the int arrays of the type
|
||||
// "const unsigned int scSyscallNo[] = { SCA, SCB, SCE, SyscallNo };"
|
||||
|
||||
// mov.l #h'80010070, r2
|
||||
// mov.l #SyscallNo, r0
|
||||
// jmp @r2
|
||||
// nop
|
||||
|
||||
/*
|
||||
* Macro for defining function pointers to some Casio syscalls
|
||||
* see for addesses: http://media.taricorp.net/prizm/simon_chm/fx_legacy_syscalls.htm
|
||||
*/
|
||||
#define DEFINE_CASIO_SYSCALL_FN_PTR(func_name, ret, args, addr) \
|
||||
typedef ret (* _ ## func_name ## _type) args; \
|
||||
const unsigned int _ ## func_name ## _ ## address[] = {_CASIO_SYSCALLS_SCA, _CASIO_SYSCALLS_SCB, _CASIO_SYSCALLS_SCE, addr}; \
|
||||
const _ ## func_name ## _type _ ## func_name ## _ptr = (_ ## func_name ## _type) _ ## func_name ## _ ## address;
|
||||
|
||||
/* example for the code generated by DEFINE_SYSCALL_FN_PTR(malloc, void*, (size_t), 0xACD) */
|
||||
// typedef void* (*_malloc_type)(size_t size);
|
||||
// const unsigned int _malloc_address[] = { SCA, SCB, SCE, 0x0ACC };
|
||||
// const _malloc_type _malloc_ptr = (_malloc_type) _malloc_address;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Original Casio key positions
|
||||
*/
|
||||
#define _CASIO_ROW_AC 1
|
||||
#define _CASIO_ROW_MIN 2 // bottom
|
||||
#define _CASIO_ROW_SHIFT 9
|
||||
#define _CASIO_ROW_ALPHA 8
|
||||
#define _CASIO_ROW_MAX 10 // top
|
||||
#define _CASIO_COL_AC 1
|
||||
#define _CASIO_COL_MIN 2 // right
|
||||
#define _CASIO_COL_SHIFT 7
|
||||
#define _CASIO_COL_ALPHA 7
|
||||
#define _CASIO_COL_MAX 7 // left
|
||||
|
||||
/*
|
||||
* Casio syscalls (non-stdlib)
|
||||
*/
|
||||
int GetKey(unsigned int* keycode);
|
||||
int PutKey(int keycode, int mode);
|
||||
int GetKeyWait(int*column, int*row, int type_of_waiting, int timeout_period, int menu, unsigned short *keycode);
|
||||
void Bdisp_AllClr_DDVRAM(void);
|
||||
void Bdisp_PutDisp_DD(void);
|
||||
void Print(const unsigned char* str);
|
||||
void locate(int x, int y);
|
||||
void wait_ms(unsigned int ms); // TODO signature assumed
|
||||
|
||||
#endif /* _CASIO_SYSCALLS_H */
|
|
@ -0,0 +1,33 @@
|
|||
#ifndef _NEWLIB_STDIO_H
|
||||
#define _NEWLIB_STDIO_H
|
||||
|
||||
/*
|
||||
* Include casio_syscalls.h to provide basic Casio
|
||||
* functionality alongside with stdio.
|
||||
*/
|
||||
#include <sys/casio_syscalls.h>
|
||||
|
||||
#include <sys/lock.h>
|
||||
#include <sys/reent.h>
|
||||
|
||||
/* Internal locking macros, used to protect stdio functions. In the
|
||||
general case, expand to nothing. Use __SSTR flag in FILE _flags to
|
||||
detect if FILE is private to sprintf/sscanf class of functions; if
|
||||
set then do nothing as lock is not initialised. */
|
||||
#if !defined(_flockfile)
|
||||
#ifndef __SINGLE_THREAD__
|
||||
# define _flockfile(fp) (((fp)->_flags & __SSTR) ? 0 : __lock_acquire_recursive((fp)->_lock))
|
||||
#else
|
||||
# define _flockfile(fp) ((void) 0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(_funlockfile)
|
||||
#ifndef __SINGLE_THREAD__
|
||||
# define _funlockfile(fp) (((fp)->_flags & __SSTR) ? 0 : __lock_release_recursive((fp)->_lock))
|
||||
#else
|
||||
# define _funlockfile(fp) ((void) 0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* _NEWLIB_STDIO_H */
|
Loading…
Reference in New Issue