Changeset b5ed4f8 in mainline


Ignore:
Timestamp:
2008-02-05T14:48:26Z (16 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0b5f9fa
Parents:
b07c332
Message:

convert ARC specific commands to generic ones

Location:
kernel/arch/mips32
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/mips32/include/drivers/arc.h

    rb07c332 rb5ed4f8  
    258258
    259259extern int arc_init(void);
    260 extern int arc_enabled(void);
    261 void arc_frame_init(void);
    262 void arc_console(void);
     260extern int arc_reboot(void);
     261extern int arc_frame_init(void);
     262extern int arc_console(void);
    263263
    264264#endif
  • kernel/arch/mips32/include/mm/frame.h

    rb07c332 rb5ed4f8  
    4343
    4444extern void frame_arch_init(void);
    45 #define physmem_print()
     45extern void physmem_print(void);
    4646
    4747#endif /* __ASM__ */
  • kernel/arch/mips32/src/console.c

    rb07c332 rb5ed4f8  
    4141void console_init(devno_t devno)
    4242{
    43         if (arc_enabled()) {
    44                 arc_console();
    45         } else if (serial_init()) {
    46                 serial_console(devno);
    47         } else {
    48                 msim_console(devno);
     43        if (!arc_console()) {
     44                if (serial_init())
     45                        serial_console(devno);
     46                else
     47                        msim_console(devno);
    4948        }
    5049}
  • kernel/arch/mips32/src/drivers/arc.c

    rb07c332 rb5ed4f8  
    107107};
    108108
    109 static arc_sbp *sbp = (arc_sbp *)PA2KA(0x1000);
     109static arc_sbp *sbp = (arc_sbp *) PA2KA(0x1000);
    110110static arc_func_vector_t *arc_entry;
    111111
    112112
    113 static void arc_putchar(char ch);
    114 
    115113/** Return true if ARC is available */
    116 int arc_enabled(void)
    117 {
    118         return sbp != NULL;
    119 }
     114#define arc_enabled() (sbp != NULL)
    120115
    121116
     
    139134        return;
    140135       
    141         for (i=0; i < configdata->count; i++) {
     136        for (i = 0; i < configdata->count; i++) {
    142137                switch (configdata->descr[i].type) {
    143138                case CmResourceTypePort:
    144139                        printf("Port: %p-size:%d ",
    145                                (uintptr_t)configdata->descr[i].u.port.start,
     140                               (uintptr_t) configdata->descr[i].u.port.start,
    146141                               configdata->descr[i].u.port.length);
    147142                        break;
     
    170165
    171166        printf("%s: ",ctypes[c->type]);
    172         for (i=0;i < c->identifier_len;i++)
    173                 printf("%c",c->identifier[i]);
     167        for (i = 0; i < c->identifier_len; i++)
     168                printf("%c", c->identifier[i]);
    174169
    175170        printf(" ");
     
    183178static int cmd_arc_print_devices(cmd_arg_t *argv)
    184179{
    185         arc_component *c,*next;
     180        arc_component *c, *next;
    186181
    187182        c = arc_entry->getchild(NULL);
     
    211206 *
    212207 */
    213 static int cmd_arc_print_memmap(cmd_arg_t *argv)
    214 {
    215         arc_memdescriptor_t *desc;
    216 
    217         printf("Memory map:\n");
    218 
    219         desc = arc_entry->getmemorydescriptor(NULL);
    220         while (desc) {
    221                 printf("%s: %d(%p) (size: %dKB)\n",basetypes[desc->type],
    222                        desc->basepage * ARC_FRAME,
    223                        desc->basepage * ARC_FRAME,
    224                        desc->basecount*ARC_FRAME/1024);
    225                 desc = arc_entry->getmemorydescriptor(desc);
    226         }
    227         return 1;
    228 }
    229 static cmd_info_t memmap_info = {
    230         .name = "arcmemmap",
    231         .description = "Print arc memory map",
    232         .func = cmd_arc_print_memmap,
    233         .argc = 0
    234 };
     208void physmem_print(void)
     209{
     210        printf("Base       Size       Type\n");
     211        printf("---------- ---------- ---------\n");
     212       
     213        if (arc_enabled()) {
     214                arc_memdescriptor_t *desc = arc_entry->getmemorydescriptor(NULL);
     215               
     216                while (desc) {
     217                        printf("%#10x %#10x %s\n",
     218                                desc->basepage * ARC_FRAME, desc->basecount * ARC_FRAME,
     219                                basetypes[desc->type]);
     220                        desc = arc_entry->getmemorydescriptor(desc);
     221                }       
     222        } else
     223                printf("%#10x %#10x free\n", 0, config.memory_size);
     224}
    235225
    236226/** Print charactor to console */
     
    244234        arc_entry->write(1, &ch, 1, &cnt);
    245235        interrupts_restore(ipl);
    246        
    247 }
    248 
    249 static int cmd_reboot(cmd_arg_t *argv)
    250 {
    251         arc_entry->reboot();
    252         return 0;
    253 }
    254 static cmd_info_t reboot_info = {
    255         .name = "reboot",
    256         .description = "Reboot computer",
    257         .func = cmd_reboot,
    258         .argc = 0
    259 };
     236}
     237
    260238
    261239/** Initialize ARC structure
     
    277255
    278256        /* Add command for resetting the computer */
    279         cmd_initialize(&reboot_info);
    280         cmd_register(&reboot_info);
    281         cmd_initialize(&memmap_info);
    282         cmd_register(&memmap_info);
    283257        cmd_initialize(&devlist_info);
    284258        cmd_register(&devlist_info);
     
    286260        return 0;
    287261}
     262
     263int arc_reboot(void)
     264{
     265        if (arc_enabled()) {
     266                arc_entry->reboot();
     267                return true;
     268        }
     269       
     270        return false;
     271}
     272
    288273
    289274static bool kbd_polling_enabled;
     
    297282        long result;
    298283       
    299         if (! kbd_polling_enabled)
     284        if (!kbd_polling_enabled)
    300285                return;
    301286
     
    303288                return;
    304289        result = arc_entry->read(0, &ch, 1, &count);
    305         if (result || count!=1) {
     290        if ((result) || (count != 1)) {
    306291                return;
    307292        }
     
    321306
    322307        result = arc_entry->read(0, &ch, 1, &count);
    323         if (result || count!=1) {
     308        if ((result) || (count != 1)) {
    324309                printf("Error reading from ARC keyboard.\n");
    325310                cpu_halt();
     
    354339};
    355340
    356 void arc_console(void)
    357 {
    358         kbd_polling_enabled = true;
    359        
    360         chardev_initialize("arc_console", &console, &arc_ops);
    361         virtual_timer_fnc = &arc_keyboard_poll;
    362         stdin = &console;
    363         stdout = &console;
     341int arc_console(void)
     342{
     343        if (arc_enabled()) {
     344                kbd_polling_enabled = true;
     345               
     346                chardev_initialize("arc_console", &console, &arc_ops);
     347                virtual_timer_fnc = &arc_keyboard_poll;
     348                stdin = &console;
     349                stdout = &console;
     350               
     351                return true;
     352        }
     353       
     354        return false;
    364355}
    365356
     
    368359 * currently we use the FreeMemory (what about the LoadedProgram?)
    369360 */
    370 void arc_frame_init(void)
    371 {
    372         arc_memdescriptor_t *desc;
    373         int total = 0;
    374         uintptr_t base;
    375         size_t basesize;
    376 
    377         desc = arc_entry->getmemorydescriptor(NULL);
    378         while (desc) {
    379                 if (desc->type == FreeMemory ||
    380                     desc->type == FreeContiguous) {
    381                         base = desc->basepage*ARC_FRAME;
    382                         basesize = desc->basecount*ARC_FRAME;
    383 
    384                         if (base % FRAME_SIZE ) {
    385                                 basesize -= FRAME_SIZE - (base % FRAME_SIZE);
    386                                 base = ALIGN_UP(base, FRAME_SIZE);
     361int arc_frame_init(void)
     362{
     363        if (arc_enabled()) {
     364                arc_memdescriptor_t *desc;
     365                int total = 0;
     366                uintptr_t base;
     367                size_t basesize;
     368       
     369                desc = arc_entry->getmemorydescriptor(NULL);
     370                while (desc) {
     371                        if ((desc->type == FreeMemory) ||
     372                            (desc->type == FreeContiguous)) {
     373                                base = desc->basepage*ARC_FRAME;
     374                                basesize = desc->basecount*ARC_FRAME;
     375       
     376                                if (base % FRAME_SIZE ) {
     377                                        basesize -= FRAME_SIZE - (base % FRAME_SIZE);
     378                                        base = ALIGN_UP(base, FRAME_SIZE);
     379                                }
     380                                basesize = ALIGN_DOWN(basesize, FRAME_SIZE);
     381       
     382                                total += basesize;
     383                               
     384                                zone_create(ADDR2PFN(base), SIZE2FRAMES(basesize),
     385                                            ADDR2PFN(base), 0);
    387386                        }
    388                         basesize = ALIGN_DOWN(basesize, FRAME_SIZE);
    389 
    390                         total += basesize;
    391                        
    392                         zone_create(ADDR2PFN(base), SIZE2FRAMES(basesize),
    393                                     ADDR2PFN(base), 0);
     387                        desc = arc_entry->getmemorydescriptor(desc);
    394388                }
    395                 desc = arc_entry->getmemorydescriptor(desc);
    396         }
    397 
    398         config.memory_size = total;
     389       
     390                config.memory_size = total;
     391                return true;
     392        }
     393       
     394        return false;
    399395}
    400396
  • kernel/arch/mips32/src/mips32.c

    rb07c332 rb5ed4f8  
    142142void userspace(uspace_arg_t *kernel_uarg)
    143143{
    144         /* EXL=1, UM=1, IE=1 */
     144        /* EXL = 1, UM = 1, IE = 1 */
    145145        cp0_status_write(cp0_status_read() | (cp0_status_exl_exception_bit |
    146                                               cp0_status_um_bit |
    147                                               cp0_status_ie_enabled_bit));
     146                cp0_status_um_bit | cp0_status_ie_enabled_bit));
    148147        cp0_epc_write((uintptr_t) kernel_uarg->uspace_entry);
    149         userspace_asm(((uintptr_t) kernel_uarg->uspace_stack+PAGE_SIZE),
    150                       (uintptr_t) kernel_uarg->uspace_uarg,
    151                       (uintptr_t) kernel_uarg->uspace_entry);
    152         while (1)
    153                 ;
     148        userspace_asm(((uintptr_t) kernel_uarg->uspace_stack + PAGE_SIZE),
     149                (uintptr_t) kernel_uarg->uspace_uarg,
     150                (uintptr_t) kernel_uarg->uspace_entry);
     151       
     152        while (1);
    154153}
    155154
     
    181180void arch_reboot(void)
    182181{
    183         ___halt();
     182        if (!arc_reboot())
     183                ___halt();
     184       
    184185        while (1);
    185186}
  • kernel/arch/mips32/src/mm/frame.c

    rb07c332 rb5ed4f8  
    4646void frame_arch_init(void)
    4747{
    48         if (arc_enabled())
    49                 arc_frame_init();
    50         else {
     48        if (!arc_frame_init()) {
    5149                zone_create(0, ADDR2PFN(config.memory_size), 1, 0);
    5250                /*
Note: See TracChangeset for help on using the changeset viewer.