Subversion Repositories HelenOS-historic

Rev

Rev 1221 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1221 Rev 1702
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
 /** @addtogroup mips32
-
 
30
 * @{
-
 
31
 */
-
 
32
/** @file
-
 
33
 */
-
 
34
 
29
#include <arch/drivers/arc.h>
35
#include <arch/drivers/arc.h>
30
#include <arch/mm/page.h>
36
#include <arch/mm/page.h>
31
#include <print.h>
37
#include <print.h>
32
#include <arch.h>
38
#include <arch.h>
33
#include <arch/byteorder.h>
39
#include <arch/byteorder.h>
34
#include <arch/mm/frame.h>
40
#include <arch/mm/frame.h>
35
#include <mm/frame.h>
41
#include <mm/frame.h>
36
#include <interrupt.h>
42
#include <interrupt.h>
37
#include <align.h>
43
#include <align.h>
38
#include <console/console.h>
44
#include <console/console.h>
39
#include <console/kconsole.h>
45
#include <console/kconsole.h>
40
#include <console/cmd.h>
46
#include <console/cmd.h>
41
#include <mm/slab.h>
47
#include <mm/slab.h>
42
 
48
 
43
/* This is a good joke, SGI HAS different types than NT bioses... */
49
/* This is a good joke, SGI HAS different types than NT bioses... */
44
/* Here is the SGI type */
50
/* Here is the SGI type */
45
static char *basetypes[] = {
51
static char *basetypes[] = {
46
    "ExceptionBlock",
52
    "ExceptionBlock",
47
    "SystemParameterBlock",
53
    "SystemParameterBlock",
48
    "FreeContiguous",
54
    "FreeContiguous",
49
    "FreeMemory",
55
    "FreeMemory",
50
    "BadMemory",
56
    "BadMemory",
51
    "LoadedProgram",
57
    "LoadedProgram",
52
    "FirmwareTemporary",
58
    "FirmwareTemporary",
53
    "FirmwarePermanent"
59
    "FirmwarePermanent"
54
};
60
};
55
 
61
 
56
static char *ctypes[] = {
62
static char *ctypes[] = {
57
    "ARC_type",
63
    "ARC_type",
58
    "CPU_type",
64
    "CPU_type",
59
    "FPU_type",
65
    "FPU_type",
60
    "PrimaryICache",
66
    "PrimaryICache",
61
    "PrimaryDCache",
67
    "PrimaryDCache",
62
    "SecondaryICache",
68
    "SecondaryICache",
63
    "SecondaryDCache",
69
    "SecondaryDCache",
64
    "SecondaryCache",
70
    "SecondaryCache",
65
    "Memory",
71
    "Memory",
66
    "EISAAdapter",
72
    "EISAAdapter",
67
    "TCAdapter",
73
    "TCAdapter",
68
    "SCSIAdapter",
74
    "SCSIAdapter",
69
    "DTIAdapter",
75
    "DTIAdapter",
70
    "MultiFunctionAdapter",
76
    "MultiFunctionAdapter",
71
    "DiskController",
77
    "DiskController",
72
    "TapeController",
78
    "TapeController",
73
    "CDROMController",
79
    "CDROMController",
74
    "WORMController",
80
    "WORMController",
75
    "SerialController",
81
    "SerialController",
76
    "NetworkController",
82
    "NetworkController",
77
    "DisplayController",
83
    "DisplayController",
78
    "ParallelController",
84
    "ParallelController",
79
    "PointerController",
85
    "PointerController",
80
    "KeyboardController",
86
    "KeyboardController",
81
    "AudioController",
87
    "AudioController",
82
    "OtherController",
88
    "OtherController",
83
    "DiskPeripheral",
89
    "DiskPeripheral",
84
    "FloppyDiskPeripheral",
90
    "FloppyDiskPeripheral",
85
    "TapePeripheral",
91
    "TapePeripheral",
86
    "ModemPeripheral",
92
    "ModemPeripheral",
87
    "MonitorPeripheral",
93
    "MonitorPeripheral",
88
    "PrinterPeripheral",
94
    "PrinterPeripheral",
89
    "PointerPeripheral",
95
    "PointerPeripheral",
90
    "KeyboardPeripheral",
96
    "KeyboardPeripheral",
91
    "TerminalPeripheral",
97
    "TerminalPeripheral",
92
    "OtherPeripheral",
98
    "OtherPeripheral",
93
    "LinePeripheral",
99
    "LinePeripheral",
94
    "NetworkPeripheral"
100
    "NetworkPeripheral"
95
    "OtherPeripheral",
101
    "OtherPeripheral",
96
    "XTalkAdapter",
102
    "XTalkAdapter",
97
    "PCIAdapter",
103
    "PCIAdapter",
98
    "GIOAdapter",
104
    "GIOAdapter",
99
    "TPUAdapter",
105
    "TPUAdapter",
100
    "Anonymous"
106
    "Anonymous"
101
};
107
};
102
 
