1 /*---------------------------------------------------------------------------*
2   Project:  TwlSDK - OS - include
3   File:     systemCall.h
4 
5   Copyright 2003-2008 Nintendo. All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain
8   proprietary information of Nintendo of America Inc. and/or Nintendo
9   Company Ltd., and are protected by Federal copyright law. They may
10   not be disclosed to third parties or copied or duplicated in any form,
11   in whole or in part, without the prior written consent of Nintendo.
12 
13   $Date:: 2008-09-17#$
14   $Rev: 8556 $
15   $Author: okubata_ryoma $
16 
17 
18  *---------------------------------------------------------------------------*/
19 
20 #ifndef NITRO_OS_SYSTEMCALL_H_
21 #define NITRO_OS_SYSTEMCALL_H_
22 
23 #include <nitro/mi/stream.h>
24 #include <nitro/mi/uncompress.h>
25 
26 #ifdef SDK_TWL
27 #include <twl/os/common/systemCall.h>
28 #endif
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 
35 //================================================================================
36 /*---------------------------------------------------------------------------*
37   Name:         SVC_WaitVBlankIntr
38 
39   Description:  Wait for VBlank.
40 
41               - Waits in hold state until VBlank interrupt is generated.
42               - Using the interrupt process, set the flag corresponding to INTR_CHECK_BUF (DTCM_END - 0x8).
43 
44               At times when multiple interrupts are combined, it is possible to decrease call overhead compared to cases where SVC_Halt() is called repeatedly.
45 
46 
47               -If Halt is entered when using a thread, other threads will also be stopped until an interrupt is generated. So we recommend using OS_WaitIrq(1, OS_IE_V_BLANK) for all threads other than the idle thread.
48 
49 
50 
51   Arguments:    None.
52 
53   Returns:      None.
54 
55  *---------------------------------------------------------------------------*/
56 #ifdef  SDK_SVC_WAITVBLANK_COMPATIBLE
57 void    SVC_WaitVBlankIntr(void);
58 #else
59 #define SVC_WaitVBlankIntr  OS_WaitVBlankIntr
60 #endif
61 
62 /*---------------------------------------------------------------------------*
63   Name:         SVC_WaitByLoop
64 
65   Description:  Loop specified number of times.
66 
67               - Performs loop processing in system ROM a specified number of times.
68               - It takes four cycles for one loop.
69               In states during normal operation where the sub-processor has priority to access main memory, it is possible to reduce stalling of the main processor by having the sub-processor run programs in system ROM.
70 
71 
72               - When it is necessary to give priority to the main processor in modes such as main memory display mode, it may be a situation in which calling by the main processor is valid, but there is no need to call from the main processor as long as most of that time span is running in the cache or on the TCM.
73 
74 
75 
76 
77               Arguments:
78                   count:     loop count
79 
80   Arguments:    count: times to loop
81 
82   Returns:      None.
83 
84  *---------------------------------------------------------------------------*/
85 void    SVC_WaitByLoop(s32 count);
86 
87 /*---------------------------------------------------------------------------*
88   Name:         SVC_CpuSet
89 
90   Description:  Clear or copy memory by cpu.
91 
92                - Clears or copies RAM using DmaSet macro compatible parameters.
93                - If 32-bit transfer, it is accessed forcibly with 4-byte boundary, but with 16-bit transfer the arguments need to be matched up with a 2-byte boundary and passed.
94 
95 
96                Arguments:
97                    srcp    Source address
98                    destp   Destination address
99                    dmaCntData:    only valid with MI_DMA_SRC_FIX, MI_DMA_32BIT_BUS, or MI_DMA_COUNT_MASK
100 
101                          MI_DMA_SRC_FIX(0, 1) = (source address increment, source address fixed)
102                          MI_DMA_32BIT_BUS(0, 1) = (16-bit transfer, 32-bit transfer)
103                          MI_DMA_COUNT_MASK & dmaCntData = number of transfers
104 
105                - High-level macros:
106                    SVC_CpuClear, SVC_CpuClearArray, SVC_CpuCopy, SVC_CpuCopyArray
107 
108   Arguments:    srcp:       Source address
109                 destp:      Destination address
110                 dmaCntData: dma control data
111                             (only MI_DMA_SRC_FIX, MI_DMA_32BIT_BUS, or MI_DMA_COUNT_MASK
112                              is available)
113 
114   Returns:      None.
115 
116  *---------------------------------------------------------------------------*/
117 void    SVC_CpuSet(const void *srcp, void *destp, u32 dmaCntData);
118 
119 /*---------------------------------------------------------------------------*
120   Name:         SVC_CpuSetFast
121 
122   Description:  Clear or copy memory by cpu quickly.
123 
124               - Clears and copies RAM at high speed with DmaSet macro compatible parameters.
125               - When access in 32-Byte units is possible, multiple load/store instructions are used, and the remainder is accessed in 4-Byte units.
126 
127               - Even if you provide an argument outside the 4-Byte boundary, access is forcibly within the 4-Byte boundary.
128 
129               Arguments:
130                   srcp    Source address
131                   destp   Destination address
132                   dmaCntData:     only valid with MI_DMA_SRC_FIX and MI_DMA_COUNT_MASK
133 
134                         MI_DMA_SRC_FIX(0, 1) = (source address increment, source address fixed)
135                         MI_DMA_COUNT_MASK & dmaCntData = number of transfers
136 
137               - High-level macros:
138                   SVC_CpuClearFast, SVC_CpuClearArrayFast, SVC_CpuCopyFast, SVC_CpuCopyArrayFast
139 
140   Arguments:    srcp:       Source address
141                 destp:      Destination address
142                 dmaCntData: dma control data
143                             (only MI_DMA_SRC_FIX and MI_DMA_COUNT_MASK
144                              is available)
145 
146   Returns:      None.
147 
148  *---------------------------------------------------------------------------*/
149 void    SVC_CpuSetFast(const void *srcp, void *destp, u32 dmaCntData);
150 
151 /*---------------------------------------------------------------------------*
152   Name:         SVC_CpuClear
153 
154   Description:  Clear memory by SVC_CpuSet.
155 
156               - Calls system call that does RAM clear with the CPU.
157               - Clear data is put in stack, and that is copied to the destination.
158 
159               Arguments:
160                   data:        clear data
161                   destp   Destination address
162                   size:        number of cleared bytes
163                   bit:         transfer bit width (16|32)
164 
165   Arguments:    data: clear data
166                 destp: destination address
167                 size: clear size ( by byte )
168                 bit: bit width ( 16 or 32 )
169 
170   Returns:      None.
171 
172  *---------------------------------------------------------------------------*/
173 #define SVC_CpuClear( data, destp, size, bit )                  \
174 do{                                                             \
175     vu##bit tmp = (vu##bit )(data);                             \
176     SVC_CpuSet((u8 *)&(tmp), (u8 *)(destp), (                   \
177         MI_DMA_SRC_FIX        |                                 \
178         MI_DMA_##bit##BIT_BUS | ((size)/((bit)/8) & 0x1fffff)));  \
179 } while(0)
180 
181 /*---------------------------------------------------------------------------*
182   Name:         SVC_CpuClearArray
183 
184   Description:  Clear memory by SVC_CpuSet.
185 
186               - Calls system call that does RAM clear with the CPU.
187               - Clear data is put in stack, and that is copied to the destination.
188               - SVC_CpuClearArray clears the entire destination array.
189 
190               Arguments:
191                   data:        clear data
192                   destp   Destination address
193                   bit:         transfer bit width (16|32)
194 
195   Arguments:    data: clear data
196                 destp: destination address
197                 bit: bit width ( 16 or 32 )
198 
199   Returns:      None.
200 
201  *---------------------------------------------------------------------------*/
202 #define SVC_CpuClearArray( data, destp, bit )                   \
203         SVC_CpuClear( data, destp, sizeof(destp), bit )
204 
205 /*---------------------------------------------------------------------------*
206   Name:         SVC_CpuCopy
207 
208   Description:  Copy memory by SVC_CpuSet.
209 
210               - Calls system call that does copy with the CPU.
211               - SVC_CpuCopyArray copies the entire source array.
212 
213               Arguments:
214                   srcp:  source address
215                   destp:  destination address
216                   size:  number of bytes transferred
217                   bit:  transfer bit width (16|32)
218 
219   Arguments:    srcp: Source address
220                 destp: destination address
221                 size: size to copy ( by byte )
222                 bit: bit width ( 16 or 32 )
223 
224   Returns:      None.
225 
226  *---------------------------------------------------------------------------*/
227 #define SVC_CpuCopy( srcp, destp, size, bit )                   \
228                                                                 \
229     SVC_CpuSet((u8 *)(srcp), (u8 *)(destp),  (                  \
230         MI_DMA_SRC_INC        |                                 \
231         MI_DMA_##bit##BIT_BUS | ((size)/((bit)/8) & 0x1fffff)))
232 
233 /*---------------------------------------------------------------------------*
234   Name:         SVC_CpuCopyArray
235 
236   Description:  Copy memory by SVC_CpuSet.
237 
238               - Calls system call that does copy with the CPU.
239               - SVC_CpuCopyArray copies the entire source array.
240 
241               Arguments:
242                   srcp:  source address
243                   destp:  destination address
244                   bit:  transfer bit width (16|32)
245 
246   Arguments:    srcp: Source address
247                 destp: destination address
248                 bit: bit width ( 16 or 32 )
249 
250   Returns:      None.
251 
252  *---------------------------------------------------------------------------*/
253 #define SVC_CpuCopyArray( srcp, destp, bit  )                  \
254         SVC_CpuCopy( srcp, destp, sizeof(srcp), bit )
255 
256 /*---------------------------------------------------------------------------*
257   Name:         SVC_CpuClearFast
258 
259   Description:  Clear memory by SVC_CpuSetFast quickly.
260 
261               - Calls a system call that rapidly clears RAM in the CPU.
262               - Clear data is put in stack, and that is copied to the destination.
263               - When access is possible in 32-Byte units, multiple 32-Byte unit store instructions are used, and the remainder is accessed in 4-Byte units.
264 
265 
266               Arguments:
267                   data:        clear data
268                   destp   Destination address
269                   size:        number of cleared bytes
270 
271   Arguments:    data: clear data
272                 destp: destination address
273                 size: clear size ( by byte )
274 
275   Returns:      None.
276 
277  *---------------------------------------------------------------------------*/
278 #define SVC_CpuClearFast( data, destp, size )                   \
279 do{                                                             \
280     vu32 tmp = (vu32 )(data);                                   \
281     SVC_CpuSetFast((u8 *)&(tmp), (u8 *)(destp), (               \
282         MI_DMA_SRC_FIX | ((size)/(32/8) & 0x1fffff)));   \
283 } while(0)
284 
285 /*---------------------------------------------------------------------------*
286   Name:         SVC_CpuClearArrayFast
287 
288   Description:  Clear memory by SVC_CpuSetFast quickly.
289 
290               - Calls a system call that rapidly clears RAM in the CPU.
291               - Clear data is put in stack, and that is copied to the destination.
292               - When access is possible in 32-Byte units, multiple store instructions are used, and the remainder is accessed in 4-Byte units.
293 
294               - SVC_CpuClearArrayFast clears the entire destination array.
295 
296               Arguments:
297                   data:        clear data
298                   destp   Destination address
299 
300   Arguments:    data: clear data
301                 size: size to clear ( by byte )
302 
303   Returns:      None.
304  *---------------------------------------------------------------------------*/
305 #define SVC_CpuClearArrayFast( data, destp )                    \
306         SVC_CpuClearFast( data, destp, sizeof(destp) )
307 
308 /*---------------------------------------------------------------------------*
309   Name:         SVC_CpuCopyFast
310 
311   Description:  Clear memory by SVC_CpuSetFast quickly.
312 
313               - Calls a system call that rapidly copies in the CPU.
314               - When access in 32-Byte units is possible, multiple load/store instructions are used, and the remainder is accessed in 4-Byte units.
315 
316 
317               Arguments:
318                   srcp    Source address
319                   destp   Destination address
320                   size:        number of transfer bytes
321 
322   Arguments:    srcp: Source address
323                 destp: destination address
324                 size: size to copy ( by byte )
325 
326   Returns:      None.
327 
328  *---------------------------------------------------------------------------*/
329 #define SVC_CpuCopyFast( srcp, destp, size )                    \
330                                                                 \
331     SVC_CpuSetFast((u8 *)(srcp), (u8 *)(destp),  (              \
332         MI_DMA_SRC_INC | ((size)/(32/8) & 0x1fffff)))
333 
334 /*---------------------------------------------------------------------------*
335   Name:         SVC_CpuCopyArrayFast
336 
337   Description:  Clear memory by SVC_CpuSetFast quickly.
338 
339               - Calls a system call that rapidly copies in the CPU.
340               - When access in 32-Byte units is possible, multiple load/store instructions are used, and the remainder is accessed in 4-Byte units.
341 
342               - SVC_CpuCopyArrayFast copies the entire source array.
343 
344               Arguments:
345                   srcp    Source address
346                   destp   Destination address
347 
348   Arguments:    srcp: Source address
349                 destp: destination address
350 
351   Returns:      None.
352 
353  *---------------------------------------------------------------------------*/
354 #define SVC_CpuCopyArrayFast( srcp, destp )                     \
355         SVC_CpuCopyFast( srcp, destp, sizeof(srcp) )
356 
357 /*---------------------------------------------------------------------------*
358   Name:         SVC_UnpackBits
359 
360   Description:  Unpacks bits.
361 
362               - Unpacks data that was packed with the 0 fixed bit.
363               - Align the destination address to a 4-byte boundary.
364 
365               Arguments:
366                    srcp    Source address
367                    destp   Destination address
368                    paramp:        address of MIUnpackBitsParam structure
369 
370               MIUnpackBitsParam Structure
371                     u16 srcNum:              Number of bytes per source data element
372                     u8  srcBitNum:           Number of bits per source data element
373                     u8  destBitNum:          Number of bits per destination data element
374                     u32 destOffset:31:       Offset number to add to source data.
375                         destOffset0_On:1:    Flag for whether to add an offset to 0 data.
376 
377   Arguments:    srcp: Source address
378                 destp: destination address
379                 paramp: parameter structure address
380 
381   Returns:      None.
382 
383  *---------------------------------------------------------------------------*/
384 void    SVC_UnpackBits(const void *srcp, void *destp, const MIUnpackBitsParam *paramp);
385 
386 /*---------------------------------------------------------------------------*
387   Name:         SVC_UncompressLZ8
388 
389   Description:  Uncompresses LZ77.
390 
391               * Expands LZ77-compressed data and writes it in 8-bit units.
392               - You cannot directly uncompress VRAM, etc., that cannot be byte accessed.
393               - If the compressed data size was not a multiple of four, adjust by padding with 0s as much as possible.
394 
395               - Use 4-byte alignment for the source address.
396 
397               Arguments:
398                    srcp    Source address
399                    destp   Destination address
400 
401                - Data header
402                    u32 :4                Reserved
403                         compType:4          Compression type( = 1)
404                         destSize:24         Data size after decompression
405 
406                - Flag data format
407                     u8  flags               Compression/no compression flag
408                                             (0, 1) = (data not compressed, data compressed)
409                - Code data format (big endian)
410                     u16 length:4            Decompressed data length - 3 (only compress when the match length is 3 bytes or greater)
411                         offset:12           Match data offset - 1
412 
413   Arguments:    srcp: Source address
414                 destp: destination address
415 
416   Returns:      None.
417 
418  *---------------------------------------------------------------------------*/
419 void    SVC_UncompressLZ8(const void *srcp, void *destp);
420 
421 /*---------------------------------------------------------------------------*
422   Name:         SVC_UncompressRL8
423 
424   Description:  Uncompresses run length encoding.
425 
426               - Decompresses run-length compressed data, writing in 8 bit units.
427               - You cannot directly uncompress VRAM, etc., that cannot be byte accessed.
428               - If the compressed data size was not a multiple of four, adjust by padding with 0s as much as possible.
429 
430               - Use 4-byte alignment for the source address.
431 
432               Arguments:
433                    srcp    Source address
434                    destp   Destination address
435 
436               - Data header
437                    u32 :4                Reserved
438                        compType:4          Compression type( = 3)
439                        destSize:24         Data size after decompression
440 
441               - Flag data format
442                    u8  length:7            Decompressed data length - 1 (When not compressed)
443                                            Decompressed data length - 3 (only compress when the contiguous length is 3 bytes or greater)
444                        flag:1              (0, 1) = (not compressed, compressed)
445 
446   Arguments:    srcp: Source address
447                 destp: destination address
448 
449   Returns:      None.
450 
451  *---------------------------------------------------------------------------*/
452 void    SVC_UncompressRL8(const void *srcp, void *destp);
453 
454 /*---------------------------------------------------------------------------*
455   Name:         SVC_UncompressLZ16FromDevice
456 
457   Description:  Uncompresses LZ77 from device.
458 
459               * Expands LZ77-compressed data and writes it in 16-bit units.
460               - You can directly uncompress compressed data on a non-memory mapped device without using a temporary buffer.
461 
462               - You can also uncompress in RAM that cannot byte-access, but it is slower than SVC_UncompressLZ8().
463 
464               * For compressed data, search for a matching character string from a minimum of 2 bytes previous.
465               - If the compressed data size was not a multiple of four, adjust by padding with 0s as much as possible.
466 
467               - Use 4-byte alignment for the source address.
468               - At success, it returns the size after uncompression. At failure, it returns a negative value.
469                 Return a negative value when an error is detected in the initStream/terminateStream callback function.
470 
471 
472               Arguments:
473                    srcp    Source address
474                    destp   Destination address
475                    paramp:        address of parameter passed to the initStream function of the MIReadStreamCallbacks structure
476                    callbacks:     address of the MIReadStreamCallbacks structure
477 
478                - Data header
479                    u32 :4                Reserved
480                        compType:4          Compression type( = 1)
481                        destSize:23         Data size after decompression
482                        :1                  unusable
483 
484                - Flag data format
485                     u8  flags               Compression/no compression flag
486                                             (0, 1) = (data not compressed, data compressed)
487                - Code data format (big endian)
488                     u16 length:4            Decompressed data length - 3 (only compress when the match length is 3 bytes or greater)
489                         offset:12           Match data offset - 1
490 
491   Arguments:    srcp: Source address
492                 destp: destination address
493                 callbacks: address of stream callbacks structure
494 
495   Returns:      Uncompressed size >= 0
496                 error < 0
497 
498  *---------------------------------------------------------------------------*/
499 s32     SVC_UncompressLZ16FromDevice(const void *srcp, void *destp, const void *paramp,
500                                      const MIReadStreamCallbacks *callbacks);
501 
502 /*---------------------------------------------------------------------------*
503   Name:         SVC_UncompressRL16FromDevice
504 
505   Description:  Uncompresses run length encoding from device.
506 
507               - Decompresses run-length compressed data, writing in 16 bit units.
508               - You can directly uncompress compressed data on a non-memory mapped device without using a temporary buffer.
509 
510               - You can also uncompress in RAM that cannot byte-access, but it is slower than SVC_UncompressRL8().
511 
512               - If the compressed data size was not a multiple of four, adjust by padding with 0s as much as possible.
513 
514               - Use 4-byte alignment for the source address.
515               - At success, it returns the size after uncompression. At failure, it returns a negative value.
516                 Return a negative value when an error is detected in the initStream/terminateStream callback function.
517 
518 
519               Arguments:
520                    srcp    Source address
521                    destp   Destination address
522                    paramp:        address of parameter passed to the initStream function of the MIReadStreamCallbacks structure
523                    callbacks:     address of the MIReadStreamCallbacks structure
524 
525               - Data header
526                    u32 :4                Reserved
527                        compType:4          Compression type( = 3)
528                        destSize:23         Data size after decompression
529                        :1                  unusable
530 
531               - Flag data format
532                    u8  length:7            Decompressed data length - 1 (When not compressed)
533                                            Decompressed data length - 3 (only compress when the contiguous length is 3 bytes or greater)
534                        flag:1              (0, 1) = (not compressed, compressed)
535 
536   Arguments:    srcp: Source address
537                 destp: destination address
538                 callbacks: address of stream callbacks structure
539 
540   Returns:      Uncompressed size >= 0
541                 error < 0
542 
543  *---------------------------------------------------------------------------*/
544 s32     SVC_UncompressRL16FromDevice(const void *srcp, void *destp, const void *paramp,
545                                      const MIReadStreamCallbacks *callbacks);
546 
547 /*---------------------------------------------------------------------------*
548   Name:         SVC_UncompressHuffmanFromDevice
549 
550   Description:  Uncompresses Huffman encoding from device.
551 
552               - Decompresses Huffman compressed data, writing in 32-bit units.
553               - You can directly uncompress compressed data on a non-memory mapped device without using a temporary buffer.
554 
555               - If the compressed data size was not a multiple of four, adjust by padding with 0s as much as possible.
556 
557               - Use 4-byte alignment for the source address.
558               - At success, it returns the size after uncompression. At failure, it returns a negative value.
559                 Return a negative value when an error is detected in the initStream/terminateStream callback function.
560 
561 
562               Arguments:
563                    srcp    Source address
564                    destp   Destination address
565                    tableBufp:     tree table storage buffer  (maximum 512 Bytes)
566                                  When you wish to pass parameters to the initStream function of the MIReadStreamCallbacks structure, you can pass them through this buffer.
567 
568                                  However, after calling the initStream function, the tree table is overwritten.
569                    callbacks:     address of the MIReadStreamCallbacks structure
570 
571               - Data header
572                    u32 bitSize:4           1 data bit size (Normally 4|8)
573                        compType:4          Compression type( = 2)
574                        destSize:23         Data size after decompression
575                        :1                  unusable
576 
577               - Tree table
578                    u8           treeSize        Tree table size/2 - 1
579                    TreeNodeData nodeRoot        Root node
580 
581                    TreeNodeData nodeLeft        Root left node
582                    TreeNodeData nodeRight       Root right node
583 
584                    TreeNodeData nodeLeftLeft    Left left node
585                    TreeNodeData nodeLeftRight   Left right node
586 
587                    TreeNodeData nodeRightLeft   Right left node
588                    TreeNodeData nodeRightRight  Right right node
589 
590                            �E
591                            �E
592 
593                 The compressed data itself follows
594 
595               - TreeNodeData structure
596                   u8  nodeNextOffset:6 :   Offset to the next node data - 1 (2 byte units)
597                       rightEndFlag:1      Right node end flag
598                       leftEndflag:1       Left node end flag
599                                           When the end flag is set, there is data in the next node.
600 
601 
602   Arguments:    srcp: Source address
603                 destp: destination address
604                 callbacks: address of stream callbacks structure
605 
606   Returns:      Uncompressed size >= 0
607                 error < 0
608 
609  *---------------------------------------------------------------------------*/
610 s32     SVC_UncompressHuffmanFromDevice(const void *srcp, void *destp, u8 *tableBufp,
611                                         const MIReadStreamCallbacks *callbacks);
612 
613 /*---------------------------------------------------------------------------*
614   Name:         SVC_GetCRC16
615 
616   Description:  Calculates CRC-16.
617 
618               - Calculates CRC-16.
619               - Align the data address and size to 2 Byte boundary.
620 
621               Arguments:
622                    start:         initial value
623                    datap:         data address
624                    size:          size (number of bytes)
625 
626   Arguments:    start: Start value
627                 datap: Data address
628                 size: Data size (by byte)
629 
630   Returns:      CRC-16
631 
632  *---------------------------------------------------------------------------*/
633 u16     SVC_GetCRC16(u32 start, const void *datap, u32 size);
634 
635 /*---------------------------------------------------------------------------*
636   Name:         SVC_Div
637 
638   Description:  Quotient of division.
639 
640               - Computes the quotient of the numerator divided by the denominator.
641               - Returns with register values of: r0=numer/denom, r1=numer%denom, r3=|numer/denom|.
642 
643               - Because code size is kept small, this is not very fast.
644 
645               Arguments:
646                    numer:        numerator
647                    denom:         denominator
648 
649   Arguments:    numer:
650                 denom:
651 
652   Returns:      Quotient.
653 
654  *---------------------------------------------------------------------------*/
655 s32     SVC_Div(s32 number, s32 denom);
656 
657 /*---------------------------------------------------------------------------*
658   Name:         SVC_DivRem
659 
660   Description:  remainder of division
661 
662               - Calculates numer%denom.
663               - Returns with register values of: r0=numer%denom, r1=numer%denom, r3=|numer/denom|.
664 
665               - Because code size is kept small, this is not very fast.
666 
667               Arguments:
668                    numer:        numerator
669                    denom:         denominator
670 
671   Arguments:    numer:
672                 denom:
673 
674   Returns:      Remainder.
675 
676  *---------------------------------------------------------------------------*/
677 s32     SVC_DivRem(s32 number, s32 denom);
678 
679 /*---------------------------------------------------------------------------*
680   Name:         SVC_Sqrt
681 
682   Description:  Square root.
683 
684               - Calculates square root.
685               - To improve accuracy, make the argument a multiple of 2 only, left shift it, and pass it, then also shift the return value to align the digits.
686 
687               - Because code size is kept small, this is not very fast.
688 
689   Arguments:    src:
690 
691   Returns:      Square root.
692 
693  *---------------------------------------------------------------------------*/
694 u16     SVC_Sqrt(u32 src);
695 
696 /*---------------------------------------------------------------------------*
697   Name:         SVC_Halt
698 
699   Description:  Halt.
700 
701                 - Only stops CPU core
702                 - The relevant interrupt returns by the permitted (permission set in IE) interrupt request (IF set).
703 
704                 -If the CPSR's IRQ disable flag is set (OS_DisableInterrupts), it will return from halt, but interrupts will not occur.
705 
706 
707                 If a halt is entered during a state with IME cleared (OS_DisableIrq), return will become impossible.
708 
709 
710   Arguments:    None.
711 
712   Returns:      None.
713 
714  *---------------------------------------------------------------------------*/
715 void    SVC_Halt(void);
716 
717 #ifdef SDK_ARM7
718 /*---------------------------------------------------------------------------*
719   Name:         SVC_Sleep
720 
721   Description:  Sleep.
722 
723               - Stops source oscillation.
724               - When enabled (set in IE), interrupts for the RTC, key input, Game Cards, Game Paks, or system open events will restore the system state.
725 
726 
727               - Because source oscillation has been stopped, the IF flag will not be set immediately after the system state is restored; instead, the flag will be set when the CPU is restarted if there had already been an interrupt request signal at the terminals.
728 
729 
730               - Before calling this function, zero out the POWCNT registers for both processors and stop all blocks; stop the sound amp and wireless module; and set the ARM9 state to 'halt'.
731 
732 
733               - Set the POWCNT register's LCD enable flag to 0 at least 100 ms before calling this function.
734                  If you do not keep this condition, the system may shut down.
735 
736 
737   Arguments:    None.
738 
739   Returns:      None.
740 
741  *---------------------------------------------------------------------------*/
742 void    SVC_Sleep(void);
743 
744 /*---------------------------------------------------------------------------*
745   Name:         SVC_SetSoundBias
746 
747   Description:  Sets the sound bias.
748 
749               - Moves sound BIAS from 0 to intermediate value (0x200).
750 
751               Arguments:
752                    stepLoops:     Number of loops to one sound bias change step (4 cycles/loop).
753                                  The higher the value, the more gradually sound bias is changed.
754 
755   Arguments:    stepLoops :
756 
757   Returns:      None.
758 
759  *---------------------------------------------------------------------------*/
760 void    SVC_SetSoundBias(s32 stepLoops);
761 
762 /*---------------------------------------------------------------------------*
763   Name:         SVC_ResetSoundBias
764 
765   Description:  Sets the sound bias.
766 
767               - Changes sound BIAS from the intermediate value (0x200) to 0.
768 
769               Arguments:
770                    stepLoops:     Number of loops to one sound bias change step (4 cycles/loop).
771                                  The higher the value, the more gradually sound bias is changed.
772 
773   Arguments:    stepLoops:
774 
775   Returns:      None.
776 
777  *---------------------------------------------------------------------------*/
778 void    SVC_ResetSoundBias(s32 stepLoops);
779 
780 /*---------------------------------------------------------------------------*
781   Name:         SVC_GetSinTable
782                 SVC_GetPitchTable
783                 SVC_GetVolumeTable
784 
785   Description:  Get sound table data.
786 
787               - References the sound function table and returns value.
788 
789               Arguments:
790                    index:         index
791 
792   Arguments:    index:
793 
794   Returns:      Sound table data.
795 
796  *---------------------------------------------------------------------------*/
797 s16     SVC_GetSinTable(int index);
798 u16     SVC_GetPitchTable(int index);
799 u8      SVC_GetVolumeTable(int index);
800 #endif // SDK_ARM7
801 
802 
803 #ifdef __cplusplus
804 } /* extern "C" */
805 #endif
806 
807 /* NITRO_OS_SYSTEMCALL_H_ */
808 #endif
809