HPGCC3 Documentation 3.0 R003

kos.h File Reference

Go to the source code of this file.

Data Structures

struct  KDATE
 The KOS Date structure. More...
struct  KTIME
 The KOS Time structure. More...
struct  KDATETIME
struct  FILE_INFO
 The KOS File info structure. More...

Defines

#define size_t   unsigned int
#define SIZE_T   size_t
#define NULL   0
#define TIME_T   unsigned int
#define FALSE   0
#define TRUE   (! FALSE)
#define KOS_MEM_FREE   0x0000
#define KOS_MEM_GLOBAL   0x1000
#define KOS_MEM_LOCAL   0x2000
#define KOS_MEM_HEAP0   0x0100
#define KOS_MODULE_FILESYSTEM   1
#define KOS_FUNC_FOPEN   0
#define KOS_FUNC_FREAD   1
#define KOS_FUNC_FWRITE   2
#define KOS_FUNC_FCLOSE   3
#define KOS_FUNC_FSEEK   4
#define KOS_FUNC_FDELETE   5
#define KOS_FUNC_FRENAME   6
#define KOS_FUNC_CHDIR   7
#define KOS_FUNC_GETFILEINFO   8
#define KOS_FUNC_GETFIRSTDIR   9
#define KOS_FUNC_GETNEXTDIR   10
#define KOS_FUNC_GETPREVDIR   11
#define KOS_FUNC_GETFIRSTFILE   12
#define KOS_FUNC_GETNEXTFILE   13
#define KOS_FUNC_GETPREVFILE   14
#define KOS_FUNC_FATTR   15
#define KOS_FUNC_GETSIZE   16
#define KOS_FUNC_CHECKINSERT   17
#define KOS_FUNC_CHECKPROTECT   18
#define KOS_READMODE   1
#define KOS_WRITEMODE   2
#define FAT32_SUPPORT   1
#define NEW_FILE_NAME
#define KOS_READONLY_ATTRIBUTE   (1)
 Read-only bit for read-only attribute field.
#define KOS_HIDDEN_ATTRIBUTE   (1<<1)
 Read-only bit for hidden file attribute field.
#define KOS_SYSTEM_ATTRIBUTE   (1<<2)
 Read-only bit for system file attribute field.
#define KOS_ARCHIVE_ATTRIBUTE   (1<<5)
 Read-only bit for archive attribute field.
#define FILE_READONLY   0x00000001
#define FILE_READWRITE   0x00000002
#define FILE_APPEND   0x00000003
#define FS_SEEK_SET   0
#define FS_SEEK_CUR   1
#define FS_SEEK_END   2
#define ERR_FS_INVALID_NAME   -1
#define ERR_FS_FILE_OPENED   -2
#define ERR_FS_INVALID_HANDLE   -3
#define ERR_FS_INVALID_INDEX   -4
#define ERR_FS_INVALID_MODE   -5
#define ERR_FS_DISK_FULL   -6
#define ERR_FS_DISK_ERROR   -7
#define ERR_FS_DISK_CHANGE   -8
#define ERR_FS_NO_SDCARD   -9
#define ERR_FS_NO_MEMORY   -10
#define ERR_FS_NOT_SUPPORT   -11
#define ERR_FS_PROTECT   -13
#define ERR_FS_NOTFIND   -14
#define ERR_FS_DISK_REMOVE   -15
#define ERR_FS_FILE_NOTEXIST   -16
#define ERR_FS_UNKNOWN   -100
#define SUCCESS   0
#define EOF   -1
#define KOS_ERR_INVALIDPTR   -200
#define fdelete(a)   kos_fdelete(a);

Typedefs

typedef unsigned int U32
typedef int S32
typedef unsigned short U16
typedef short S16
typedef unsigned char U8
typedef unsigned char * P_U8
typedef char S8
typedef char BYTE
typedef char * P_BYTE
typedef int BOOL
typedef void * P_VOID
typedef U32(* FUNC_PTR )()
typedef U32(* FUNC0PTR )()
typedef U32(* FUNC1PTR )(U32)
typedef U32(* FUNC2PTR )(U32, U32)
typedef U32(* FUNC3PTR )(U32, U32, U32)
typedef struct KDATETIMEP_KDATETIME
typedef struct FILE_INFO DIR_INFO
typedef struct FILE_INFOP_FILE_INFO
typedef struct FILE_INFOP_DIR_INFO
typedef S32 H_FILE

Functions