108
 
103
static arc_sbp *sbp = (arc_sbp *)PA2KA(0x1000);
109
static arc_sbp *sbp = (arc_sbp *)PA2KA(0x1000);
104
static arc_func_vector_t *arc_entry;
110
static arc_func_vector_t *arc_entry;
105
 
111
 
106
 
112
 
107
static void arc_putchar(char ch);
113
static void arc_putchar(char ch);
108
 
114
 
109
/** Return true if ARC is available */
115
/** Return true if ARC is available */
110
int arc_enabled(void)
116
int arc_enabled(void)
111
{
117
{
112
    return sbp != NULL;
118
    return sbp != NULL;
113
}
119
}
114
 
120
 
115
 
121
 
116
/** Print configuration data that ARC reports about component */
122
/** Print configuration data that ARC reports about component */
117
static void arc_print_confdata(arc_component *c)
123
static void arc_print_confdata(arc_component *c)
118
{
124
{
119
    cm_resource_list *configdata;
125
    cm_resource_list *configdata;
120
    int i;
126
    int i;
121
 
127
 
122
    if (!c->configdatasize)
128
    if (!c->configdatasize)
123
        return; /* No configuration data */
129
        return; /* No configuration data */
124
 
130
 
125
    configdata = malloc(c->configdatasize, 0);
131
    configdata = malloc(c->configdatasize, 0);
126
 
132
 
127
    if (arc_entry->getconfigurationdata(configdata, c)) {
133
    if (arc_entry->getconfigurationdata(configdata, c)) {
128
        free(configdata);
134
        free(configdata);
129
        return;
135
        return;
130
    }
136
    }
131
    /* Does not seem to return meaningful data, don't use now */
137
    /* Does not seem to return meaningful data, don't use now */
132
    free(configdata);
138
    free(configdata);
133
    return;
139
    return;
134
   
140
   
135
    for (i=0; i < configdata->count; i++) {
141
    for (i=0; i < configdata->count; i++) {
136
        switch (configdata->descr[i].type) {
142
        switch (configdata->descr[i].type) {
137
        case CmResourceTypePort:
143
        case CmResourceTypePort:
138
            printf("Port: %p-size:%d ",
144
            printf("Port: %p-size:%d ",
139
                   (__address)configdata->descr[i].u.port.start,
145
                   (__address)configdata->descr[i].u.port.start,
140
                   configdata->descr[i].u.port.length);
146
                   configdata->descr[i].u.port.length);
141
            break;
147
            break;
142
        case CmResourceTypeInterrupt:
148
        case CmResourceTypeInterrupt:
143
            printf("Irq: level(%d) vector(%d) ",
149
            printf("Irq: level(%d) vector(%d) ",
144
                   configdata->descr[i].u.interrupt.level,
150
                   configdata->descr[i].u.interrupt.level,
145
                   configdata->descr[i].u.interrupt.vector);
151
                   configdata->descr[i].u.interrupt.vector);
146
            break;
152
            break;
147
        case CmResourceTypeMemory:
153
        case CmResourceTypeMemory:
148
            printf("Memory: %p-size:%d ",
154
            printf("Memory: %p-size:%d ",
149
                   (__address)configdata->descr[i].u.port.start,
155
                   (__address)configdata->descr[i].u.port.start,
150
                   configdata->descr[i].u.port.length);
156
                   configdata->descr[i].u.port.length);
151
            break;
157
            break;
152
        default:
158
        default:
153
            break;
159
            break;
154
        }
160
        }
155
    }
161
    }
156
 
162
 
157
    free(configdata);
163
    free(configdata);
158
}
164
}
159
 
