1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
/****************************************************************************
*
* Broadcom-MIPS EJTAG Debrick Utility
*
* Copyright (C) 2009 Michael Buesch <mb@bu3sch.de>
* Copyright (C) 2004 HairyDairyMaid (a.k.a. Lightbulb)
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 the GNU General Public License as published
* by the Free Software Foundation.
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
* To view a copy of the license go to:
* http://www.fsf.org/copyleft/gpl.html
* To receive a copy of the GNU General Public License write the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#ifdef __FreeBSD__
# include <dev/ppbus/ppi.h>
# include <dev/ppbus/ppbconf.h>
# define PPWDATA PPISDATA
# define PPRSTATUS PPIGSTATUS
#else
# include <linux/ppdev.h>
#endif
#define size4K 0x1000
#define size8K 0x2000
#define size16K 0x4000
#define size32K 0x8000
#define size64K 0x10000
#define size128K 0x20000
#define size1MB 0x100000
#define size2MB 0x200000
#define size4MB 0x400000
#define size8MB 0x800000
#define size16MB 0x1000000
#define CMD_TYPE_BSC 0x01
#define CMD_TYPE_SCS 0x02
#define CMD_TYPE_AMD 0x03
#define CMD_TYPE_SST 0x04
// EJTAG DEBUG Unit Vector on Debug Break
#define MIPS_DEBUG_VECTOR_ADDRESS 0xFF200200
// Our 'Pseudo' Virtual Memory Access Registers
#define MIPS_VIRTUAL_ADDRESS_ACCESS 0xFF200000
#define MIPS_VIRTUAL_DATA_ACCESS 0xFF200004
static const unsigned int pracc_readword_code_module[] = {
// #
// # HairyDairyMaid's Assembler PrAcc Read Word Routine
// #
// start:
//
// # Load R1 with the address of the pseudo-address register
0x3C01FF20, // lui $1, 0xFF20
0x34210000, // ori $1, 0x0000
//
// # Load R2 with the address for the read
0x8C220000, // lw $2, ($1)
//
// # Load R3 with the word @R2
0x8C430000, // lw $3, 0($2)
//
// # Store the value into the pseudo-data register
0xAC230004, // sw $3, 4($1)
//
0x00000000, // nop
0x1000FFF9, // beq $0, $0, start
0x00000000
}; // nop
static const unsigned int pracc_writeword_code_module[] = {
// #
// # HairyDairyMaid's Assembler PrAcc Write Word Routine
// #
// start:
//
// # Load R1 with the address of the pseudo-address register
0x3C01FF20, // lui $1, 0xFF20
0x34210000, // ori $1, 0x0000
//
// # Load R2 with the address for the write
0x8C220000, // lw $2, ($1)
//
// # Load R3 with the data from pseudo-data register
0x8C230004, // lw $3, 4($1)
//
// # Store the word at @R2 (the address)
0xAC430000, // sw $3, ($2)
//
0x00000000, // nop
0x1000FFF9, // beq $0, $0, start
0x00000000
}; // nop
static const unsigned int pracc_readhalf_code_module[] = {
// #
// # HairyDairyMaid's Assembler PrAcc Read HalfWord Routine
// #
// start:
//
// # Load R1 with the address of the pseudo-address register
0x3C01FF20, // lui $1, 0xFF20
0x34210000, // ori $1, 0x0000
//
// # Load R2 with the address for the read
0x8C220000, // lw $2, ($1)
//
// # Load R3 with the half word @R2
0x94430000, // lhu $3, 0($2)
//
// # Store the value into the pseudo-data register
0xAC230004, // sw $3, 4($1)
//
0x00000000, // nop
0x1000FFF9, // beq $0, $0, start
0x00000000
}; // nop
static const unsigned int pracc_writehalf_code_module[] = {
// #
// # HairyDairyMaid's Assembler PrAcc Write HalfWord Routine
// #
// start:
//
// # Load R1 with the address of the pseudo-address register
0x3C01FF20, // lui $1, 0xFF20
0x34210000, // ori $1, 0x0000
//
// # Load R2 with the address for the write
0x8C220000, // lw $2, ($1)
//
// # Load R3 with the data from pseudo-data register
0x8C230004, // lw $3, 4($1)
//
// # Store the half word at @R2 (the address)
0xA4430000, // sh $3, ($2)
//
0x00000000, // nop
0x1000FFF9, // beq $0, $0, start
0x00000000
}; // nop
|