Rev 332 | Rev 344 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 332 | Rev 341 | ||
---|---|---|---|
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 arc_sbp *sbp = (arc_sbp *)PA2KA(0x1000); |
48 | static arc_sbp *sbp = (arc_sbp *)PA2KA(0x1000); |
49 | static arc_func_vector_t *arc_entry; |
49 | static arc_func_vector_t *arc_entry; |
50 | 50 | ||
51 | static void _arc_putchar(char ch); |
51 | static void _arc_putchar(char ch); |
52 | 52 | ||
53 | /** Initialize ARC structure |
53 | /** Initialize ARC structure |
54 | * |
54 | * |
55 | * @return 0 - ARC OK, -1 - ARC does not exist |
55 | * @return 0 - ARC OK, -1 - ARC does not exist |
56 | */ |
56 | */ |
57 | int init_arc(void) |
57 | int init_arc(void) |
58 | { |
58 | { |
59 | if (sbp->signature != ARC_MAGIC) { |
59 | if (sbp->signature != ARC_MAGIC) { |
60 | sbp = NULL; |
60 | sbp = NULL; |
61 | return -1; |
61 | return -1; |
62 | } |
62 | } |
63 | arc_entry = sbp->firmwarevector; |
63 | arc_entry = sbp->firmwarevector; |
64 | 64 | ||
65 | arc_putchar('A'); |
65 | arc_putchar('A'); |
66 | arc_putchar('R'); |
66 | arc_putchar('R'); |
67 | arc_putchar('C'); |
67 | arc_putchar('C'); |
68 | arc_putchar('\n'); |
68 | arc_putchar('\n'); |
69 | } |
69 | } |
70 | 70 | ||
71 | /** Return true if ARC is available */ |
71 | /** Return true if ARC is available */ |
72 | int arc_enabled(void) |
72 | int arc_enabled(void) |
73 | { |
73 | { |
74 | return sbp != NULL; |
74 | return sbp != NULL; |
75 | } |
75 | } |
76 | 76 | ||
77 | void arc_print_memory_map(void) |
77 | void arc_print_memory_map(void) |
78 | { |
78 | { |
79 | arc_memdescriptor_t *desc; |
79 | arc_memdescriptor_t *desc; |
80 | 80 | ||
81 | if (!sbp) { |
81 | if (!sbp) { |
82 | printf("ARC not enabled.\n"); |
82 | printf("ARC not enabled.\n"); |
83 | return; |
83 | return; |
84 | } |
84 | } |
85 | 85 | ||
86 | printf("Memory map:\n"); |
86 | printf("Memory map:\n"); |
87 | 87 | ||
88 | desc = arc_entry->getmemorydescriptor(NULL); |
88 | desc = arc_entry->getmemorydescriptor(NULL); |
89 | while (desc) { |
89 | while (desc) { |
90 | printf("%s: %d (size: %dKB)\n",basetypes[desc->type], |
90 | printf("%s: %d (size: %dKB)\n",basetypes[desc->type], |
91 | desc->basepage * 4096, |
91 | desc->basepage * 4096, |
92 | desc->basecount*4); |
92 | desc->basecount*4); |
93 | desc = arc_entry->getmemorydescriptor(desc); |
93 | desc = arc_entry->getmemorydescriptor(desc); |
94 | } |
94 | } |
95 | } |
95 | } |
96 | 96 | ||
97 | /** Print charactor to console */ |
97 | /** Print charactor to console */ |
98 | void arc_putchar(char ch) |
98 | void arc_putchar(char ch) |
99 | { |
99 | { |
100 | __u32 cnt; |
100 | __u32 cnt; |
101 | pri_t pri; |
101 | pri_t pri; |
102 | 102 | ||
103 | /* TODO: Should be spinlock? */ |
103 | /* TODO: Should be spinlock? */ |
104 | pri = cpu_priority_high(); |
104 | pri = cpu_priority_high(); |
105 | arc_entry->write(1, &ch, 1, &cnt); |
105 | arc_entry->write(1, &ch, 1, &cnt); |
106 | cpu_priority_restore(pri); |
106 | cpu_priority_restore(pri); |
107 | 107 | ||
108 | } |
108 | } |
109 | 109 |