Subversion Repositories HelenOS-historic

Rev

Rev 852 | Rev 958 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 852 Rev 853
Line 36... Line 36...
36
#include <interrupt.h>
36
#include <interrupt.h>
37
#include <align.h>
37
#include <align.h>
38
#include <console/console.h>
38
#include <console/console.h>
39
#include <console/kconsole.h>
39
#include <console/kconsole.h>
40
#include <console/cmd.h>
40
#include <console/cmd.h>
-
 
41
#include <mm/slab.h>
41
 
42
 
42
/* This is a good joke, SGI HAS different types than NT bioses... */
43
/* This is a good joke, SGI HAS different types than NT bioses... */
43
/* Here is the SGI type */
44
/* Here is the SGI type */
44
static char *basetypes[] = {
45
static char *basetypes[] = {
45
    "ExceptionBlock",
46
    "ExceptionBlock",
Line 109... Line 110...
109
int arc_enabled(void)
110
int arc_enabled(void)
110
{
111
{
111
    return sbp != NULL;
112
    return sbp != NULL;
112
}
113
}
113
 
114
 
-
 
115
 
-
 
116
/** Print configuration data that ARC reports about component */
-
 
117
static void arc_print_confdata(arc_component *c)
-
 
118
{
-
 
119
    cm_resource_list *configdata;
-
 
120
    int i;
-
 
121
 
-
 
122
    if (!c->configdatasize)
-
 
123
        return; /* No configuration data */
-
 
124
 
-
 
125
    configdata = malloc(c->configdatasize, 0);
-
 
126
 
-
 
127
    if (arc_entry->getconfigurationdata(configdata, c)) {
-
 
128
        free(configdata);
-
 
129
        return;
-
 
130
    }
-
 
131
    /* Does not seem to return meaningful data, don't use now */
-
 
132
    free(configdata);
-
 
133
    return;
-
 
134
   
-
 
135
    for (i=0; i < configdata->count; i++) {
-
 
136
        switch (configdata->descr[i].type) {
-
 
137
        case CmResourceTypePort:
-
 
138
            printf("Port: %P-size:%d ",
-
 
139
                   (__address)configdata->descr[i].u.port.start,
-
 
140
                   configdata->descr[i].u.port.length);
-
 
141
            break;
-
 
142
        case CmResourceTypeInterrupt:
-
 
143
            printf("Irq: level(%d) vector(%d) ",
-
 
144
                   configdata->descr[i].u.interrupt.level,
-
 
145
                   configdata->descr[i].u.interrupt.vector);
-
 
146
            break;
-
 
147
        case CmResourceTypeMemory:
-
 
148
            printf("Memory: %P-size:%d ",
-
 
149
                   (__address)configdata->descr[i].u.port.start,
-
 
150
                   configdata->descr[i].u.port.length);
-
 
151
            break;
-
 
152
        default:
-
 
153
            break;
-
 
154
        }
-
 
155
    }
-
 
156
 
-
 
157
    free(configdata);
-
 
158
}
-
 
159
 
-
 
160
/** Print information about component */
114
static void arc_print_component(arc_component *c)
161
static void arc_print_component(arc_component *c)
115
{
162
{
116
    int i;
163
    int i;
117
 
164
 
118
    printf("%s: ",ctypes[c->type]);
165
    printf("%s: ",ctypes[c->type]);
119
    for (i=0;i < c->identifier_len;i++)
166
    for (i=0;i < c->identifier_len;i++)
120
        arc_putchar(c->identifier[i]);
167
        printf("%c",c->identifier[i]);
-
 
168
 
-
 
169
    printf(" ");
121
    arc_putchar('\n');
170
    arc_print_confdata(c);
-
 
171
    printf("\n");
122
}
172
}
123
 
173
 
-
 
174
/**
-
 
175
 * Read from ARC bios configuration data and print it
-
 
176
 */
124
void arc_print_devices(void)
177
static int cmd_arc_print_devices(cmd_arg_t *argv)
125
{
178
{
126
    arc_component *c,*next;
179
    arc_component *c,*next;
127
 
180
 
128
    if (!arc_enabled())
-
 
129
        return;
-
 
130
 
-
 
131
    c = arc_entry->getchild(NULL);
181
    c = arc_entry->getchild(NULL);
132
    while (c) {
182
    while (c) {
133
        arc_print_component(c);
183
        arc_print_component(c);
134
        next = arc_entry->getchild(c);
184
        next = arc_entry->getchild(c);
135
        while (!next) {
185
        while (!next) {
136
            next = arc_entry->getpeer(c);
186
            next = arc_entry->getpeer(c);
137
            if (!next)
187
            if (!next)
138
                c = arc_entry->getparent(c);
188
                c = arc_entry->getparent(c);
139
            if (!c)
189
            if (!c)
140
                return;
190
                return 0;
141
        }
191
        }
142
        c = next;
192
        c = next;
143
    }
193
    }
-
 
194
    return 1;
144
}
195
}
-
 
196
static cmd_info_t devlist_info = {
-
 
197
    .name = "arcdevlist",
-
 
198
    .description = "Print arc device list",
-
 
199
    .func = cmd_arc_print_devices,
-
 
200
    .argc = 0
-
 
201
};
145
 
202
 
-
 
203
 
-
 
204
/** Read from arc bios memory map and print it
-
 
205
 *
-
 
206
 */
146
void arc_print_memory_map(void)
207
static int cmd_arc_print_memmap(cmd_arg_t *argv)
147
{
208
{
148
    arc_memdescriptor_t *desc;
209
    arc_memdescriptor_t *desc;
149
 
210
 
150
    if (!arc_enabled())
-
 
151
        return;
-
 
152
 
-
 
153
    printf("Memory map:\n");
211
    printf("Memory map:\n");
154
 
212
 
155
    desc = arc_entry->getmemorydescriptor(NULL);
213
    desc = arc_entry->getmemorydescriptor(NULL);
156
    while (desc) {
214
    while (desc) {
157
        printf("%s: %d(%P) (size: %dKB)\n",basetypes[desc->type],
215
        printf("%s: %d(%P) (size: %dKB)\n",basetypes[desc->type],
158
               desc->basepage * ARC_FRAME,
216
               desc->basepage * ARC_FRAME,
159
               desc->basepage * ARC_FRAME,
217
               desc->basepage * ARC_FRAME,
160
               desc->basecount*ARC_FRAME/1024);
218
               desc->basecount*ARC_FRAME/1024);
161
        desc = arc_entry->getmemorydescriptor(desc);
219
        desc = arc_entry->getmemorydescriptor(desc);
162
    }
220
    }
-
 
221
    return 1;
163
}
222
}
-
 
223
static cmd_info_t memmap_info = {
-
 
224
    .name = "arcmemmap",
-
 
225
    .description = "Print arc memory map",
-
 
226
    .func = cmd_arc_print_memmap,
-
 
227
    .argc = 0
-
 
228
};
164
 
229
 
165
/** Print charactor to console */
230
/** Print charactor to console */
166
static void arc_putchar(char ch)
231
static void arc_putchar(char ch)
167
{
232
{
168
    __u32 cnt;
233
    __u32 cnt;
Line 205... Line 270...
205
    arc_putchar('\n');
270
    arc_putchar('\n');
206
 
271
 
207
    /* Add command for resetting the computer */
272
    /* Add command for resetting the computer */
208
    cmd_initialize(&reboot_info);
273
    cmd_initialize(&reboot_info);
209
    cmd_register(&reboot_info);
274
    cmd_register(&reboot_info);
-
 
275
    cmd_initialize(&memmap_info);
-
 
276
    cmd_register(&memmap_info);
-
 
277
    cmd_initialize(&devlist_info);
-
 
278
    cmd_register(&devlist_info);
210
 
279
 
211
    return 0;
280
    return 0;
212
}
281
}
213
 
282
 
214
static bool kbd_polling_enabled;
283
static bool kbd_polling_enabled;