hpsys.h File Reference

Header file for system functions. More...

#include <kos.h>

Go to the source code of this file.

Data Structures

struct  _atexit_entry
struct  lldiv_t
struct  sys_timer_t

Defines

#define EXTERN   extern
#define sys_bcd2bin(BCD)   sys_bcd2bin_nibbles(BCD,2)
 Convert a BCD format BYTE (least significant 2 digits) to an integer value.
#define LCD_REGS   0x07300000
#define CLK_REGS   0x07200000
#define RTC_REGS   0x07B00000
#define SYS_TIMER_INITIALIZER   { 0, 0, 0, 0 }
#define SYS_TIMER_INITIALIZER_NUM(n)   { 0, 0, n, 0 }
#define MODE_MONO   0
#define MODE_4GRAY   1
#define MODE_16GRAY   2

Typedefs

typedef unsigned long long ULONGLONG
typedef long long LONGLONG
typedef void(*) ATEXITFUNC ()
typedef _atexit_entry ATEXIT_ENTRY

Functions

int atexit (ATEXITFUNC f)
char * sys_bcd2str (unsigned int BCD)
 Convert a BCD format number to an hexa value.
unsigned int sys_bcd2bin_nibbles (unsigned int BCD, int nibbles)
 Convert the least significant n (=nibbles, max. 8) digits of a BCD formatted number to it's integer value.
lldiv_t lldiv (LONGLONG, LONGLONG)
unsigned divlu2 (unsigned num_h, unsigned num_l, unsigned den, unsigned *rem)
 Unsigned 64/32 bit division.
ULONGLONG udiv64 (ULONGLONG nom, unsigned den, unsigned *rem)
 Unsigned 64/32 bit division with 64 bit quotient.
LONGLONG sdiv64 (LONGLONG nom, int den, int *rem)
 Signed 64/32 bit division with 64 bit quotient.
void sys_intOff ()
void sys_intOn ()
void sys_slowOn ()
void sys_slowOff ()
int sys_is_slowOn ()
void sys_clksave (int *buf)
 Save CPU clock state to a buffer (6-words).
void sys_clkrestore (int *buf)
 Restore CPU clock from a buffer (6-words).
ULONGLONG sys_updateTimer (sys_timer_t *timer)
void sys_sleep (unsigned int millis)
void sys_waitTicks (unsigned int time)
 numers of ticks at 750kHz to wait for
void sys_setupTimers ()
void sys_restoreTimers ()
unsigned short int sys_getPWMCounter0 ()
 Get PWM counter 0.
int sys_RTC_seconds ()
 Get date in seconds from RTC.
void sys_LCDSynch ()
 Wait for LCD synchro.
void sys_lcdfix ()
 Fix LCD clock rate at any CPU speed.
void sys_lcdsave (int *buffer)
 Save LCD controller state (buffer size must be 17 words min.).
void sys_lcdrestore (int *buffer)
 Restore LCD controller state from buffer (saved by sys_lcdsave).
int sys_lcdsetmode (int mode, int *physicalbuffer)
 Sets the corresponding video mode. Returns scanline width in bytes.
int sys_lcdgetheight ()
EXTERN int sys_map_v2p (unsigned int vaddr)
 Convert a virtual address to its physical bus address.
EXTERN int sys_map_p2v (unsigned int paddr)
 Convert a physical bus address to its virtual address.
int sys_mem_classify (int addr)
 Classify a memory address 0=System; 1=Port1; 2=Main.
void sys_flush_cache (int *ptr, int size)
 Flush write-back caches on the specified block of memory.
void * sys_phys_malloc (size_t)
EXTERN void sys_playTone (unsigned int tone, unsigned int duration)
EXTERN void setDisplayPlane (unsigned char *plane)
EXTERN void sys_playTone2 (unsigned int time, unsigned int duration)
int sys_isRTCTick ()
 Returns '1' if an RTC Interrupt Tick has occured since it was last called.
unsigned char sys_setRTCTickPeriod (unsigned char n)
 Ajdusts the rate of the RTC Tick. Remember to restore the default when done!
void sys_waitRTCTicks (int count)
 Waits for 'count' RTC Ticks to elapse.
int sys_delta_seconds (int t_start, int t_end)
 Compute the time span (in seconds) between t_start and t_end. Account for possible wrap around at midnight.
