source: rtems/c/src/lib/libbsp/arm/nds/libnds/include/nds/system.h @ e1730f64

4.104.114.95
Last change on this file since e1730f64 was 311dfa6, checked in by Joel Sherrill <joel.sherrill@…>, on 04/16/08 at 18:37:33

2008-04-16 Matthieu Bucchianeri <mbucchia@…>

  • ChangeLog?, Makefile.am, README, bsp_specs, configure.ac, mk_libnds.sh, patch.libnds, preinstall.am, block/block.c, clock/clock.c, console/console.c, coproc/coproc.S, coproc/coproc.c, coproc/coproc.ld, dswifi/dswifi_license.txt, dswifi/makefile, dswifi/arm7/makefile, dswifi/arm7/source/wifi_arm7.c, dswifi/arm7/source/wifi_arm7.h, dswifi/arm9/makefile, dswifi/arm9/source/sgIP.c, dswifi/arm9/source/sgIP.h, dswifi/arm9/source/sgIP_ARP.c, dswifi/arm9/source/sgIP_ARP.h, dswifi/arm9/source/sgIP_Config.h, dswifi/arm9/source/sgIP_DHCP.c, dswifi/arm9/source/sgIP_DHCP.h, dswifi/arm9/source/sgIP_DNS.c, dswifi/arm9/source/sgIP_DNS.h, dswifi/arm9/source/sgIP_Hub.c, dswifi/arm9/source/sgIP_Hub.h, dswifi/arm9/source/sgIP_ICMP.c, dswifi/arm9/source/sgIP_ICMP.h, dswifi/arm9/source/sgIP_IP.c, dswifi/arm9/source/sgIP_IP.h, dswifi/arm9/source/sgIP_TCP.c, dswifi/arm9/source/sgIP_TCP.h, dswifi/arm9/source/sgIP_UDP.c, dswifi/arm9/source/sgIP_UDP.h, dswifi/arm9/source/sgIP_memblock.c, dswifi/arm9/source/sgIP_memblock.h, dswifi/arm9/source/sgIP_sockets.c, dswifi/arm9/source/sgIP_sockets.h, dswifi/arm9/source/wifi_arm9.c, dswifi/arm9/source/wifi_arm9.h, dswifi/common/source/dsregs.h, dswifi/common/source/spinlock.h, dswifi/common/source/spinlock.s, dswifi/common/source/wifi_shared.h, dswifi/include/dswifi7.h, dswifi/include/dswifi9.h, dswifi/include/dswifi_version.h, dswifi/include/netdb.h, dswifi/include/sgIP_errno.h, dswifi/include/netinet/in.h, fb/fb.c, fb/fb.h, include/bsp.h, include/my_ipc.h, include/tm27.h, include/types.h, include/sys/iosupport.h, irq/irq.c, irq/irq.h, libfat/gba/include/fat.h, libfat/include/fat.h, libfat/nds/include/fat.h, libfat/source/bit_ops.h, libfat/source/cache.c, libfat/source/cache.h, libfat/source/common.h, libfat/source/directory.c, libfat/source/directory.h, libfat/source/fatdir.c, libfat/source/fatdir.h, libfat/source/fatfile.c, libfat/source/fatfile.h, libfat/source/file_allocation_table.c, libfat/source/file_allocation_table.h, libfat/source/filetime.c, libfat/source/filetime.h, libfat/source/libfat.c, libfat/source/mem_allocate.h, libfat/source/partition.c, libfat/source/partition.h, libfat/source/disc_io/disc.c, libfat/source/disc_io/disc.h, libfat/source/disc_io/disc_io.h, libfat/source/disc_io/io_cf_common.c, libfat/source/disc_io/io_cf_common.h, libfat/source/disc_io/io_dldi.h, libfat/source/disc_io/io_dldi.s, libfat/source/disc_io/io_efa2.c, libfat/source/disc_io/io_efa2.h, libfat/source/disc_io/io_fcsr.c, libfat/source/disc_io/io_fcsr.h, libfat/source/disc_io/io_m3_common.c, libfat/source/disc_io/io_m3_common.h, libfat/source/disc_io/io_m3cf.c, libfat/source/disc_io/io_m3cf.h, libfat/source/disc_io/io_m3sd.c, libfat/source/disc_io/io_m3sd.h, libfat/source/disc_io/io_mpcf.c, libfat/source/disc_io/io_mpcf.h, libfat/source/disc_io/io_njsd.c, libfat/source/disc_io/io_njsd.h, libfat/source/disc_io/io_nmmc.c, libfat/source/disc_io/io_nmmc.h, libfat/source/disc_io/io_sc_common.c, libfat/source/disc_io/io_sc_common.h, libfat/source/disc_io/io_sccf.c, libfat/source/disc_io/io_sccf.h, libfat/source/disc_io/io_scsd.c, libfat/source/disc_io/io_scsd.h, libfat/source/disc_io/io_scsd_s.s, libfat/source/disc_io/io_sd_common.c, libfat/source/disc_io/io_sd_common.h, libnds/Makefile.arm7, libnds/Makefile.arm9, libnds/libnds_license.txt, libnds/basicARM7/source/defaultARM7.c, libnds/include/default_font_bin.h, libnds/include/gbfs.h, libnds/include/nds.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/memory.h, libnds/include/nds/registers_alt.h, libnds/include/nds/reload.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/background.h, libnds/include/nds/arm9/boxtest.h, libnds/include/nds/arm9/cache.h, libnds/include/nds/arm9/console.h, libnds/include/nds/arm9/exceptions.h, libnds/include/nds/arm9/image.h, libnds/include/nds/arm9/input.h, libnds/include/nds/arm9/math.h, libnds/include/nds/arm9/ndsmotion.h, libnds/include/nds/arm9/pcx.h, libnds/include/nds/arm9/postest.h, libnds/include/nds/arm9/rumble.h, libnds/include/nds/arm9/sound.h, libnds/include/nds/arm9/sprite.h, libnds/include/nds/arm9/trig_lut.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/spi.c, libnds/source/arm7/touch.c, libnds/source/arm7/userSettings.c, libnds/source/arm9/COS.bin, libnds/source/arm9/COS.s, libnds/source/arm9/SIN.bin, libnds/source/arm9/SIN.s, libnds/source/arm9/TAN.bin, libnds/source/arm9/TAN.s, libnds/source/arm9/boxtest.c, libnds/source/arm9/console.c, libnds/source/arm9/dcache.s, libnds/source/arm9/default_font.bin, libnds/source/arm9/default_font.s, libnds/source/arm9/exceptionHandler.S, libnds/source/arm9/exceptionHandler.s, libnds/source/arm9/exceptions.c, libnds/source/arm9/gurumeditation.c, libnds/source/arm9/icache.s, libnds/source/arm9/image.c, libnds/source/arm9/initSystem.c, libnds/source/arm9/keys.c, libnds/source/arm9/ndsmotion.c, libnds/source/arm9/pcx.c, libnds/source/arm9/rumble.c, libnds/source/arm9/sound.c, libnds/source/arm9/system.c, libnds/source/arm9/touch.c, libnds/source/arm9/video.c, libnds/source/arm9/videoGL.c, libnds/source/common/biosCalls.s, libnds/source/common/card.c, libnds/source/common/gbfs.c, libnds/source/common/interruptDispatcher.s, libnds/source/common/interrupts.c, rtc/rtc.c, sound/sound.c, sound/sound.h, start/start.S, startup/linkcmds, startup/start.c, timer/timer.c, tools/Makefile.am, tools/bin2s, tools/bin2s.c, tools/configure.ac, tools/runtest, tools/ndstool/include/arm7_sha1_homebrew.h, tools/ndstool/include/arm7_sha1_nintendo.h, tools/ndstool/include/banner.h, tools/ndstool/include/bigint.h, tools/ndstool/include/crc.h, tools/ndstool/include/default_icon.h, tools/ndstool/include/encryption.h, tools/ndstool/include/header.h, tools/ndstool/include/hook.h, tools/ndstool/include/little.h, tools/ndstool/include/loadme.h, tools/ndstool/include/logo.h, tools/ndstool/include/ndscreate.h, tools/ndstool/include/ndsextract.h, tools/ndstool/include/ndstool.h, tools/ndstool/include/ndstree.h, tools/ndstool/include/overlay.h, tools/ndstool/include/passme.h, tools/ndstool/include/passme_sram.h, tools/ndstool/include/passme_vhd1.h, tools/ndstool/include/passme_vhd2.h, tools/ndstool/include/raster.h, tools/ndstool/include/sha1.h, tools/ndstool/include/types.h, tools/ndstool/source/arm7_sha1_homebrew.c, tools/ndstool/source/arm7_sha1_nintendo.c, tools/ndstool/source/banner.cpp, tools/ndstool/source/bigint.cpp, tools/ndstool/source/compile_date.c, tools/ndstool/source/crc.cpp, tools/ndstool/source/default_icon.c, tools/ndstool/source/encryption.cpp, tools/ndstool/source/header.cpp, tools/ndstool/source/hook.cpp, tools/ndstool/source/loadme.c, tools/ndstool/source/logo.cpp, tools/ndstool/source/ndscodes.cpp, tools/ndstool/source/ndscreate.cpp, tools/ndstool/source/ndsextract.cpp, tools/ndstool/source/ndstool.cpp, tools/ndstool/source/ndstree.cpp, tools/ndstool/source/passme.cpp, tools/ndstool/source/passme_sram.c, tools/ndstool/source/raster.cpp, tools/ndstool/source/sha1.cpp, touchscreen/README.reco, touchscreen/parser.c, touchscreen/reco.c, touchscreen/reco.h, touchscreen/touchscreen.c, touchscreen/touchscreen.h, wifi/compat.c, wifi/compat.h, wifi/wifi.c: New files.
  • Property mode set to 100644
