source: rtems/c/src/lib/libbsp/arm/nds/libnds/include/nds/bios.h @ 49a40165

4.104.114.9
Last change on this file since 49a40165 was 49a40165, checked in by Joel Sherrill <joel.sherrill@…>, on Aug 19, 2008 at 3:47:14 PM

2008-08-19 Joel Sherrill <joel.sherrill@…>

  • dswifi/arm7/makefile, dswifi/include/netinet/in.h, libnds/basicARM7/source/defaultARM7.c, libnds/include/gbfs.h, libnds/include/nds/bios.h, libnds/include/nds/card.h, libnds/include/nds/dma.h, libnds/include/nds/interrupts.h, libnds/include/nds/ipc.h, libnds/include/nds/jtypes.h, libnds/include/nds/registers_alt.h, libnds/include/nds/system.h, libnds/include/nds/timers.h, libnds/include/nds/arm7/audio.h, libnds/include/nds/arm7/clock.h, libnds/include/nds/arm7/serial.h, libnds/include/nds/arm7/touch.h, libnds/include/nds/arm9/boxtest.h, libnds/include/nds/arm9/cache.h, libnds/include/nds/arm9/console.h, libnds/include/nds/arm9/ndsmotion.h, libnds/include/nds/arm9/video.h, libnds/include/nds/arm9/videoGL.h, libnds/source/arm7/audio.c, libnds/source/arm7/clock.c, libnds/source/arm7/microphone.c, libnds/source/arm7/touch.c, libnds/source/arm7/userSettings.c, libnds/source/arm9/boxtest.c, libnds/source/arm9/gurumeditation.c, libnds/source/arm9/ndsmotion.c, libnds/source/arm9/videoGL.c, libnds/source/common/card.c, libnds/source/common/interruptDispatcher.S, touchscreen/reco.c: Fix various warnings by fixing prototypes. Remove unused .bin files. Convert all files to UNIX CF/LF.
  • libnds/source/arm9/COS.bin, libnds/source/arm9/SIN.bin, libnds/source/arm9/TAN.bin, libnds/source/arm9/default_font.bin: Removed.
  • Property mode set to 100644