void sys_error (const char *msg, int code)
 Output msg to screen, set errno=code and exit if code < 0.
void * sys_chkptr (void *p)
 Check pointer after malloc'ing and exit via sys_error() if NULL.

Variables

EXTERN unsigned int _ram_base_addr
 Value of r1 register at the begining of execution.
EXTERN unsigned int _mmu_table_addr
EXTERN unsigned int ram_size
EXTERN unsigned int _heap_base_addr
EXTERN unsigned int _code_base_addr


Detailed Description

Header file for system functions.

Definition in file hpsys.h.


Define Documentation

#define CLK_REGS   0x07200000

Definition at line 186 of file hpsys.h.

#define EXTERN   extern

Definition at line 56 of file hpsys.h.

#define LCD_REGS   0x07300000

Definition at line 185 of file hpsys.h.

#define MODE_16GRAY   2

Definition at line 252 of file hpsys.h.

#define MODE_4GRAY   1

Definition at line 251 of file hpsys.h.

#define MODE_MONO   0

Definition at line 250 of file hpsys.h.

#define RTC_REGS   0x07B00000

Definition at line 187 of file hpsys.h.

#define sys_bcd2bin ( BCD   )     sys_bcd2bin_nibbles(BCD,2)

Convert a BCD format BYTE (least significant 2 digits) to an integer value.

Definition at line 79 of file hpsys.h.

#define SYS_TIMER_INITIALIZER   { 0, 0, 0, 0 }

Definition at line 217 of file hpsys.h.

#define SYS_TIMER_INITIALIZER_NUM (  )     { 0, 0, n, 0 }

Definition at line 218 of file hpsys.h.


Typedef Documentation

typedef struct _atexit_entry ATEXIT_ENTRY

typedef void(*) ATEXITFUNC()

Definition at line 66 of file hpsys.h.

typedef long long LONGLONG

Definition at line 48 of file hpsys.h.

typedef unsigned long long ULONGLONG

Definition at line 47 of file hpsys.h.


Function Documentation

int atexit ( ATEXITFUNC  f  ) 

unsigned divlu2 ( unsigned  num_h,
unsigned  num_l,
unsigned  den,
unsigned *  rem 
)

Unsigned 64/32 bit division.

lldiv_t lldiv ( LONGLONG  ,
LONGLONG   
)

LONGLONG sdiv64 ( LONGLONG  nom,
int  den,
int *  rem 
)

Signed 64/32 bit division with 64 bit quotient.

EXTERN void setDisplayPlane ( unsigned char *  plane  ) 

unsigned int sys_bcd2bin_nibbles ( unsigned int  BCD,
int  nibbles 
)

Convert the least significant n (=nibbles, max. 8) digits of a BCD formatted number to it's integer value.

char* sys_bcd2str ( unsigned int  BCD  ) 

Convert a BCD format number to an hexa value.

void sys_chkptr ( void *  p  ) 

Check pointer after malloc'ing and exit via sys_error() if NULL.

Parameters:
p the pointer to be checked

void sys_clkrestore ( int *  buf  ) 

Restore CPU clock from a buffer (6-words).

void sys_clksave ( int *  buf  ) 

Save CPU clock state to a buffer (6-words).

int sys_delta_seconds ( int  t_start,
int  t_end 
)

Compute the time span (in seconds) between t_start and t_end. Account for possible wrap around at midnight.

Parameters:
t_start Start time
t_end End time

void sys_error ( const char *  msg,
int  code 
)

Output msg to screen, set errno=code and exit if code < 0.

Parameters:
msg The message text or NULL for none
code The error code, forwarded to exit()

void sys_flush_cache ( int *  ptr,
int  size 
)

Flush write-back caches on the specified block of memory.

unsigned short int sys_getPWMCounter0 (  ) 

Get PWM counter 0.

Returns:
The current value
The counter goes from 0 to 65536.

void sys_intOff (  ) 

void sys_intOn (  ) 

int sys_is_slowOn (  ) 

int sys_isRTCTick (  ) 

Returns '1' if an RTC Interrupt Tick has occured since it was last called.

void sys_lcdfix (  ) 

Fix LCD clock rate at any CPU speed.

int sys_lcdgetheight (  ) 

void sys_lcdrestore ( int *  buffer  ) 

Restore LCD controller state from buffer (saved by sys_lcdsave).

void sys_lcdsave ( int *  buffer  ) 