FUNC_PTR kos_GetFuncEntry (U32 module, U32 index)
H_FILE kos_fopen (P_BYTE fname, U8 mode)
SIZE_T kos_fread (H_FILE fd, P_BYTE buf, U32 length)
SIZE_T kos_fwrite (H_FILE fd, P_BYTE buf, U32 length)
S32 kos_fseek (H_FILE fd, S32 offset, U32 mode)
S32 kos_fclose (H_FILE fd)
S32 kos_fdelete (P_BYTE fname)
S32 kos_frename (P_BYTE oldname, P_BYTE newname)
 FIXME: this function does not seem to work as it should (return -200 err every time)
S32 kos_chdir (P_BYTE pDir)
 Change system current directory.
S32 kos_GetSpecialFileInfo (P_BYTE fname, P_FILE_INFO pInfo)
 FIXME: Still confused by this.
S32 kos_GetFirstDirInfo (P_DIR_INFO pInfo)
 Fill a FILE_INFO structure of the first sub-directory of the current directory.
S32 kos_GetNextDirInfo (P_DIR_INFO pInfo, U32 index)
 Fill a DIR_INFO structure of the next 'indexed' sub-directory of the current directory.
S32 kos_GetPrevDirInfo (P_DIR_INFO pInfo, U32 index)
 Fill a DIR_INFO structure of the previous 'indexed' sub-directory of the current directory.
S32 kos_GetFirstFileInfo (P_FILE_INFO pInfo)
 Fill a FILE_INFO structure of the first file of the current directory.
S32 kos_GetNextFileInfo (P_FILE_INFO pInfo, U32 index)
 Fill a FILE_INFO structure of the next 'indexed' file of the current directory.
S32 kos_GetPrevFileInfo (P_FILE_INFO pInfo, U32 index)
 Fill a FILE_INFO structure of the previous 'indexed' file of the current directory.
S32 kos_fattr (P_BYTE fname, U8 attr)
 Set file attributes.
S32 kos_GetDiskFreeSize (void)
 Get disk free size in bytes.
S32 kos_CheckDiskInsert (void)
 Check if a valid SD is inserted.
S32 kos_CheckDiskProtect (void)
 Check if a the SD is write-protected.
void kos_ResetSD (void)
 Reset calculator OS file system.
void * kos_malloc (SIZE_T size)
S32 kos_free (void *pMemory)
void kos_ClearLcd (void)
U32 kos_PutString (U32 dx, U32 dy, P_VOID ptr)
void kos_PutHexNumber (U32 dx, U32 dy, U32 value)
void kos_PutDecNumber (U32 dx, U32 dy, U32 value, U32 bit)
U32 kos_LCDGetContrast (void)
void kos_LCDSetContrast (U32 contrast)
P_BYTE kos_getSerialNumber (void)
void kos_Reset (void)
S32 kos_beep (U32 freq, TIME_T time, U32 override)
U32 kos_GetSysTickTime ()

Define Documentation

#define EOF   -1

Definition at line 221 of file kos.h.

#define ERR_FS_DISK_CHANGE   -8

Definition at line 206 of file kos.h.

#define ERR_FS_DISK_ERROR   -7

Definition at line 205 of file kos.h.

#define ERR_FS_DISK_FULL   -6

Definition at line 204 of file kos.h.

#define ERR_FS_DISK_REMOVE   -15

Definition at line 212 of file kos.h.

#define ERR_FS_FILE_NOTEXIST   -16

Definition at line 213 of file kos.h.

#define ERR_FS_FILE_OPENED   -2

Definition at line 200 of file kos.h.

#define ERR_FS_INVALID_HANDLE   -3

Definition at line 201 of file kos.h.

#define ERR_FS_INVALID_INDEX   -4

Definition at line 202 of file kos.h.

#define ERR_FS_INVALID_MODE   -5

Definition at line 203 of file kos.h.

#define ERR_FS_INVALID_NAME   -1

Definition at line 199 of file kos.h.

#define ERR_FS_NO_MEMORY   -10

Definition at line 208 of file kos.h.

#define ERR_FS_NO_SDCARD   -9

Definition at line 207 of file kos.h.

#define ERR_FS_NOT_SUPPORT   -11

Definition at line 209 of file kos.h.

#define ERR_FS_NOTFIND   -14

Definition at line 211 of file kos.h.

#define ERR_FS_PROTECT   -13

Definition at line 210 of file kos.h.

#define ERR_FS_UNKNOWN   -100

Definition at line 214 of file kos.h.

#define FALSE   0

Definition at line 53 of file kos.h.