165
 
160
/** Print information about component */
166
/** Print information about component */
161
static void arc_print_component(arc_component *c)
167
static void arc_print_component(arc_component *c)
162
{
168
{
163
    int i;
169
    int i;
164
 
170
 
165
    printf("%s: ",ctypes[c->type]);
171
    printf("%s: ",ctypes[c->type]);
166
    for (i=0;i < c->identifier_len;i++)
172
    for (i=0;i < c->identifier_len;i++)
167
        printf("%c",c->identifier[i]);
173
        printf("%c",c->identifier[i]);
168
 
174
 
169
    printf(" ");
175
    printf(" ");
170
    arc_print_confdata(c);
176
    arc_print_confdata(c);
171
    printf("\n");
177
    printf("\n");
172
}
178
}
173
 
179
 
174
/**
180
/**
175
 * Read from ARC bios configuration data and print it
181
 * Read from ARC bios configuration data and print it
176
 */
182
 */
177
static int cmd_arc_print_devices(cmd_arg_t *argv)
183
static int cmd_arc_print_devices(cmd_arg_t *argv)
178
{
184
{
179
    arc_component *c,*next;
185
    arc_component *c,*next;
180
 
186
 
181
    c = arc_entry->getchild(NULL);
187
    c = arc_entry->getchild(NULL);
182
    while (c) {
188
    while (c) {
183
        arc_print_component(c);
189
        arc_print_component(c);
184
        next = arc_entry->getchild(c);
190
        next = arc_entry->getchild(c);
185
        while (!next) {
191
        while (!next) {
186
            next = arc_entry->getpeer(c);
192
            next = arc_entry->getpeer(c);
187
            if (!next)
193
            if (!next)
188
                c = arc_entry->getparent(c);
194
                c = arc_entry->getparent(c);
189
            if (!c)
195
            if (!c)
190
                return 0;
196
                return 0;
191
        }
197
        }
192
        c = next;
198
        c = next;
193
    }
199
    }
194
    return 1;
200
    return 1;
195
}
201
}
196
static cmd_info_t devlist_info = {
202
static cmd_info_t devlist_info = {
197
    .name = "arcdevlist",
203
    .name = "arcdevlist",
198
    .description = "Print arc device list",
204
    .description = "Print arc device list",
199
    .func = cmd_arc_print_devices,
205
    .func = cmd_arc_print_devices,
200
    .argc = 0
206
    .argc = 0
201
};
207
};
202
 
208
 
203
 
209
 
204
/** Read from arc bios memory map and print it
210
/** Read from arc bios memory map and print it
205
 *
211
 *
206
 */
212
 */
