hpsys.h

Go to the documentation of this file.
00001 //& ****************************************************************************
00002 //&
00003 //& Written by Ingo Blank, August 2004
00004 //&
00005 //& Copyright (C) 2004 The HP-GCC Development Team
00006 //&
00007 //& ****************************************************************************
00008 //&
00009 //&
00010 //& This file is part of HP-GCC.
00011 //&
00012 //& HP-GCC is free software; you can redistribute it and/or modify
00013 //& it under the terms of the GNU General Public License as published by
00014 //& the Free Software Foundation; either version 2, or (at your option)
00015 //& any later version.
00016 //& 
00017 //& HP-GCC is distributed in the hope that it will be useful,
00018 //& but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 //& MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020 //& GNU General Public License for more details.
00021 //& 
00022 //& You should have received a copy of the GNU General Public License
00023 //& along with HP-GCC; see the file COPYING. 
00024 //&
00025 //& As a special exception, you may use this file as part of a free software
00026 //& library without restriction.  Specifically, if other files instantiate
00027 //& templates or use macros or inline functions from this file, or you compile
00028 //& this file and link it with other files to produce an executable, this
00029 //& file does not by itself cause the resulting executable to be covered by
00030 //& the GNU General Public License.  This exception does not however
00031 //& invalidate any other reasons why the executable file might be covered by
00032 //& the GNU General Public License.
00033 //&
00034 //& ****************************************************************************
00035 
00036 
00037 
00042 #ifndef _HPSYS_H
00043 #define _HPSYS_H
00044 
00045 // LONG TYPE DEFINITION, ADDED BY CLAUDIO 01/14/05
00046 #ifndef _LONGLONG_DEF
00047 typedef unsigned long long ULONGLONG;
00048 typedef long long LONGLONG;
00049 #define _LONGLONG_DEF
00050 #endif
00051 
00052 
00053 #include <kos.h>
00054 
00055 #ifndef EXTERN
00056 #define EXTERN extern
00057 #endif
00058 
00059 #ifndef NULL
00060 #define NULL 0
00061 #endif
00062 
00063 
00064 // atexit machinery added by ibl 2005-01-31
00065 
00066 typedef void (*ATEXITFUNC)();
00067 
00068 typedef struct _atexit_entry {
00069     ATEXITFUNC f;
00070     struct _atexit_entry *next;
00071 } ATEXIT_ENTRY;
00072 
00073 int atexit(ATEXITFUNC f);
00074 
00076 char  *sys_bcd2str(unsigned int BCD);
00077 
00079 #define sys_bcd2bin(BCD) sys_bcd2bin_nibbles(BCD,2)
00081 unsigned int sys_bcd2bin_nibbles(unsigned int  BCD,int nibbles);
00082 
00083 
00084 
00085 
00086 
00087 // arithmetics
00088 
00089  typedef struct
00090  {
00091  LONGLONG quot;
00092  LONGLONG rem;
00093  } lldiv_t;
00094 
00095  lldiv_t lldiv(LONGLONG,LONGLONG);
00096 
00111 unsigned divlu2(unsigned num_h,unsigned num_l,unsigned den,unsigned *rem);
00112 
00113 ULONGLONG
00114 udiv64(ULONGLONG nom, unsigned den, unsigned *rem);
00115 
00116 LONGLONG
00117 sdiv64(LONGLONG nom, int den, int *rem);
00118 
00119 
00120 // loader globals
00121 
00123 
00173 // Now defined in "saturn.h"
00174 // <ibl ; 2004-11-24>
00175 // EXTERN unsigned int _saturn_cpu; 
00176 
00177 EXTERN unsigned int _ram_base_addr;
00178 EXTERN unsigned int _mmu_table_addr;
00179 EXTERN unsigned int ram_size;
00180 EXTERN unsigned int _heap_base_addr;
00181 EXTERN unsigned int _code_base_addr;
00182 
00183 // HARDWARE CONSTANTS
00184 
00185 #define LCD_REGS    0x07300000
00186 #define CLK_REGS    0x07200000
00187 #define RTC_REGS    0x07B00000 // < ibl ; 2005-06-23 >
00188 
00189 //ARM interrupts
00190 void sys_intOff(); 
00191 void sys_intOn();
00192 
00193 // power management routines
00194 void sys_slowOn(); 
00195 void sys_slowOff();
00196 int sys_is_slowOn();
00197 
00198 // CPU CLOCK SAVE/RESTORE
00200 void sys_clksave(int *buf);
00202 void sys_clkrestore(int *buf);
00203 
00204 
00205 
00206 
00207 // time related routines
00208 
00209 typedef struct
00210 {
00211     ULONGLONG current;
00212     unsigned last_val : 16;
00213     unsigned timer : 3;
00214     unsigned inited : 1;
00215 } sys_timer_t;
00216 
00217 #define SYS_TIMER_INITIALIZER { 0, 0, 0, 0 }
00218 #define SYS_TIMER_INITIALIZER_NUM(n) { 0, 0, n, 0 }
00219 
00220 ULONGLONG sys_updateTimer(sys_timer_t *timer);
00221 
00222 void sys_sleep(unsigned int millis);
00223 
00225 void sys_waitTicks(unsigned int time); 
00226 void sys_setupTimers();
00227 void sys_restoreTimers();
00228 
00229 
00231 
00236 unsigned short int sys_getPWMCounter0();
00237 
00238 
00240 
00245 int sys_RTC_seconds();
00246 
00247 
00248 
00249 // VIDEO MODE CONSTANTS
00250 #define MODE_MONO 0
00251 #define MODE_4GRAY 1
00252 #define MODE_16GRAY 2
00253 
00255 void sys_LCDSynch();
00257 void sys_lcdfix();
00259 void sys_lcdsave(int *buffer);
00261 void sys_lcdrestore(int *buffer);
00267 int sys_lcdsetmode(int mode,int *physicalbuffer);
00268 // ! Returns the screen height in pixels
00269 int sys_lcdgetheight();
00270 
00271 
00272 
00273 
00274 // mmu mapping functions
00276 EXTERN int sys_map_v2p(unsigned int vaddr);
00278 EXTERN int sys_map_p2v(unsigned int paddr);
00280 int sys_mem_classify(int addr);
00282 void sys_flush_cache(int *ptr,int size);
00283 
00284 // mmu independent physical malloc
00285 
00286 void *sys_phys_malloc(size_t);
00287 
00288 
00289 // particular functions
00290 
00297 EXTERN void sys_playTone(unsigned int tone, unsigned int duration);
00298 EXTERN void sys_waitTicks (unsigned int time);
00299 EXTERN void setDisplayPlane(unsigned char * plane);
00300 
00301 EXTERN void sys_playTone2(unsigned int time, unsigned int duration);
00302 
00304 int sys_isRTCTick();
00306 unsigned char sys_setRTCTickPeriod(unsigned char n);
00308 void sys_waitRTCTicks(int count);
00309 
00310 
00311 // < ibl >
00312 
00322 int sys_delta_seconds(int t_start, int t_end);
00323 
00324 // < ibl ; 2005-02-08 >
00325 
00334 void sys_error(const char *msg, int code);
00335 
00336 // < ibl ; 2005-05-16 >
00337 
00345 void *sys_chkptr(void *p);
00346 
00347 
00348 
00349 #endif 
00350 

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