1 /* $NetBSD: tx39xx.c,v 1.7 2009/03/14 14:45:59 dsl Exp $ */
4 * Copyright (c) 1999 Shin Takemura, UCHIYAMA Yasushi
7 * This software is part of the PocketBSD.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed by the PocketBSD project
20 * and its contributors.
21 * 4. Neither the name of the project nor the names of its contributors
22 * may be used to endorse or promote products derived from this software
23 * without specific prior written permission.
25 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
41 extern void tx39xx_asm_code();
42 extern void tx39xx_asm_code_end();
43 void tx39xx_asm_code_holder(void);
45 #define TX39_SYSADDR_CONFIG_REG 0x10C00000
46 #define TX39_SYSADDR_CONFIG_REG_LEN 0x00200000
47 typedef int tx_chipset_tag_t
;
48 u_int32_t __tx39conf_addr
;
51 tx_conf_read(tx_chipset_tag_t t
, int reg
)
53 return *((u_int32_t
*)(__tx39conf_addr
+ reg
));
57 tx_conf_write(tx_chipset_tag_t t
, int reg
, u_int32_t val
)
59 u_int32_t addr
= (u_int32_t
)t
;
60 *((u_int32_t
*)(__tx39conf_addr
+reg
)) = val
;
64 tx39xx_init(SYSTEM_INFO
*info
)
67 system_info
.si_pagesize
= info
->dwPageSize
;
68 /* DRAM Bank 0/1 physical addr range */
69 system_info
.si_dramstart
= 0x04000000;
70 system_info
.si_drammaxsize
= 0x04000000;
71 /* Pointer for bootstrap code */
72 system_info
.si_asmcode
= (unsigned char*)tx39xx_asm_code
;
73 system_info
.si_asmcodelen
= (unsigned char*)tx39xx_asm_code_end
74 - system_info
.si_asmcode
;
75 system_info
.si_boot
= mips_boot
;
76 system_info
.si_intrvec
= 0x80;
78 __tx39conf_addr
= (int)VirtualAlloc(0, TX39_SYSADDR_CONFIG_REG_LEN
, MEM_RESERVE
,
80 if (!VirtualCopy((LPVOID
)__tx39conf_addr
,
81 (LPVOID
)(TX39_SYSADDR_CONFIG_REG
>> 8),
82 TX39_SYSADDR_CONFIG_REG_LEN
,
83 PAGE_READWRITE
|PAGE_NOCACHE
|PAGE_PHYSICAL
)) {
84 msg_printf(MSG_ERROR
, whoami
,
85 TEXT("Mapping TX39 configuration register failed.\n"));
90 tx39xx_asm_code_holder()
94 * startprog(register struct map_s *map)
96 * register unsigned char *addr;
97 * register unsigned char *p;
102 * while (p = map->leaf[i / map->leafsize][i % map->leafsize]) {
103 * register unsigned char *pe = p + map->pagesize;
111 * register assignment:
112 * struct map_s *map a0
113 * unsigned char *addr a1
114 * unsigned char *p a2
115 * unsigned char *pe a3
128 * void **leaf[32]; +36
133 ".globl tx39xx_asm_code;"
138 /* Disable interrupt */
144 * Copy kernel to bootaddr
146 /* addr = map->base; */
154 /* while (p = map->leaf[i / map->leafsize][i % map->leafsize]) { */
155 /* t1 = map->leafsize */
158 /* lo = i / map->leafsize, hi = i % map->leafsize */
163 /* t3 = i / map->leafsize */
166 /* t2 = map->leaf[i / map->leafsize] */
170 /* t3 = i % map->leafsize */
173 /* p = map->leaf[i / map->leafsize][i % map->leafsize] */
178 /* if (p == NULL) { */
181 "beq a2, zero, loop_end;"
184 /* register unsigned char *pe = p + map->pagesize; */
188 /* while (p < pe) { */
191 "beq zero,t1,loop_end2;"
194 /* *addr++ = *p++; */
201 "beq zero, zero, loop_start2;"
207 "beq zero, zero, loop_start;"
221 /* Disable I-cache */
222 "li t5, ~0x00000020;"
228 "beq zero, zero, 1f;"
262 * Jump to kernel entry
266 "lw t0, 0(t3);" /* entry addr */
267 "lw a1, 24(t3);" /* arg1 */
268 "lw a2, 28(t3);" /* arg2 */
269 "lw a3, 32(t3);" /* arg3 */
270 "lw a0, 20(t3);" /* arg0 */
274 ".globl tx39xx_asm_code_end;"
275 "tx39xx_asm_code_end: nop;"