File size: 8.0 KB
Line 
1/*---------------------------------------------------------------------------------
2        $Id$
3
4        Power control, keys, and HV clock registers
5
6        Copyright (C) 2005
7                Jason Rogers (dovoto)
8                Dave Murphy (WinterMute)
9
10        This software is provided 'as-is', without any express or implied
11        warranty.  In no event will the authors be held liable for any
12        damages arising from the use of this software.
13
14        Permission is granted to anyone to use this software for any
15        purpose, including commercial applications, and to alter it and
16        redistribute it freely, subject to the following restrictions:
17
18        1.      The origin of this software must not be misrepresented; you
19                must not claim that you wrote the original software. If you use
20                this software in a product, an acknowledgment in the product
21                documentation would be appreciated but is not required.
22
23        2.      Altered source versions must be plainly marked as such, and
24                must not be misrepresented as being the original software.
25
26        3.      This notice may not be removed or altered from any source
27                distribution.
28
29---------------------------------------------------------------------------------*/
30
31//!     NDS hardware definitions.
32/*!     \file system.h
33
34        These definitions are usually only touched during
35        the initialization of the program.
36*/
37
38#ifndef NDS_SYSTEM_INCLUDE
39#define NDS_SYSTEM_INCLUDE
40
41//!     LCD status register.
42#define REG_DISPSTAT    (*(vu16*)0x04000004)
43
44//!     The display currently in a vertical blank.
45#define DISP_IN_VBLANK     BIT(0)
46
47//!     The display currently in a horizontal blank.
48#define DISP_IN_HBLANK     BIT(1)
49
50//!     Current scanline and %DISP_Y match.
51#define DISP_YTRIGGERED    BIT(2)
52
53//!     Interrupt on vertical blank.
54#define DISP_VBLANK_IRQ    BIT(3)
55
56//!     Interrupt on horizontal blank.
57#define DISP_HBLANK_IRQ    BIT(4)
58
59//!     Interrupt when current scanline and %DISP_Y match.
60#define DISP_YTRIGGER_IRQ  BIT(5)
61
62static inline
63void SetYtrigger(int Yvalue) {
64        REG_DISPSTAT = (REG_DISPSTAT & 0x007F ) | (Yvalue << 8) | (( Yvalue & 0x100 ) >> 2) ;
65}
66
67//!     Current display scanline.
68#define REG_VCOUNT              (*(vu16*)0x4000006)
69
70
71//!     Halt control register.
72/*!     Writing 0x40 to HALT_CR activates GBA mode.
73        %HALT_CR can only be accessed via the BIOS.
74*/
75#define HALT_CR       (*(vuint16*)0x04000300)
76
77//!     Power control register.
78/*!     This register controls what hardware should
79        be turned on or off.
80*/
81#define REG_POWERCNT    *(vu16*)0x4000304
82
83//!     Turns on specified hardware.
84/*!     This function should only be called after %powerSET.
85
86        \param on What to power on.
87*/
88static inline
89void powerON(int on) { REG_POWERCNT |= on;}
90
91//!     Turns on only the specified hardware.
92/*!     Use this function to power on basic hardware types you
93        wish to use throughout your program.
94
95        \param on What to power on.
96*/
97static inline void powerSET(int on) { REG_POWERCNT = on;}
98
99//!     Turns off the specified hardware.
100/*!     \param off What to power off.
101*/
102static inline void powerOFF(int off) { REG_POWERCNT &= ~off;}
103
104#ifdef ARM9
105#ifdef DOXYGEN
106//!     Power-controlled hardware devices accessable to the ARM9.
107/*!     Used with %powerON, %powerSET, and %powerOFF functions.
108        Note that these should only be used when programming for
109        the ARM9.  Trying to boot up these hardware devices via
110        the ARM7 would lead to unexpected results.
111*/
112enum ARM9_power
113{
114        POWER_LCD,                      //!<    Controls the power for both LCD screens.
115        POWER_2D_A,                     //!<    Controls the power for the main 2D core.
116        POWER_MATRIX,           //!<    Controls the power for the 3D matrix.
117        POWER_3D_CORE,          //!<    Controls the power for the main 3D core.
118        POWER_2D_B,                     //!<    Controls the power for the sub 2D core.
119        POWER_SWAP_LCDS,        //!<    Controls which screen should use the main core.
120};
121#else
122#define POWER_LCD                       BIT(0)
123#define POWER_2D_A                      BIT(1)
124#define POWER_MATRIX            BIT(2)
125#define POWER_3D_CORE           BIT(3)
126#define POWER_2D_B                      BIT(9)
127#define POWER_SWAP_LCDS         BIT(15)
128#endif /* DOXYGEN */
129
130//!     Enables power to all hardware required for 2D video.
131#define POWER_ALL_2D     (POWER_LCD |POWER_2D_A |POWER_2D_B)
132
133//!     Enables power to all hardware required for 3D video.
134#define POWER_ALL                (POWER_ALL_2D | POWER_3D_CORE | POWER_MATRIX)
135
136//!     Switches the screens.
137static inline void lcdSwap(void) { REG_POWERCNT ^= POWER_SWAP_LCDS; }
138
139//!     Forces the main core to display on the top.
140static inline void lcdMainOnTop(void) { REG_POWERCNT |= POWER_SWAP_LCDS; }
141
142//!     Forces the main core to display on the bottom.
143static inline void lcdMainOnBottom(void) { REG_POWERCNT &= ~POWER_SWAP_LCDS; }
144#endif
145
146#ifdef ARM7
147#ifdef DOXYGEN
148//!     Power-controlled hardware devices accessable to the ARM7.
149/*!     Note that these should only be used when programming for
150        the ARM7.  Trying to boot up these hardware devices via
151        the ARM9 would lead to unexpected results.
152*/
153enum ARM7_power
154{
155        POWER_SOUND,    //!<    Controls the power for the sound controller.
156        POWER_UNKNOWN,  //!<    Controls the power for an unknown device.
157};
158#else
159#define POWER_SOUND       BIT(0)
160#define POWER_UNKNOWN     BIT(1)
161#endif /* DOXYGEN */
162
163void readUserSettings();
164
165#endif /* ARM7 */
166
167//!     User's DS settings.
168/*!     \struct tPERSONAL_DATA
169
170        Defines the structure the DS firmware uses for transfer
171        of the user's settings to the booted program.
172*/
173typedef struct tPERSONAL_DATA {
174  u8 RESERVED0[2];                      //!<    ??? (0x05 0x00).
175
176  u8 theme;                                     //!<    The user's theme color (0-15).
177  u8 birthMonth;                        //!<    The user's birth month (1-12).
178  u8 birthDay;                          //!<    The user's birth day (1-31).
179
180  u8 RESERVED1[1];                      //!<    ???
181
182  s16 name[10];                         //!<    The user's name in UTF-16 format.
183  u16 nameLen;                          //!<    The length of the user's name in characters.
184
185  s16 message[26];                      //!<    The user's message.
186  u16 messageLen;                       //!<    The length of the user's message in characters.
187
188  u8 alarmHour;                         //!<    What hour the alarm clock is set to (0-23).
189  u8 alarmMinute;                       //!<    What minute the alarm clock is set to (0-59).
190            //0x027FFCD3  alarm minute
191
192  u8 RESERVED2[4];                      //!<    ???
193           //0x027FFCD4  ??
194
195  u16 calX1;                            //!<    Touchscreen calibration: first X touch
196  u16 calY1;                            //!<    Touchscreen calibration: first Y touch
197  u8 calX1px;                           //!<    Touchscreen calibration: first X touch pixel
198  u8 calY1px;                           //!<    Touchscreen calibration: first X touch pixel
199
200  u16 calX2;                            //!<    Touchscreen calibration: second X touch
201  u16 calY2;                            //!<    Touchscreen calibration: second Y touch
202  u8 calX2px;                           //!<    Touchscreen calibration: second X touch pixel
203  u8 calY2px;                           //!<    Touchscreen calibration: second Y touch pixel
204
205  packed_struct {
206    unsigned language                   : 3;    //!<    User's language.
207    unsigned gbaScreen                  : 1;    //!<    GBA screen selection (lower screen if set, otherwise upper screen).
208    unsigned defaultBrightness  : 2;    //!<    Brightness level at power on, dslite.
209    unsigned autoMode                   : 1;    //!<    The DS should boot from the DS cart or GBA cart automatically if one is inserted.
210    unsigned RESERVED1                  : 2;    //!<    ???
211        unsigned settingsLost           : 1;    //!<    User Settings Lost (0=Normal, 1=Prompt/Settings Lost)
212        unsigned RESERVED2                      : 6;    //!<    ???
213  } _user_data;
214 
215  u16   RESERVED3;
216  u32   rtcOffset;
217  u32   RESERVED4;
218} PACKED PERSONAL_DATA ;
219
220//!     Key input register.
221/*!     On the ARM9, the hinge "button," the touch status, and the
222        X and Y buttons cannot be accessed directly.
223*/
224#define REG_KEYINPUT    (*(vuint16*)0x04000130)
225
226//!     Key input control register.
227#define REG_KEYCNT              (*(vuint16*)0x04000132)
228
229//!     Default location for the user's personal data (see %PERSONAL_DATA).
230#define PersonalData ((PERSONAL_DATA*)0x27FFC80)
231
232//!     argv structure
233/*!     \struct __argv
234
235        structure used to set up argc/argv on the DS
236
237*/
238struct __argv {
239        int argvMagic;          //!< argv magic number, set to 0x5f617267 ('_arg') if valid
240        char *commandLine;      //!< base address of command line, set of null terminated strings
241        int length;                     //!< total length of command line
242};
243
244//!     Default location for the libnds argv structure.
245#define libnds_argv             ((struct __argv *)0x027FFF70)
246
247// argv struct magic number
248#define argvMagic 0x5f617267
249
250#endif
Note: See TracBrowser for help on using the repository browser.