Referenced by gControl::AcceptFocus().

#define FAT32_SUPPORT   1

Definition at line 133 of file kos.h.

#define fdelete (   a)    kos_fdelete(a);

Definition at line 239 of file kos.h.

#define FILE_APPEND   0x00000003

Definition at line 193 of file kos.h.

#define FILE_READONLY   0x00000001

Definition at line 191 of file kos.h.

#define FILE_READWRITE   0x00000002

Definition at line 192 of file kos.h.

#define FS_SEEK_CUR   1

Definition at line 196 of file kos.h.

#define FS_SEEK_END   2

Definition at line 197 of file kos.h.

#define FS_SEEK_SET   0

Definition at line 195 of file kos.h.

#define KOS_ARCHIVE_ATTRIBUTE   (1<<5)

Read-only bit for archive attribute field.

Definition at line 189 of file kos.h.

#define KOS_ERR_INVALIDPTR   -200

Definition at line 222 of file kos.h.

#define KOS_FUNC_CHDIR   7

Definition at line 110 of file kos.h.

#define KOS_FUNC_CHECKINSERT   17

Definition at line 120 of file kos.h.

#define KOS_FUNC_CHECKPROTECT   18

Definition at line 121 of file kos.h.

#define KOS_FUNC_FATTR   15

Definition at line 118 of file kos.h.

#define KOS_FUNC_FCLOSE   3

Definition at line 105 of file kos.h.

#define KOS_FUNC_FDELETE   5

Definition at line 107 of file kos.h.

#define KOS_FUNC_FOPEN   0

Definition at line 102 of file kos.h.

#define KOS_FUNC_FREAD   1

Definition at line 103 of file kos.h.

#define KOS_FUNC_FRENAME   6

Definition at line 109 of file kos.h.

#define KOS_FUNC_FSEEK   4

Definition at line 106 of file kos.h.

#define KOS_FUNC_FWRITE   2

Definition at line 104 of file kos.h.

#define KOS_FUNC_GETFILEINFO   8

Definition at line 111 of file kos.h.

#define KOS_FUNC_GETFIRSTDIR   9

Definition at line 112 of file kos.h.

#define KOS_FUNC_GETFIRSTFILE   12

Definition at line 115 of file kos.h.

#define KOS_FUNC_GETNEXTDIR   10

Definition at line 113 of file kos.h.

#define KOS_FUNC_GETNEXTFILE   13

Definition at line 116 of file kos.h.

#define KOS_FUNC_GETPREVDIR   11

Definition at line 114 of file kos.h.

#define KOS_FUNC_GETPREVFILE   14

Definition at line 117 of file kos.h.

#define KOS_FUNC_GETSIZE   16

Definition at line 119 of file kos.h.

#define KOS_HIDDEN_ATTRIBUTE   (1<<1)

Read-only bit for hidden file attribute field.

Definition at line 185 of file kos.h.

#define KOS_MEM_FREE   0x0000

Definition at line 91 of file kos.h.

#define KOS_MEM_GLOBAL   0x1000

Definition at line 93 of file kos.h.

#define KOS_MEM_HEAP0   0x0100

Definition at line 97 of file kos.h.

#define KOS_MEM_LOCAL   0x2000

Definition at line 95 of file kos.h.

#define KOS_MODULE_FILESYSTEM   1

Definition at line 100 of file kos.h.

#define KOS_READMODE   1

Definition at line 125 of file kos.h.

#define KOS_READONLY_ATTRIBUTE   (1)

Read-only bit for read-only attribute field.

Definition at line 183 of file kos.h.

#define KOS_SYSTEM_ATTRIBUTE   (1<<2)

Read-only bit for system file attribute field.

Definition at line 187 of file kos.h.

#define KOS_WRITEMODE   2

Definition at line 126 of file kos.h.

#define NEW_FILE_NAME

Definition at line 136 of file kos.h.

#define NULL   0

Definition at line 38 of file kos.h.

#define size_t   unsigned int

Definition at line 28 of file kos.h.

#define SIZE_T   size_t

Definition at line 32 of file kos.h.

#define SUCCESS   0

Definition at line 220 of file kos.h.

#define TIME_T   unsigned int

Definition at line 42 of file kos.h.

#define TRUE   (! FALSE)

Typedef Documentation

typedef int BOOL

Definition at line 24 of file kos.h.

typedef char BYTE

Definition at line 22 of file kos.h.

typedef struct FILE_INFO DIR_INFO
typedef U32(* FUNC0PTR)()