207
static int cmd_arc_print_memmap(cmd_arg_t *argv)
213
static int cmd_arc_print_memmap(cmd_arg_t *argv)
208
{
214
{
209
    arc_memdescriptor_t *desc;
215
    arc_memdescriptor_t *desc;
210
 
216
 
211
    printf("Memory map:\n");
217
    printf("Memory map:\n");
212
 
218
 
213
    desc = arc_entry->getmemorydescriptor(NULL);
219
    desc = arc_entry->getmemorydescriptor(NULL);
214
    while (desc) {
220
    while (desc) {
215
        printf("%s: %d(%p) (size: %dKB)\n",basetypes[desc->type],
221
        printf("%s: %d(%p) (size: %dKB)\n",basetypes[desc->type],
216
               desc->basepage * ARC_FRAME,
222
               desc->basepage * ARC_FRAME,
217
               desc->basepage * ARC_FRAME,
223
               desc->basepage * ARC_FRAME,
218
               desc->basecount*ARC_FRAME/1024);
224
               desc->basecount*ARC_FRAME/1024);
219
        desc = arc_entry->getmemorydescriptor(desc);
225
        desc = arc_entry->getmemorydescriptor(desc);
220
    }
226
    }
221
    return 1;
227
    return 1;
222
}
228
}
223
static cmd_info_t memmap_info = {
229
static cmd_info_t memmap_info = {
224
    .name = "arcmemmap",
230
    .name = "arcmemmap",
225
    .description = "Print arc memory map",
231
    .description = "Print arc memory map",
226
    .func = cmd_arc_print_memmap,
232
    .func = cmd_arc_print_memmap,
227
    .argc = 0
233
    .argc = 0
228
};
234
};
229
 
235
 
230
/** Print charactor to console */
236
/** Print charactor to console */
231
static void arc_putchar(char ch)
237
static void arc_putchar(char ch)
232
{
238
{
233
    __u32 cnt;
239
    __u32 cnt;
234
    ipl_t ipl;
240
    ipl_t ipl;
235
 
241
 
236
    /* TODO: Should be spinlock? */
242
    /* TODO: Should be spinlock? */
237
    ipl = interrupts_disable();
243
    ipl = interrupts_disable();
238
    arc_entry->write(1, &ch, 1, &cnt);
244
    arc_entry->write(1, &ch, 1, &cnt);
239
    interrupts_restore(ipl);
245
    interrupts_restore(ipl);
240
   
246
   
241
}
247
}
242
 
248
 
243
static int cmd_reboot(cmd_arg_t *argv)
249
static int cmd_reboot(cmd_arg_t *argv)
244
{
250
{
245
    arc_entry->reboot();
251
    arc_entry->reboot();
246
    return 0;
252
    return 0;
247
}
253
}
248
static cmd_info_t reboot_info = {
254
static cmd_info_t reboot_info = {
249
    .name = "reboot",
255
    .name = "reboot",
250
    .description = "Reboot computer",
256
    .description = "Reboot computer",
251
    .func = cmd_reboot,
257
    .func = cmd_reboot,
252
    .argc = 0
258
    .argc = 0
253
};
259
};
254
 
260
 
255
/** Initialize ARC structure
261
/** Initialize ARC structure
256
 *
262
 *
257
 * @return 0 - ARC OK, -1 - ARC does not exist
263
 * @return 0 - ARC OK, -1 - ARC does not exist
258
 */
264
 */
259
int arc_init(void)
265
int arc_init(void)
260
{
266
{
261
    if (sbp->signature != ARC_MAGIC) {
267
    if (sbp->signature != ARC_MAGIC) {
262
        sbp = NULL;
268
        sbp = NULL;
263
        return -1;
269
        return -1;
264
    }
270
    }
265
    arc_entry = sbp->firmwarevector;
271
    arc_entry = sbp->firmwarevector;
266
 
272
 
267
    arc_putchar('A');
273
    arc_putchar('A');
268
    arc_putchar('R');
274
    arc_putchar('R');
269
    arc_putchar('C');
275
    arc_putchar('C');
270
    arc_putchar('\n');
276
    arc_putchar('\n');
271
 
277
 
272
    /* Add command for resetting the computer */
278
    /* Add command for resetting the computer */
273
    cmd_initialize(&reboot_info);
279
    cmd_initialize(&reboot_info);
274
    cmd_register(&reboot_info);
280
    cmd_register(&reboot_info);
275
    cmd_initialize(&memmap_info);
281
    cmd_initialize(&memmap_info);
276
    cmd_register(&memmap_info);
282
    cmd_register(&memmap_info);
277
    cmd_initialize(&devlist_info);
283
    cmd_initialize(&devlist_info);
278
    cmd_register(&devlist_info);
284
    cmd_register(&devlist_info);
279
 
285
 
280
    return 0;
286
    return 0;
281
}
287
}
282
 
