kos.h

Go to the documentation of this file.
00001 //& ****************************************************************************
00002 //&
00003 //&
00004 //& This file is part of HP-GCC.
00005 //&
00006 //& HP-GCC is free software; you can redistribute it and/or modify
00007 //& it under the terms of the GNU General Public License as published by
00008 //& the Free Software Foundation; either version 2, or (at your option)
00009 //& any later version.
00010 //& 
00011 //& HP-GCC is distributed in the hope that it will be useful,
00012 //& but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //& MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //& GNU General Public License for more details.
00015 //& 
00016 //& You should have received a copy of the GNU General Public License
00017 //& along with HP-GCC; see the file COPYING. 
00018 //&
00019 //& As a special exception, you may use this file as part of a free software
00020 //& library without restriction.  Specifically, if other files instantiate
00021 //& templates or use macros or inline functions from this file, or you compile
00022 //& this file and link it with other files to produce an executable, this
00023 //& file does not by itself cause the resulting executable to be covered by
00024 //& the GNU General Public License.  This exception does not however
00025 //& invalidate any other reasons why the executable file might be covered by
00026 //& the GNU General Public License.
00027 //&
00028 //& ****************************************************************************
00029 
00030 // $Header: /cvsroot/hpgcc/sources/hplib/kos.h,v 1.14 2005/06/12 20:14:40 njz3 Exp $
00031 
00032 #ifndef _KOS_H
00033 #define _KOS_H
00034 
00035 
00036 
00037 typedef unsigned int U32;
00038 typedef int S32;
00039 typedef unsigned short U16;
00040 typedef short S16;
00041 typedef unsigned char U8,*P_U8;
00042 typedef char S8;
00043 typedef char BYTE;
00044 typedef char *P_BYTE;
00045 typedef int BOOL;
00046 typedef void *P_VOID;
00047 
00048 #ifndef size_t
00049 #define size_t unsigned int
00050 #endif /* size_t */
00051 
00052 #ifndef SIZE_T
00053 #define SIZE_T size_t
00054 #endif
00055 
00056 
00057 //Al 19th Nov '04
00058 #ifndef NULL
00059 #define NULL 0
00060 #endif
00061 
00062 // < ibl ; 2004-10-28 >
00063 #define TIME_T unsigned int 
00064 
00065 typedef U32 (*FUNC_PTR)();
00066 typedef U32 (*FUNC0PTR)();
00067 typedef U32 (*FUNC1PTR)(U32);
00068 typedef U32 (*FUNC2PTR)(U32,U32);
00069 typedef U32 (*FUNC3PTR)(U32,U32,U32);
00070 
00071 
00072 
00073 #ifndef FALSE
00074 #define FALSE 0
00075 #define TRUE (! FALSE)
00076 #endif
00077 
00078 
00079 
00080 
00082 typedef struct
00083 {
00084     U16 year;    
00085     U8 month;    
00086     U8 day;        
00087 }
00088 KDATE;
00089 
00091 typedef struct
00092 {
00093     U8 hours;        
00094     U8 minutes;        
00095     U8 seconds;        
00096     U8 unknown1;    
00097     U32 unknown2;    
00098 } KTIME;
00099 
00100 // The KOS Date&Time Structure (nesting)
00101 typedef struct
00102 {
00103     KDATE date;        
00104     KTIME time;        
00105 }
00106 KDATETIME, *P_KDATETIME;
00107 
00108 
00109 
00110 
00111 // memory alloc type define
00112 #define KOS_MEM_FREE                        0x0000
00113 // memory not allocated
00114 #define KOS_MEM_GLOBAL                      0x1000
00115 // global memory type
00116 #define KOS_MEM_LOCAL                       0x2000
00117 // local (task) memory type
00118 #define KOS_MEM_HEAP0                       0x0100
00119 // heap number
00120 
00121 #define KOS_MODULE_FILESYSTEM 1
00122 
00123 #define KOS_FUNC_FOPEN    0
00124 #define KOS_FUNC_FREAD    1
00125 #define KOS_FUNC_FWRITE    2
00126 #define KOS_FUNC_FCLOSE    3
00127 #define KOS_FUNC_FSEEK    4
00128 #define KOS_FUNC_FDELETE 5
00129 // < Benjamin ; 2005-06-12 >
00130 #define KOS_FUNC_FRENAME        6
00131 #define KOS_FUNC_CHDIR            7
00132 #define KOS_FUNC_GETFILEINFO    8
00133 #define KOS_FUNC_GETFIRSTDIR    9
00134 #define KOS_FUNC_GETNEXTDIR        10
00135 #define KOS_FUNC_GETPREVDIR        11
00136 #define KOS_FUNC_GETFIRSTFILE    12
00137 #define KOS_FUNC_GETNEXTFILE    13
00138 #define KOS_FUNC_GETPREVFILE    14
00139 #define KOS_FUNC_FATTR            15
00140 #define KOS_FUNC_GETSIZE        16
00141 #define KOS_FUNC_CHECKINSERT    17
00142 #define KOS_FUNC_CHECKPROTECT    18
00143 
00144 
00145 
00146 #define KOS_READMODE 1        
00147 #define KOS_WRITEMODE 2
00148 
00149 // Filesystem (fs.h)
00150 
00151 // we don't have that...
00152 // #include "kgeneraldef.h"
00153 
00154 #define FAT32_SUPPORT  1
00155 
00156 
00157 #define NEW_FILE_NAME
00158 
00159 // < Benjamin ; 2005-06-12 >
00161 typedef struct 
00162 //__file_dir_info
00163 {
00164        KDATETIME       last_modifier;
00165        KDATETIME       create_date;
00166        KDATE           last_access_date;
00167 #ifdef  NEW_FILE_NAME
00168        BYTE            file_name[13];    
00169 #else
00170        BYTE            extension[4];
00171        BYTE            name[9];
00172 #endif
00173 
00191        U8               attribute;    
00192        U16             ext_attr;    
00193        U32             size;        
00194 }
00195 FILE_INFO, DIR_INFO, *P_FILE_INFO, *P_DIR_INFO;
00196 
00197 
00198 
00199 typedef S32     H_FILE;
00200 
00201 // < Benjamin ; 2005-06-12 >
00202 // Attributes for FILE_INFO/DIR_INFO
00204 #define KOS_READONLY_ATTRIBUTE (1)
00206 #define KOS_HIDDEN_ATTRIBUTE (1<<1)
00208 #define KOS_SYSTEM_ATTRIBUTE (1<<2)
00210 #define KOS_ARCHIVE_ATTRIBUTE (1<<5)
00211 
00212 #define FILE_READONLY   0x00000001      //mode parameter in kos_fopen
00213 #define FILE_READWRITE  0x00000002
00214 #define FILE_APPEND     0x00000003
00215 
00216 #define FS_SEEK_SET             0
00217 #define FS_SEEK_CUR             1
00218 #define FS_SEEK_END             2
00219 
00220 #define ERR_FS_INVALID_NAME                     -1
00221 #define ERR_FS_FILE_OPENED                      -2
00222 #define ERR_FS_INVALID_HANDLE                   -3
00223 #define ERR_FS_INVALID_INDEX                    -4
00224 #define ERR_FS_INVALID_MODE                     -5
00225 #define ERR_FS_DISK_FULL                        -6
00226 #define ERR_FS_DISK_ERROR                       -7
00227 #define ERR_FS_DISK_CHANGE                      -8
00228 #define ERR_FS_NO_SDCARD                        -9
00229 #define ERR_FS_NO_MEMORY                       -10
00230 #define ERR_FS_NOT_SUPPORT                     -11
00231 #define ERR_FS_PROTECT                         -13
00232 #define ERR_FS_NOTFIND                         -14
00233 #define ERR_FS_DISK_REMOVE                     -15
00234 #define ERR_FS_FILE_NOTEXIST                   -16
00235 #define ERR_FS_UNKNOWN                        -100
00236 
00237 
00238 
00239 // Errors
00240 
00241 #define SUCCESS 0
00242 #define EOF -1
00243 #define KOS_ERR_INVALIDPTR    -200 // FIXME: random guess
00244 
00245 // Kernel
00246 
00247 FUNC_PTR kos_GetFuncEntry(U32 module, U32 index);
00248 
00249 // Filesystem
00250 
00251 H_FILE kos_fopen(P_BYTE fname, U8 mode);
00252 SIZE_T kos_fread(H_FILE fd, P_BYTE buf, U32 length);
00253 SIZE_T kos_fwrite(H_FILE fd, P_BYTE buf, U32 length);
00254 S32 kos_fseek(H_FILE fd, S32 offset, U32 mode);
00255 S32 kos_fclose(H_FILE fd);
00256 S32 kos_fdelete(P_BYTE fname);
00257 
00258 
00259 // CHANGED TO A MACRO
00260 #define fdelete(a) kos_fdelete(a);
00261 
00262 
00263 
00264 
00265 
00266 
00267 
00268 // < Benjamin ; 2005-06-12 >
00270 
00273 S32 kos_frename(P_BYTE oldname, P_BYTE newname);
00274 
00276 
00286 S32 kos_chdir(P_BYTE pDir);
00287 
00289 S32 kos_GetSpecialFileInfo(P_BYTE fname, P_FILE_INFO pInfo);
00290 
00292 
00297 S32 kos_GetFirstDirInfo(P_DIR_INFO pInfo);
00298 
00300 
00309 S32 kos_GetNextDirInfo(P_DIR_INFO pInfo, U32 index);
00310 
00312 
00321 S32 kos_GetPrevDirInfo(P_DIR_INFO pInfo, U32 index);
00322 
00324 
00367 S32 kos_GetFirstFileInfo(P_FILE_INFO pInfo);
00368 
00370 
00379 S32 kos_GetNextFileInfo(P_FILE_INFO pInfo, U32 index);
00380 
00382 
00391 S32 kos_GetPrevFileInfo(P_FILE_INFO pInfo, U32 index);
00392 
00394 
00397 S32 kos_fattr(P_BYTE fname, U8 attr);
00398 
00399 
00401 
00405 S32 kos_GetDiskFreeSize(void);
00406 
00408 
00412 S32 kos_CheckDiskInsert(void);
00413 
00415 
00419 S32 kos_CheckDiskProtect(void);
00420 
00421 
00423 
00429 void kos_ResetSD(void);
00430 
00431 
00432 
00433 //Edit by Al 19th October
00434 //Include more of HP's KOS functions
00435 
00436 //TODO: Add the rest (except maybe the dangerous ones)
00437 
00438 //memory management
00439 
00440 void *kos_malloc(SIZE_T size); //malloc. ~100kb free on 49g+, <30k free on 39g+
00441 S32 kos_free(void *pMemory); //free
00442  
00443 
00444 //display routines
00445 
00446 void kos_ClearLcd(void); //clears the LCD
00447 U32 kos_PutString(U32 dx, U32 dy, P_VOID ptr); //writes a string, in large 5 x 8 font
00448 void kos_PutHexNumber(U32 dx, U32 dy, U32 value); //write a number in hex
00449 void kos_PutDecNumber(U32 dx, U32 dy, U32 value, U32 bit); //writes a number in base-10
00450 
00451 U32 kos_LCDGetContrast(void); //gets and sets LCD contrast
00452 void kos_LCDSetContrast(U32 contrast);
00453 
00454 //misc routines
00455 
00456 P_BYTE kos_getSerialNumber(void); //seems to return garbage, and a Kinpo copyright. 
00457 void kos_Reset(void); // reset OS + emulator?
00458 S32 kos_beep(U32 freq, TIME_T time, U32 override);
00459 
00460 // Time
00461 
00462 U32 kos_GetSysTickTime();
00463 
00464 
00465 
00466 #endif

Generated on Fri Feb 16 16:43:16 2007 for HP-GCCLibrary by  doxygen 1.5.0