/**************************************************************************** * @(#) Ndless - OS Calls * * Copyright (C) 2010 by ANNEHEIM Geoffrey and ARMAND Olivier * Contact: geoffrey.anneheim@gmail.com / olivier.calc@gmail.com * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. * * RCSID $Id$ ****************************************************************************/ #ifndef _OS_H_ #define _OS_H_ #include "common.h" #ifdef os1_0_494 #include "os_1.0.494.h" #elif os1_0_529 #include "os_1.0.529.h" #elif os1_0_554 #include "os_1.0.554.h" #else #error You must specify an Nspire OS (os1_0_494 or os1_0_529 or os1_0_554) #endif /** GNU AS */ #ifdef GNU_AS .macro oscall address mov lr,pc ldr pc,=\address .endm #define _oscall(rettype,funcaddr,...) funcaddr /** GNU C Compiler */ #else #define _oscall(rettype,funcaddr,...) (*((rettype(*)(__VA_ARGS__))(funcaddr))) #define NULL ((void*)0) typedef enum bool {FALSE = 0, TRUE = 1} BOOL; typedef struct{} FILE; typedef unsigned long size_t; #endif #define fopen (_oscall(FILE*, fopen_, const char *filename, const char *mode)) #define fread (_oscall(size_t, fread_, void *ptr, size_t size, size_t nitems, FILE *stream)) #define fwrite (_oscall(size_t, fwrite_, const void *ptr, size_t size, size_t count, FILE *stream)) #define fclose (_oscall(int, fclose_, FILE *stream)) #define fgets (_oscall(char *,fgets_, const char *ptr, size_t count, FILE *stream)) #define malloc (_oscall(void*, malloc_, size_t size)) #define free (_oscall(void, free_, void *ptr)) #define strcpy (_oscall(void*, strcpy_, char *s1, char *s2)) #define memset (_oscall(void*, memset_, void *ptr, int value, size_t num)) #define memcpy (_oscall(void*, memcpy_, void *s1, const void *s2, size_t n)) #define memcmp (_oscall(int, memcmp_, const void *ptr1, const void *ptr2, size_t num)) //#define printf (_oscall(int __attribute__((__format__(__printf__,1,2))), printf_, const char *format, ...)) #define sprintf (_oscall(int __attribute__((__format__(__printf__,2,3))), sprintf_, const char *s, const char *format, ...)) #define fprintf (_oscall(int __attribute__((__format__(__printf__,2,3))), fprintf_, FILE *stream, const char *format, ...)) #define ascii2utf16 (_oscall(void, ascii2utf16_, void *buff, const char *str, int max_size)) #define show_dialog_box2 (_oscall(void, show_dialog_box2_, const char *title, const char *msg, const char *lang)) #define show_Entrydialog_box (_oscall(int, show_Entrydialog_box_, int, const char *input)) //#define show_Entrydialog_box (_oscall(int, show_Entrydialog_box_, int, const char *title,int, const char *label, const char *input, int, char*, char*)) //#define dialog_3btn (_oscall(int, dialog_3btn_, const char *title, const char *msg, const char *buttons, int defbtn)) #define mkdir (_oscall(int, mkdir_, const char *path, int mode)) #define rmdir (_oscall(int, rmdir_, const char *path)) #define set_current_path (_oscall(void, set_current_path_, const char*)) #define chdir (_oscall(void, chdir_, const char*)) #define stat (_oscall(int, stat_, const char *restric path, struct stat *restrict buf)) #define unlink (_oscall(int, unlink_, const char *)) #define rename (_oscall(int, rename_, const char *old, const char *new)) #define _log_rs232 (_oscall(void, log_rs232_, const char* msg, void *param2)) #define log_rs232(msg) (_log_rs232(msg "\n", (void*)log_rs232_param2_)) #define log_rs232_v(msg) (_log_rs232(msg, (void*)log_rs232_param2_)) //#define printf_rs232 (_oscall(void, printf_rs232_, const char*, ...)) #define power_off (_oscall(void, power_off_, void)) #define TCT_Local_Control_Interrupts (_oscall(int, TCT_Local_Control_Interrupts_, int newlevel)) #define sscanf (_oscall(int, sscanf_ , char *str, char *fmtin, ... )) #define memmove (_oscall(int, memmove_ , char *dest, char *src , int size)) #define strcat (_oscall(int, strcat_ , char *dest, char *src )) #define strlen (_oscall(int, strlen_ , char *str )) #define strstr (_oscall(char*, strstr_ , char *str , char *substr)) #define NU_Current_Dir (_oscall(int, NU_Current_Dir_ , char *drive, char *path )) #define NU_Get_First (_oscall(int, NU_Get_First_ , struct dstat*, char *path )) #define NU_Get_Next (_oscall(int, NU_Get_Next_ , struct dstat* )) #define NU_Done (_oscall(int, NU_Done_ , struct dstat* )) #define TCC_Task_Sleep (_oscall(int, TCC_Task_Sleep_ , unsigned ticks)) #define idle (_oscall(void, idle_ , void)) #define strtoul (_oscall(size_t, strtoul_ ,const char *, char **, int base)) //#define puts (_oscall(void, puts_ ,const char *)) #define SDC_Data_Ready (_oscall(int, SDC_Data_Ready_ ,int )) #define SDC_Get_Char (_oscall(int, SDC_Get_Char_ ,int )) #define getcwd (_oscall(int, getcwd_ ,char *,int size )) #endif