288
 
283
static bool kbd_polling_enabled;
289
static bool kbd_polling_enabled;
284
static chardev_t console;
290
static chardev_t console;
285
 
291
 
286
/** Try to get character, return character or -1 if not available */
292
/** Try to get character, return character or -1 if not available */
287
static void arc_keyboard_poll(void)
293
static void arc_keyboard_poll(void)
288
{
294
{
289
    char ch;
295
    char ch;
290
    __u32 count;
296
    __u32 count;
291
    long result;
297
    long result;
292
   
298
   
293
    if (! kbd_polling_enabled)
299
    if (! kbd_polling_enabled)
294
        return;
300
        return;
295
 
301
 
296
    if (arc_entry->getreadstatus(0))
302
    if (arc_entry->getreadstatus(0))
297
        return;
303
        return;
298
    result = arc_entry->read(0, &ch, 1, &count);
304
    result = arc_entry->read(0, &ch, 1, &count);
299
    if (result || count!=1) {
305
    if (result || count!=1) {
300
        return;
306
        return;
301
    }
307
    }
302
    if (ch == '\r')
308
    if (ch == '\r')
303
        ch = '\n';
309
        ch = '\n';
304
    if (ch == 0x7f)
310
    if (ch == 0x7f)
305
        ch = '\b';
311
        ch = '\b';
306
   
312
   
307
    chardev_push_character(&console, ch);
313
    chardev_push_character(&console, ch);
308
}
314
}
309
 
315
 
310
static char arc_read(chardev_t *dev)
316
static char arc_read(chardev_t *dev)
311
{
317
{
312
    char ch;
318
    char ch;
313
    __u32 count;
319
    __u32 count;
314
    long result;
320
    long result;
315
 
321
 
316
    result = arc_entry->read(0, &ch, 1, &count);
322
    result = arc_entry->read(0, &ch, 1, &count);
317
    if (result || count!=1) {
323
    if (result || count!=1) {
318
        printf("Error reading from ARC keyboard.\n");
324
        printf("Error reading from ARC keyboard.\n");
319
        cpu_halt();
325
        cpu_halt();
320
    }
326
    }
321
    if (ch == '\r')
327
    if (ch == '\r')
322
        return '\n';
328
        return '\n';
323
    if (ch == 0x7f)
329
    if (ch == 0x7f)
324
        return '\b';
330
        return '\b';
325
    return ch;
331
    return ch;
326
}
332
}
327
 
333
 
328
static void arc_write(chardev_t *dev, const char ch)
334
static void arc_write(chardev_t *dev, const char ch)
329
{
335
{
330
    arc_putchar(ch);
336
    arc_putchar(ch);
331
}
337
}
332
 
338
 
333
static void arc_enable(chardev_t *dev)
339
static void arc_enable(chardev_t *dev)
334
{
340
{
335
    kbd_polling_enabled = true;
341
    kbd_polling_enabled = true;
336
}
342
}
337
 
343
 
338
static void arc_disable(chardev_t *dev)
344
static void arc_disable(chardev_t *dev)
339
{
345
{
340
    kbd_polling_enabled = false;
346
    kbd_polling_enabled = false;
341
}
347
}
342
 
348
 
343
static chardev_operations_t arc_ops = {
349
static chardev_operations_t arc_ops = {
344
    .resume = arc_enable,
350
    .resume = arc_enable,
345
    .suspend = arc_disable,
351
    .suspend = arc_disable,
346
    .write = arc_write,
352
    .write = arc_write,
347
    .read = arc_read
353
    .read = arc_read
348
};
354
};
349
 
355
 