Definition at line 45 of file kos.h.

typedef U32(* FUNC1PTR)(U32)

Definition at line 46 of file kos.h.

typedef U32(* FUNC2PTR)(U32, U32)

Definition at line 47 of file kos.h.

typedef U32(* FUNC3PTR)(U32, U32, U32)

Definition at line 48 of file kos.h.

typedef U32(* FUNC_PTR)()

Definition at line 44 of file kos.h.

typedef S32 H_FILE

Definition at line 178 of file kos.h.

typedef char* P_BYTE

Definition at line 23 of file kos.h.

typedef struct FILE_INFO * P_DIR_INFO
typedef struct FILE_INFO * P_FILE_INFO
typedef struct KDATETIME * P_KDATETIME
typedef unsigned char * P_U8

Definition at line 20 of file kos.h.

typedef void* P_VOID

Definition at line 25 of file kos.h.

typedef short S16

Definition at line 19 of file kos.h.

typedef int S32

Definition at line 17 of file kos.h.

typedef char S8

Definition at line 21 of file kos.h.

typedef unsigned short U16

Definition at line 18 of file kos.h.

typedef unsigned int U32

Definition at line 16 of file kos.h.

typedef unsigned char U8

Definition at line 20 of file kos.h.


Function Documentation

S32 kos_beep ( U32  freq,
TIME_T  time,
U32  override 
)
S32 kos_chdir ( P_BYTE  pDir)

Change system current directory.

The format of the path is unix-like. For example: / is the root, /ARCHIVES/TEMP is the sub-sub-directory TEMP in ARCHIVE, in / Example:

 if (kos_chdir("/TEMP")==SUCCESS)
 {
 }
Returns:
SUCCESS (0) if ok, KOS_ERR_INVALIDPTR -200 else.
S32 kos_CheckDiskInsert ( void  )

Check if a valid SD is inserted.

See also:
kos_checkDiskProtect kos_getDiskFreeSize
Returns:
1 if a disk is inserted, 0 else.
S32 kos_CheckDiskProtect ( void  )

Check if a the SD is write-protected.

See also:
kos_checkDiskInsert kos_getDiskFreeSize
Returns:
1 if protected, 0 else.
void kos_ClearLcd ( void  )
S32 kos_fattr ( P_BYTE  fname,
U8  attr 
)

Set file attributes.

Returns:
SUCCESS (0) if ok, KOS_ERR_INVALIDPTR -200 else.
S32 kos_fclose ( H_FILE  fd)
S32 kos_fdelete ( P_BYTE  fname)
H_FILE kos_fopen ( P_BYTE  fname,
U8  mode 
)
SIZE_T kos_fread ( H_FILE  fd,
P_BYTE  buf,
U32  length 
)
S32 kos_free ( void *  pMemory)
S32 kos_frename ( P_BYTE  oldname,
P_BYTE  newname 
)

FIXME: this function does not seem to work as it should (return -200 err every time)

Returns:
SUCCESS (0) if ok, KOS_ERR_INVALIDPTR -200 else.
S32 kos_fseek ( H_FILE  fd,
S32  offset,
U32  mode 
)
SIZE_T kos_fwrite ( H_FILE  fd,
P_BYTE  buf,
U32  length 
)
S32 kos_GetDiskFreeSize ( void  )

Get disk free size in bytes.

See also:
kos_checkDiskProtect kos_checkDiskInsert
Returns:
free bytes if ok, KOS_ERR_INVALIDPTR -200 else.
S32 kos_GetFirstDirInfo ( P_DIR_INFO  pInfo)

Fill a FILE_INFO structure of the first sub-directory of the current directory.

Example: see kos_getFirstFileInfo example (change File by Dir).

See also:
kos_getFirstFileInfo kos_getNextDirInfo kos_getPrevDirInfo
Returns:
SUCCESS (0) if ok, KOS_ERR_INVALIDPTR -200 else.
S32 kos_GetFirstFileInfo ( P_FILE_INFO  pInfo)

Fill a FILE_INFO structure of the first file of the current directory.