File size: 10.1 KB
Line 
1/*---------------------------------------------------------------------------------
2  $Id$
3
4  BIOS functions
5
6  Copyright (C) 2005
7    Michael Noland (joat)
8    Jason Rogers (dovoto)
9    Dave Murphy (WinterMute)
10
11  This software is provided 'as-is', without any express or implied
12  warranty.  In no event will the authors be held liable for any
13  damages arising from the use of this software.
14
15  Permission is granted to anyone to use this software for any
16  purpose, including commercial applications, and to alter it and
17  redistribute it freely, subject to the following restrictions:
18
19  1.  The origin of this software must not be misrepresented; you
20      must not claim that you wrote the original software. If you use
21      this software in a product, an acknowledgment in the product
22      documentation would be appreciated but is not required.
23  2.  Altered source versions must be plainly marked as such, and
24      must not be misrepresented as being the original software.
25  3.  This notice may not be removed or altered from any source
26      distribution.
27
28---------------------------------------------------------------------------------*/
29
30#ifndef BIOS_H_INCLUDE
31#define BIOS_H_INCLUDE
32
33/*!     \file bios.h
34
35        \brief Nintendo DS Bios functions
36*/
37
38
39#ifdef __cplusplus
40extern "C" {
41#endif
42
43
44#include <nds/jtypes.h>
45
46
47typedef struct DecompressionStream {
48  int (*getSize)(uint8 * source, uint16 * dest, uint32 r2);
49  int (*getResult)(uint8 * source); // can be NULL
50  uint8 (*readByte)(uint8 * source);
51} PACKED TDecompressionStream;
52
53
54typedef struct UnpackStruct {
55  uint16 sourceSize; // in bytes
56  uint8 sourceWidth;
57  uint8 destWidth;
58  uint32 dataOffset;
59} PACKED TUnpackStruct, * PUnpackStruct;
60
61
62/*! \fn swiSoftReset(void)
63        \brief reset the DS.
64
65*/
66void swiSoftReset(void);
67
68/*! \fn swiDelay( uint32 duration)
69        \brief delay
70
71   Delays for for a period X + Y*duration where X is the swi overhead and Y is a cycle of
72<CODE><PRE>
73     loop:
74       sub r0, #1
75       bgt loop
76</PRE></CODE>
77  of thumb fetches in BIOS memory
78        \param duration
79                length of delay
80        \note
81                Duration should be 1 or more, a duration of 0 is a huge delay
82
83*/
84void swiDelay(uint32 duration);
85
86/*! \fn swiIntrWait(int waitForSet, uint32 flags)
87
88        \brief wait for interrupt(s) to occur
89
90        \param waitForSet
91                0: Return if the interrupt has already occured
92                1: Wait until the interrupt has been set since the call
93        \param flags
94                interrupt mask to wait for
95
96*/
97
98void swiIntrWait(int waitForSet, uint32 flags);
99
100/*! \fn  swiWaitForVBlank(void)
101        \brief Wait for vblank interrupt
102
103        Waits for a vertical blank interrupt
104
105        \note Identical to calling swiIntrWait(1, 1)
106*/
107
108void swiWaitForVBlank(void);
109
110/*!     \fn int swiDivide(int numerator, int divisor)
111        \param numerator
112                signed integer to divide
113        \param divisor
114                signed integer to divide by
115        \return numerator / divisor
116
117        \fn int swiRemainder(int numerator, int divisor)
118        \param numerator
119                signed integer to divide
120        \param divisor
121                signed integer to divide by
122        \return numerator % divisor
123
124        \fn void swiDivMod(int numerator, int divisor, int * result, int * remainder)
125        \param numerator
126                signed integer to divide
127        \param divisor
128                signed integer to divide by
129        \param result
130                pointer to integer set to numerator / divisor
131        \param remainder
132                pointer to integer set to numerator % divisor
133*/
134
135int swiDivide(int numerator, int divisor);
136int swiRemainder(int numerator, int divisor);
137void swiDivMod(int numerator, int divisor, int * result, int * remainder);
138
139/*!     \fn swiCopy(const void * source, void * dest, int flags)
140        \param source
141                pointer to transfer source
142        \param dest
143                dest = pointer to transfer destination
144        \param flags
145                copy mode and size
146//  flags(26) = transfer width (0: halfwords, 1: words)
147//  flags(24) = transfer mode (0: copy, 1: fill)
148//  flags(20..0) = transfer count (always in words)
149
150        \fn swiFastCopy (const void * source, void * dest, int flags)
151        \param source
152                pointer to transfer source
153        \param dest
154                dest = pointer to transfer destination
155        \param flags
156                copy mode and size
157//  flags(24) = transfer mode (0: copy, 1: fill)
158//  flags(20..0) = transfer count (in words)
159
160        \note Transfers more quickly than swiCopy, but has higher interrupt latency
161*/
162
163#define COPY_MODE_HWORD  (0)
164#define COPY_MODE_WORD  (1<<26)
165#define COPY_MODE_COPY  (0)
166#define COPY_MODE_FILL  (1<<24)
167
168void swiCopy(const void * source, void * dest, int flags);
169void swiFastCopy(const void * source, void * dest, int flags);
170
171// swiSqrt (swi 0x0D)
172
173int swiSqrt(int value);
174
175// swiCRC16(uint16 crc, void * data, uint32 size) (swi 0x0E)
176//   crc - starting CRC-16
177//   data - pointer to data (processed nibble by nibble)
178//   size - size in bytes
179//
180// Returns the CRC-16 after the data has been processed
181
182uint16 swiCRC16(uint16 crc, void * data, uint32 size);
183
184// int swiIsDebugger(void)
185//   Returns 0 if running on a debugger (8 MB of ram instead of 4 MB)
186//
187// Note: swi 0x0F on both CPUs
188
189int swiIsDebugger(void);
190
191// swiUnpackBits
192//  source      - Source address
193//  destination - destination address (word aligned)
194//  params      - Unpack structure
195//       uint16 sourceSize (in bytes)
196//       uint8 sourceWidth (1,2,4,8)
197//       uint8 destWidth (1,2,4,8,16,32)
198//       uint32 dataOffset (bits 0..30 are added to all non-zero
199//                          destination writes, unless b31 is set,
200//                          which does it for zeros too)
201//
202// Unpack data stored multiple elements to a byte into a larger space
203// i.e. 8 elements per byte (i.e. b/w font), into 1 element per byte
204//
205// Note: swi 0x10 on both CPUs
206
207void swiUnpackBits(uint8 * source, uint32 * destination, PUnpackStruct params);
208
209// DecompressLZSSWram (swi 0x11)
210//   source      - pointer to a header word, followed by compressed data
211//                 word(31..8) = size of uncompressed data (in bytes)
212//                 word(7..0) = ignored
213//   destination - destination address
214// Writes data a byte at a time
215//
216// DecompressLZSSVram (swi 0x12)
217// Writes data a halfword at a time
218// See DecompressRLEVram for parameter details
219
220void swiDecompressLZSSWram(void * source, void * destination);
221int swiDecompressLZSSVram(void * source, void * destination, uint32 toGetSize, TDecompressionStream * stream);
222
223// swiDecompressHuffman (swi 0x13)
224// See DecompressRLE for parameter details
225
226int swiDecompressHuffman(void * source, void * destination, uint32 toGetSize, TDecompressionStream * stream);
227
228// DecompressRLEWram (swi 0x14)
229//   r0 - pointer to a header word, followed by compressed data
230//        word(31..8) = size of uncompressed data (in bytes)
231//        word(7..0) = ignored
232//   r1 - destination address
233// Writes data a byte at a time
234//
235// DecompressRLEVram (swi 0x15)
236//   r0 - pointer to compressed source data, maybe! (always goes through
237//        the function pointers, so could just be an offset)
238//   r1 - pointer to destination (halfword)
239//   r2 - no idea, passed to getSize function
240//   r3 - pointer to a structure
241// Writes data a halfword at a time
242//
243// Result of getSize is a word, with the size of decompressed data in
244// bits 31..8, and bits 7..0 are ignored.  This value is also returned
245// by the swi, unless getResult is non-NULL and returns a neg. value
246//
247// getResult is used to provide a result for the swi, given the source
248// pointer after all data has been read (or if getSize < 0).  It can
249// be NULL, unlike getSize and readByte.  Its value is only returned
250// if negative, otherwise the typical result is used, so it is likely
251// some sort of error-checking procedure
252//
253// readByte is used in lieu of directly accessing memory
254//
255// compressed data format:
256//   bit(7): 0: uncompressed, 1: compressed
257//   bit(6..0) when uncompressed: run length - 1, followed by run_length bytes of true data
258//   bit(6..0) when compressed: run length - 3, followed by one byte of true data, to be repeated
259
260void swiDecompressRLEWram(void * source, void * destination);
261int swiDecompressRLEVram(void * source, void * destination, uint32 toGetSize, TDecompressionStream * stream);
262
263// swiDecodeDelta8
264//   source      - pointer to a header word, followed by encoded data
265//                 word(31..8) = size of data (in bytes)
266//                 word(7..0) = ignored
267//   destination - destination address
268// Writes data a byte at a time
269//
270// Note: ARM9 exclusive swi 0x16
271
272#ifdef ARM9
273
274/*! \fn swiWaitForIRQ
275        \brief wait for any interrupt
276
277        \note ARM9 exclusive
278*/
279void swiWaitForIRQ(void);
280
281void swiSetHaltCR(uint32 data);
282
283
284extern void swiDecodeDelta8(void * source, void * destination);
285
286// swiDecodeDelta16
287//   source      - pointer to a header word, followed by encoded data
288//                 word(31..8) = size of data (in bytes)
289//                 word(7..0) = ignored
290//   destination - destination address
291// Writes data a halfword at a time
292//
293// Note: ARM9 exclusive swi 0x18
294
295void swiDecodeDelta16(void * source, void * destination);
296#endif
297
298
299#ifdef ARM7
300
301//
302// swiHalt (swi 0x06)
303//   Same as swiSetHaltCR(0x80)
304//
305// swiSleep (swi 0x07)
306//   Same as swiSetHaltCR(0xC0)
307//
308// swiSwitchToGBAMode (not a SWI)
309//   Same as swiSetHaltCR(0x40)
310//
311// swiSetHaltCR (swi 0x1F)
312//   Writes a byte of the data to 0x04000301:8
313//
314// Note: All of these are ARM7 exclusive
315//
316// swiSetHaltCR (swi 0x1F)
317//   Writes a word of the data to 0x04000300:32
318//
319// Note: This is on the ARM9, but works differently to the ARM7 function!
320//
321
322void swiHalt(void);
323void swiSleep(void);
324void swiSwitchToGBAMode(void);
325void swiSetHaltCR(uint8 data);
326
327// swiGetSineTable(int index)
328//  Returns an entry in the sine table (index = 0..63)
329//
330// Note: ARM7 exclusive swi 0x1A
331
332uint16 swiGetSineTable(int index);
333//
334// swiGetPitchTable(int index)
335//   Returns an entry in the pitch table (index = 0..767)
336//
337// Note: ARM7 exclusive swi 0x1B
338
339uint16 swiGetPitchTable(int index);
340
341
342// swiGetVolumeTable(int index)
343//   Returns an entry in the volume table (index = 0..723)
344//
345// Note: ARM7 exclusive swi 0x1C
346uint8 swiGetVolumeTable(int index);
347// swiChangeSoundBias(int enabled, int delay)
348//   enabled
349//     0: decrement SOUND_BIAS once per delay until it reaches 0x000
350//     1: increment SOUND_BIAS once per delay until it reaches 0x200
351//   delay is in the same units of time as swiDelay
352//
353// Note: ARM7 exclusive SWI 0x08
354
355void swiChangeSoundBias(int enabled, int delay);
356
357
358#endif //ARM7
359
360
361#ifdef __cplusplus
362}
363#endif
364
365
366#endif
367
Note: See TracBrowser for help on using the repository browser.