350
iroutine old_timer;
356
iroutine old_timer;
351
/** Do polling on timer interrupt */
357
/** Do polling on timer interrupt */
352
static void timer_replace(int n, istate_t *istate)
358
static void timer_replace(int n, istate_t *istate)
353
{
359
{
354
    arc_keyboard_poll();
360
    arc_keyboard_poll();
355
    old_timer(n, istate);
361
    old_timer(n, istate);
356
    arc_keyboard_poll();
362
    arc_keyboard_poll();
357
}
363
}
358
 
364
 
359
void arc_console(void)
365
void arc_console(void)
360
{
366
{
361
    kbd_polling_enabled = true;
367
    kbd_polling_enabled = true;
362
   
368
   
363
    chardev_initialize("arc_console", &console, &arc_ops);
369
    chardev_initialize("arc_console", &console, &arc_ops);
364
    old_timer = int_register(TIMER_IRQ, "arc_kb_poll", timer_replace);
370
    old_timer = int_register(TIMER_IRQ, "arc_kb_poll", timer_replace);
365
    stdin = &console;
371
    stdin = &console;
366
    stdout = &console;
372
    stdout = &console;
367
}
373
}
368
 
374
 
369
/* Initialize frame zones from ARC firmware.
375
/* Initialize frame zones from ARC firmware.
370
 * In the future we may use even the FirmwareTemporary regions,
376
 * In the future we may use even the FirmwareTemporary regions,
371
 * currently we use the FreeMemory (what about the LoadedProgram?)
377
 * currently we use the FreeMemory (what about the LoadedProgram?)
372
 */
378
 */
373
void arc_frame_init(void)
379
void arc_frame_init(void)
374
{
380
{
375
    arc_memdescriptor_t *desc;
381
    arc_memdescriptor_t *desc;
376
    int total = 0;
382
    int total = 0;
377
    __address base;
383
    __address base;
378
    size_t basesize;
384
    size_t basesize;
379
 
385
 
380
    desc = arc_entry->getmemorydescriptor(NULL);
386
    desc = arc_entry->getmemorydescriptor(NULL);
381
    while (desc) {
387
    while (desc) {
382
        if (desc->type == FreeMemory ||
388
        if (desc->type == FreeMemory ||
383
            desc->type == FreeContiguous) {
389
            desc->type == FreeContiguous) {
384
            base = desc->basepage*ARC_FRAME;
390
            base = desc->basepage*ARC_FRAME;
385
            basesize = desc->basecount*ARC_FRAME;
391
            basesize = desc->basecount*ARC_FRAME;
386
 
392
 
387
            if (base % FRAME_SIZE ) {
393
            if (base % FRAME_SIZE ) {
388
                basesize -= FRAME_SIZE - (base % FRAME_SIZE);
394
                basesize -= FRAME_SIZE - (base % FRAME_SIZE);
389
                base = ALIGN_UP(base, FRAME_SIZE);
395
                base = ALIGN_UP(base, FRAME_SIZE);
390
            }
396
            }
391
            basesize = ALIGN_DOWN(basesize, FRAME_SIZE);
397
            basesize = ALIGN_DOWN(basesize, FRAME_SIZE);
392
 
398
 
393
            total += basesize;
399
            total += basesize;
394
           
400
           
395
            zone_create(ADDR2PFN(base), SIZE2FRAMES(basesize),
401
            zone_create(ADDR2PFN(base), SIZE2FRAMES(basesize),
396
                    ADDR2PFN(base), 0);
402
                    ADDR2PFN(base), 0);
397
        }
403
        }
398
        desc = arc_entry->getmemorydescriptor(desc);
404
        desc = arc_entry->getmemorydescriptor(desc);
399
    }
405
    }
400
 
406
 
401
    config.memory_size = total;
407
    config.memory_size = total;
402
}
408
}
403
 
409
 
-
 
410
 
-
 
411
 /** @}
-
 
412
 */
-
 
413
 
404
 
414