Rev 364 | Rev 501 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 364 | Rev 413 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright (C) 2005 Ondrej Palkovsky |
2 | * Copyright (C) 2005 Ondrej Palkovsky |
3 | * All rights reserved. |
3 | * All rights reserved. |
4 | * |
4 | * |
5 | * Redistribution and use in source and binary forms, with or without |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
6 | * modification, are permitted provided that the following conditions |
7 | * are met: |
7 | * are met: |
8 | * |
8 | * |
9 | * - Redistributions of source code must retain the above copyright |
9 | * - Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. |
10 | * notice, this list of conditions and the following disclaimer. |
11 | * - Redistributions in binary form must reproduce the above copyright |
11 | * - Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the |
12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. |
13 | * documentation and/or other materials provided with the distribution. |
14 | * - The name of the author may not be used to endorse or promote products |
14 | * - The name of the author may not be used to endorse or promote products |
15 | * derived from this software without specific prior written permission. |
15 | * derived from this software without specific prior written permission. |
16 | * |
16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | */ |
27 | */ |
28 | 28 | ||
29 | #include <arch/drivers/arc.h> |
29 | #include <arch/drivers/arc.h> |
30 | #include <arch/mm/page.h> |
30 | #include <arch/mm/page.h> |
31 | #include <print.h> |
31 | #include <print.h> |
32 | #include <arch.h> |
32 | #include <arch.h> |
33 | #include <arch/byteorder.h> |
33 | #include <arch/byteorder.h> |
34 | 34 | ||
35 | /* This is a good joke, SGI HAS different types than NT bioses... */ |
35 | /* This is a good joke, SGI HAS different types than NT bioses... */ |
36 | /* Here is the SGI type */ |
36 | /* Here is the SGI type */ |
37 | static char *basetypes[] = { |
37 | static char *basetypes[] = { |
38 | "ExceptionBlock", |
38 | "ExceptionBlock", |
39 | "SystemParameterBlock", |
39 | "SystemParameterBlock", |
40 | "FreeContiguous", |
40 | "FreeContiguous", |
41 | "FreeMemory", |
41 | "FreeMemory", |
42 | "BadMemory", |
42 | "BadMemory", |
43 | "LoadedProgram", |
43 | "LoadedProgram", |
44 | "FirmwareTemporary", |
44 | "FirmwareTemporary", |
45 | "FirmwarePermanent" |
45 | "FirmwarePermanent" |
46 | }; |
46 | }; |
47 | 47 | ||
48 | static char *ctypes[] = { |
48 | static char *ctypes[] = { |
49 | "ARC_type", |
49 | "ARC_type", |
50 | "CPU_type", |
50 | "CPU_type", |
51 | "FPU_type", |
51 | "FPU_type", |
52 | "PrimaryICache", |
52 | "PrimaryICache", |
53 | "PrimaryDCache", |
53 | "PrimaryDCache", |
54 | "SecondaryICache", |
54 | "SecondaryICache", |
55 | "SecondaryDCache", |
55 | "SecondaryDCache", |
56 | "SecondaryCache", |
56 | "SecondaryCache", |
57 | "Memory", |
57 | "Memory", |
58 | "EISAAdapter", |
58 | "EISAAdapter", |
59 | "TCAdapter", |
59 | "TCAdapter", |
60 | "SCSIAdapter", |
60 | "SCSIAdapter", |
61 | "DTIAdapter", |
61 | "DTIAdapter", |
62 | "MultiFunctionAdapter", |
62 | "MultiFunctionAdapter", |
63 | "DiskController", |
63 | "DiskController", |
64 | "TapeController", |
64 | "TapeController", |
65 | "CDROMController", |
65 | "CDROMController", |
66 | "WORMController", |
66 | "WORMController", |
67 | "SerialController", |
67 | "SerialController", |
68 | "NetworkController", |
68 | "NetworkController", |
69 | "DisplayController", |
69 | "DisplayController", |
70 | "ParallelController", |
70 | "ParallelController", |
71 | "PointerController", |
71 | "PointerController", |
72 | "KeyboardController", |
72 | "KeyboardController", |
73 | "AudioController", |
73 | "AudioController", |
74 | "OtherController", |
74 | "OtherController", |
75 | "DiskPeripheral", |
75 | "DiskPeripheral", |
76 | "FloppyDiskPeripheral", |
76 | "FloppyDiskPeripheral", |
77 | "TapePeripheral", |
77 | "TapePeripheral", |
78 | "ModemPeripheral", |
78 | "ModemPeripheral", |
79 | "MonitorPeripheral", |
79 | "MonitorPeripheral", |
80 | "PrinterPeripheral", |
80 | "PrinterPeripheral", |
81 | "PointerPeripheral", |
81 | "PointerPeripheral", |
82 | "KeyboardPeripheral", |
82 | "KeyboardPeripheral", |
83 | "TerminalPeripheral", |
83 | "TerminalPeripheral", |
84 | "OtherPeripheral", |
84 | "OtherPeripheral", |
85 | "LinePeripheral", |
85 | "LinePeripheral", |
86 | "NetworkPeripheral" |
86 | "NetworkPeripheral" |
87 | "OtherPeripheral", |
87 | "OtherPeripheral", |
88 | "XTalkAdapter", |
88 | "XTalkAdapter", |
89 | "PCIAdapter", |
89 | "PCIAdapter", |
90 | "GIOAdapter", |
90 | "GIOAdapter", |
91 | "TPUAdapter", |
91 | "TPUAdapter", |
92 | "Anonymous" |
92 | "Anonymous" |
93 | }; |
93 | }; |
94 | 94 | ||
95 | static arc_sbp *sbp = (arc_sbp *)PA2KA(0x1000); |
95 | static arc_sbp *sbp = (arc_sbp *)PA2KA(0x1000); |
96 | static arc_func_vector_t *arc_entry; |
96 | static arc_func_vector_t *arc_entry; |
97 | 97 | ||
98 | static void _arc_putchar(char ch); |
98 | static void _arc_putchar(char ch); |
99 | 99 | ||
100 | /** Initialize ARC structure |
100 | /** Initialize ARC structure |
101 | * |
101 | * |
102 | * @return 0 - ARC OK, -1 - ARC does not exist |
102 | * @return 0 - ARC OK, -1 - ARC does not exist |
103 | */ |
103 | */ |
104 | int init_arc(void) |
104 | int init_arc(void) |
105 | { |
105 | { |
106 | if (sbp->signature != ARC_MAGIC) { |
106 | if (sbp->signature != ARC_MAGIC) { |
107 | sbp = NULL; |
107 | sbp = NULL; |
108 | return -1; |
108 | return -1; |
109 | } |
109 | } |
110 | arc_entry = sbp->firmwarevector; |
110 | arc_entry = sbp->firmwarevector; |
111 | 111 | ||
112 | arc_putchar('A'); |
112 | arc_putchar('A'); |
113 | arc_putchar('R'); |
113 | arc_putchar('R'); |
114 | arc_putchar('C'); |
114 | arc_putchar('C'); |
115 | arc_putchar('\n'); |
115 | arc_putchar('\n'); |
116 | } |
116 | } |
117 | 117 | ||
118 | /** Return true if ARC is available */ |
118 | /** Return true if ARC is available */ |
119 | int arc_enabled(void) |
119 | int arc_enabled(void) |
120 | { |
120 | { |
121 | return sbp != NULL; |
121 | return sbp != NULL; |
122 | } |
122 | } |
123 | 123 | ||
124 | static void arc_print_component(arc_component *c) |
124 | static void arc_print_component(arc_component *c) |
125 | { |
125 | { |
126 | int i; |
126 | int i; |
127 | 127 | ||
128 | printf("%s: ",ctypes[c->type]); |
128 | printf("%s: ",ctypes[c->type]); |
129 | for (i=0;i < c->identifier_len;i++) |
129 | for (i=0;i < c->identifier_len;i++) |
130 | putchar(c->identifier[i]); |
130 | putchar(c->identifier[i]); |
131 | putchar('\n'); |
131 | putchar('\n'); |
132 | } |
132 | } |
133 | 133 | ||
134 | void arc_print_devices(void) |
134 | void arc_print_devices(void) |
135 | { |
135 | { |
136 | arc_component *c,*next; |
136 | arc_component *c,*next; |
137 | 137 | ||
138 | if (!arc_enabled()) |
138 | if (!arc_enabled()) |
139 | return; |
139 | return; |
140 | 140 | ||
141 | c = arc_entry->getchild(NULL); |
141 | c = arc_entry->getchild(NULL); |
142 | while (c) { |
142 | while (c) { |
143 | arc_print_component(c); |
143 | arc_print_component(c); |
144 | next = arc_entry->getchild(c); |
144 | next = arc_entry->getchild(c); |
145 | while (!next) { |
145 | while (!next) { |
146 | next = arc_entry->getpeer(c); |
146 | next = arc_entry->getpeer(c); |
147 | if (!next) |
147 | if (!next) |
148 | c = arc_entry->getparent(c); |
148 | c = arc_entry->getparent(c); |
149 | if (!c) |
149 | if (!c) |
150 | return; |
150 | return; |
151 | } |
151 | } |
152 | c = next; |
152 | c = next; |
153 | } |
153 | } |
154 | } |
154 | } |
155 | 155 | ||
156 | void arc_print_memory_map(void) |
156 | void arc_print_memory_map(void) |
157 | { |
157 | { |
158 | arc_memdescriptor_t *desc; |
158 | arc_memdescriptor_t *desc; |
159 | 159 | ||
160 | if (!arc_enabled()) |
160 | if (!arc_enabled()) |
161 | return; |
161 | return; |
162 | 162 | ||
163 | printf("Memory map:\n"); |
163 | printf("Memory map:\n"); |
164 | 164 | ||
165 | desc = arc_entry->getmemorydescriptor(NULL); |
165 | desc = arc_entry->getmemorydescriptor(NULL); |
166 | while (desc) { |
166 | while (desc) { |
167 | printf("%s: %d (size: %dKB)\n",basetypes[desc->type], |
167 | printf("%s: %d (size: %dKB)\n",basetypes[desc->type], |
168 | desc->basepage * 4096, |
168 | desc->basepage * 4096, |
169 | desc->basecount*4); |
169 | desc->basecount*4); |
170 | desc = arc_entry->getmemorydescriptor(desc); |
170 | desc = arc_entry->getmemorydescriptor(desc); |
171 | } |
171 | } |
172 | } |
172 | } |
173 | 173 | ||
174 | /** Print charactor to console */ |
174 | /** Print charactor to console */ |
175 | void arc_putchar(char ch) |
175 | void arc_putchar(char ch) |
176 | { |
176 | { |
177 | __u32 cnt; |
177 | __u32 cnt; |
178 | pri_t pri; |
178 | ipl_t ipl; |
179 | 179 | ||
180 | /* TODO: Should be spinlock? */ |
180 | /* TODO: Should be spinlock? */ |
181 | pri = cpu_priority_high(); |
181 | ipl = interrupts_disable(); |
182 | arc_entry->write(1, &ch, 1, &cnt); |
182 | arc_entry->write(1, &ch, 1, &cnt); |
183 | cpu_priority_restore(pri); |
183 | interrupts_restore(ipl); |
184 | 184 | ||
185 | } |
185 | } |
186 | 186 |