See also:
kos_getNextFileInfo kos_getPrevFileInfo Example:
void print_file_info(P_FILE_INFO pInfo)
{
    printf("%s : %d bytes\n", pInfo->file_name, pInfo->size);
    printf("Attr: %b %b\n", pInfo->attribute, pInfo->ext_attr);
    printf("Las.Acc: %d %d %d\n", pInfo->last_access_date.day,
           pInfo->last_access_date.month, pInfo->last_access_date.year);
    printf("T: %d %d %d\n", pInfo->create_date.date.day,
           pInfo->create_date.date.month, pInfo->create_date.date.year);
    printf("T: %d %d %d\n", pInfo->create_date.time.hours,
           pInfo->create_date.time.minutes,
           pInfo->create_date.time.seconds);
    printf("T: %d %d %d\n", pInfo->last_modifier.time.hours,
           pInfo->last_modifier.time.minutes,
           pInfo->last_modifier.time.seconds);
}

int main()
{
    FILE_INFO Info;
    if (kos_GetFirstFileInfo(&Info) == SUCCESS)
    {
        print_file_info(&Info);
        keyb_waitKeyPressed();
        unsigned int j;
        for (j = 0; kos_GetNextFileInfo(&Info, j++) == SUCCESS; )
        {
            print_file_info(&Info);
            keyb_waitKeyPressed();
        }
    }
    else
    {
        printf("No files\n");
        keyb_waitKeyPressed();
    }
}
Returns:
SUCCESS (0) if ok, KOS_ERR_INVALIDPTR -200 else.
FUNC_PTR kos_GetFuncEntry ( U32  module,
U32  index 
)
S32 kos_GetNextDirInfo ( P_DIR_INFO  pInfo,
U32  index 
)

Fill a DIR_INFO structure of the next 'indexed' sub-directory of the current directory.

You *must* call kos_getFirstDirInfo(P_DIR_INFO pInfo) first to ensure that the system current file ID is pointing to the first file of the current directory

See also:
kos_getFirstDirInfo kos_getPrevDirInfo
Parameters:
pInfo[out] pointer to structure
index[in] index of current sub-directory
Returns:
SUCCESS (0) if ok, KOS_ERR_INVALIDPTR -200 else.
S32 kos_GetNextFileInfo ( P_FILE_INFO  pInfo,
U32  index 
)

Fill a FILE_INFO structure of the next 'indexed' file of the current directory.

You *must* call kos_getFirstFileInfo(P_FILE_INFO pInfo) first to ensure that the system current file ID is pointing to the first file of the current directory

See also:
kos_getFirstFileInfo kos_getPrevFileInfo
Parameters:
pInfo[out] pointer to structure
index[in] index of current file in the directory
Returns:
SUCCESS (0) if ok, KOS_ERR_INVALIDPTR -200 else.
S32 kos_GetPrevDirInfo ( P_DIR_INFO  pInfo,
U32  index 
)

Fill a DIR_INFO structure of the previous 'indexed' sub-directory of the current directory.

You *must* call kos_getFirstDirInfo(P_DIR_INFO pInfo) first to ensure that the system current file ID is pointing to the first file of the current directory

See also:
kos_getFirstDirInfo kos_getNextDirInfo
Parameters:
pInfo[out] pointer to structure
index[in] index of current sub-directory
Returns:
SUCCESS (0) if ok, KOS_ERR_INVALIDPTR -200 else.
S32 kos_GetPrevFileInfo ( P_FILE_INFO  pInfo,
U32  index 
)

Fill a FILE_INFO structure of the previous 'indexed' file of the current directory.

You *must* call kos_getFirstFileInfo(P_FILE_INFO pInfo) first to ensure that the system current file ID is pointing to the first file of the current directory

See also:
kos_getFirstFileInfo kos_getNextFileInfo
Parameters:
pInfo[out] pointer to structure
index[in] index of current file in the directory
Returns:
SUCCESS (0) if ok, KOS_ERR_INVALIDPTR -200 else.
P_BYTE kos_getSerialNumber ( void  )
S32 kos_GetSpecialFileInfo ( P_BYTE  fname,
P_FILE_INFO  pInfo 
)

FIXME: Still confused by this.

U32 kos_GetSysTickTime ( )
U32 kos_LCDGetContrast ( void  )
void kos_LCDSetContrast ( U32  contrast)
void* kos_malloc ( SIZE_T  size)
void kos_PutDecNumber ( U32  dx,
U32  dy,
U32  value,
U32  bit 
)
void kos_PutHexNumber ( U32  dx,
U32  dy,
U32  value 
)
U32 kos_PutString ( U32  dx,
U32  dy,
P_VOID  ptr 
)
void kos_Reset ( void  )
void kos_ResetSD ( void  )

Reset calculator OS file system.

Call to reinitiate SD card system after using the FSystem library.

See also:
kos_checkDiskInsert kos_getDiskFreeSize
Returns:
1 if protected, 0 else.