Save LCD controller state (buffer size must be 17 words min.).

int sys_lcdsetmode ( int  mode,
int *  physicalbuffer 
)

Sets the corresponding video mode. Returns scanline width in bytes.

Parameters:
mode = MODE_MONO (=0), MODE_4GRAY (=1) or MODE_16GRAY (=2)
physicalbuffer = Video frame memory, pointing to physical address

void sys_LCDSynch (  ) 

Wait for LCD synchro.

EXTERN int sys_map_p2v ( unsigned int  paddr  ) 

Convert a physical bus address to its virtual address.

EXTERN int sys_map_v2p ( unsigned int  vaddr  ) 

Convert a virtual address to its physical bus address.

int sys_mem_classify ( int  addr  ) 

Classify a memory address 0=System; 1=Port1; 2=Main.

void* sys_phys_malloc ( size_t   ) 

EXTERN void sys_playTone ( unsigned int  tone,
unsigned int  duration 
)

EXTERN void sys_playTone2 ( unsigned int  time,
unsigned int  duration 
)

void sys_restoreTimers (  ) 

int sys_RTC_seconds (  ) 

Get date in seconds from RTC.

Returns:
The current time in seconds
The total number of seconds 3600*H+60*M+S.

unsigned char sys_setRTCTickPeriod ( unsigned char  n  ) 

Ajdusts the rate of the RTC Tick. Remember to restore the default when done!

void sys_setupTimers (  ) 

void sys_sleep ( unsigned int  millis  ) 

void sys_slowOff (  ) 

void sys_slowOn (  ) 

ULONGLONG sys_updateTimer ( sys_timer_t timer  ) 

void sys_waitRTCTicks ( int  count  ) 

Waits for 'count' RTC Ticks to elapse.

EXTERN void sys_waitTicks ( unsigned int  time  ) 

numers of ticks at 750kHz to wait for

ULONGLONG udiv64 ( ULONGLONG  nom,
unsigned  den,
unsigned *  rem 
)

Unsigned 64/32 bit division with 64 bit quotient.


Variable Documentation

EXTERN unsigned int _code_base_addr

Definition at line 181 of file hpsys.h.

EXTERN unsigned int _heap_base_addr

Definition at line 180 of file hpsys.h.

EXTERN unsigned int _mmu_table_addr

Definition at line 178 of file hpsys.h.

EXTERN unsigned int _ram_base_addr

Value of r1 register at the begining of execution.

See post of Robert Hildinger: "The R1 register contains the base address for all the ARM globals, which can be used to access all of the Saturn registers. Altering this register will not affect the calling code. The LR register contains the return address to get back into Saturn emulation."

API INFORMATION
---------------

So far there is no real API information available, although experimentally I've been able to determine the following offsets from the global base register for accessing the emulated Saturn CPU registers:

Base (R1) offset Description
---------------------------------------

0x90C Saturn register A (low order 8 nibbles)
0x910 Saturn register A (high order 8 nibbles)
0x914 Saturn register B (low order 8 nibbles)
0x918 Saturn register B (high order 8 nibbles)
0x91C Saturn register C (low order 8 nibbles)
0x920 Saturn register C (high order 8 nibbles)
0x924 Saturn register D (low order 8 nibbles)
0x928 Saturn register D (high order 8 nibbles)

0x92C Saturn register R0 (low order 8 nibbles)
0x930 Saturn register R0 (high order 8 nibbles)
0x934 Saturn register R1 (low order 8 nibbles)
0x938 Saturn register R1 (high order 8 nibbles)
0x93C Saturn register R2 (low order 8 nibbles)
0x940 Saturn register R2 (high order 8 nibbles)
0x944 Saturn register R3 (low order 8 nibbles)
0x948 Saturn register R3 (high order 8 nibbles)
0x94C Saturn register R4 (low order 8 nibbles)
0x950 Saturn register R4 (high order 8 nibbles)

0x954 Saturn register d0
0x958 Saturn register d1
0x95C Saturn register P
0x968 Saturn register ST
0x96C Saturn register HST
0x970 Saturn CARRY flag
0x974 Saturn DECIMAL_MODE flag

Definition at line 177 of file hpsys.h.

EXTERN unsigned int ram_size

Definition at line 179 of file hpsys.h.


Generated on Sat Feb 17 00:05:26 2007 for HP-GCCLibrary by  doxygen 1.5.0