1 | /* |
---|
2 | * RTEMS for Nintendo DS platform initialization. |
---|
3 | * |
---|
4 | * Copyright (c) 2008 by Matthieu Bucchianeri <mbucchia@gmail.com> |
---|
5 | * |
---|
6 | * The license and distribution terms for this file may be |
---|
7 | * found in the file LICENSE in this distribution or at |
---|
8 | * |
---|
9 | * http://www.rtems.com/license/LICENSE |
---|
10 | * |
---|
11 | * $Id$ |
---|
12 | */ |
---|
13 | |
---|
14 | #include <bsp.h> |
---|
15 | #include <bsp/bootcard.h> |
---|
16 | #include <nds.h> |
---|
17 | |
---|
18 | /* |
---|
19 | * This definition comes from ARM cpu code. |
---|
20 | */ |
---|
21 | extern unsigned int arm_cpu_mode; |
---|
22 | |
---|
23 | /* |
---|
24 | * These are from the linker script. |
---|
25 | */ |
---|
26 | extern uint8_t _end; |
---|
27 | extern uint8_t __ewram_end; |
---|
28 | |
---|
29 | /* |
---|
30 | * This method returns the base address and size of the area which |
---|
31 | * is to be allocated between the RTEMS Workspace and the C Program |
---|
32 | * Heap. |
---|
33 | */ |
---|
34 | void bsp_get_work_area( |
---|
35 | void **work_area_start, |
---|
36 | size_t *work_area_size, |
---|
37 | void **heap_start, |
---|
38 | size_t *heap_size |
---|
39 | ) |
---|
40 | { |
---|
41 | *work_area_start = &_end; |
---|
42 | *work_area_size = (void *)&__ewram_end - (void *)&_end; |
---|
43 | *heap_start = BSP_BOOTCARD_HEAP_USES_WORK_AREA; |
---|
44 | *heap_size = BSP_BOOTCARD_HEAP_SIZE_DEFAULT; |
---|
45 | } |
---|
46 | |
---|
47 | /* |
---|
48 | * start the platform. |
---|
49 | */ |
---|
50 | |
---|
51 | void |
---|
52 | bsp_start (void) |
---|
53 | { |
---|
54 | /* initialize irq management */ |
---|
55 | BSP_rtems_irq_mngt_init (); |
---|
56 | |
---|
57 | /* setup console mode for lower screen */ |
---|
58 | irqEnable (IRQ_VBLANK); |
---|
59 | videoSetMode (0); |
---|
60 | videoSetModeSub (MODE_0_2D | DISPLAY_BG0_ACTIVE); |
---|
61 | vramSetBankC (VRAM_C_SUB_BG); |
---|
62 | |
---|
63 | SUB_BG0_CR = BG_MAP_BASE (31); |
---|
64 | BG_PALETTE_SUB[255] = RGB15 (31, 31, 31); |
---|
65 | consoleInitDefault ((u16 *) SCREEN_BASE_BLOCK_SUB (31), |
---|
66 | (u16 *) CHAR_BASE_BLOCK_SUB (0), 16); |
---|
67 | |
---|
68 | /* print status message */ |
---|
69 | printk ("[+] kernel console started\n"); |
---|
70 | |
---|
71 | /* set the cpu mode to system user */ |
---|
72 | arm_cpu_mode = 0x1f; |
---|
73 | |
---|
74 | /* configure clock period */ |
---|
75 | Configuration.microseconds_per_tick = 10000; /* us */ |
---|
76 | } |
---|
77 | |
---|
78 | /* |
---|
79 | * reset bss area. |
---|
80 | */ |
---|
81 | |
---|
82 | void |
---|
83 | bss_reset (void) |
---|
84 | { |
---|
85 | extern uint8_t __bss_start; |
---|
86 | extern uint8_t __bss_end; |
---|
87 | |
---|
88 | memset (&__bss_start, 0, (uint32_t) & __bss_end - (uint32_t) & __bss_start); |
---|
89 | } |
---|
90 | |
---|
91 | /* |
---|
92 | * reset the platform using bios call. |
---|
93 | */ |
---|
94 | |
---|
95 | void |
---|
96 | bsp_reset (void) |
---|
97 | { |
---|
98 | swiSoftReset (); |
---|
99 | } |
---|
100 | |
---|
101 | /* |
---|
102 | * clean up platform before reset. |
---|
103 | */ |
---|
104 | |
---|
105 | void |
---|
106 | bsp_cleanup (void) |
---|
107 | { |
---|
108 | printk ("[!] executive ended, rebooting\n"); |
---|
109 | |
---|
110 | bsp_reset (); |
---|
111 | } |
---|
112 | |
---|
113 | /* |
---|
114 | * A few symbols needed by libnds but not used. |
---|
115 | */ |
---|
116 | |
---|
117 | #include "../include/sys/iosupport.h" |
---|
118 | const devoptab_t *devoptab_list[STD_MAX]; |
---|
119 | void *punixTime; |
---|