Changeset f817d3a in mainline


Ignore:
Timestamp:
2009-01-29T17:24:35Z (15 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
43d6401
Parents:
26c67a8
Message:

use macio optionally

Files:
9 edited

Legend:

Unmodified
Added
Removed
  • boot/arch/ppc32/loader/main.c

    r26c67a8 rf817d3a  
    9090static void version_print(void)
    9191{
    92         printf("HelenOS PPC32 Bootloader\nRelease %s%s%s\nCopyright (c) 2006 HelenOS project\n", release, revision, timestamp);
     92        printf("HelenOS PPC32 Bootloader\nRelease %s%s%s\nCopyright (c) 2006 HelenOS project\n\n", release, revision, timestamp);
    9393}
    9494
     
    108108       
    109109        if (!ofw_memmap(&bootinfo.memmap)) {
    110                 printf("Error: unable to get memory map, halting.\n");
     110                printf("Error: Unable to get memory map, halting.\n");
    111111                halt();
    112112        }
    113113       
    114114        if (bootinfo.memmap.total == 0) {
    115                 printf("Error: no memory detected, halting.\n");
     115                printf("Error: No memory detected, halting.\n");
    116116                halt();
    117117        }
    118118       
    119119        if (!ofw_screen(&bootinfo.screen))
    120                 printf("Warning: unable to get screen properties.\n");
     120                printf("Warning: Unable to get screen properties.\n");
    121121       
    122         if (!ofw_keyboard(&bootinfo.keyboard))
    123                 printf("Warning: unable to get keyboard properties.\n");
     122        if (!ofw_macio(&bootinfo.macio))
     123                printf("Warning: Unable to get macio properties.\n");
    124124       
    125         printf("\nDevice statistics\n");
    126         printf(" screen at %L, resolution %dx%d, %d bpp (scanline %d bytes)\n", bootinfo.screen.addr, bootinfo.screen.width, bootinfo.screen.height, bootinfo.screen.bpp, bootinfo.screen.scanline);
    127         printf(" keyboard at %L (size %d bytes)\n", bootinfo.keyboard.addr, bootinfo.keyboard.size);
     125        printf("Device statistics\n");
     126       
     127        if (bootinfo.screen.addr)
     128                printf(" screen at %L, resolution %dx%d, %d bpp (scanline %d bytes)\n", bootinfo.screen.addr, bootinfo.screen.width, bootinfo.screen.height, bootinfo.screen.bpp, bootinfo.screen.scanline);
     129       
     130        if (bootinfo.macio.addr)
     131                printf(" macio at %L (size %d bytes)\n", bootinfo.macio.addr, bootinfo.macio.size);
    128132       
    129133        void *real_mode_pa = ofw_translate(&real_mode);
  • boot/arch/ppc32/loader/main.h

    r26c67a8 rf817d3a  
    4848        taskmap_t taskmap;
    4949        screen_t screen;
    50         keyboard_t keyboard;
     50        macio_t macio;
    5151} bootinfo_t;
    5252
  • boot/arch/ppc32/loader/ofwarch.c

    r26c67a8 rf817d3a  
    4949}
    5050
    51 int ofw_keyboard(keyboard_t *keyboard)
     51int ofw_macio(macio_t *macio)
    5252{
    5353        char device_name[BUF_SIZE];
     
    5555        if (ofw_get_property(ofw_aliases, "macio", device_name, sizeof(device_name)) <= 0)
    5656                return false;
    57                                
     57       
    5858        phandle device = ofw_find_device(device_name);
    5959        if (device == -1)
    6060                return false;
    61                                                                
    62         pci_reg_t macio;
    63         if (ofw_get_property(device, "assigned-addresses", &macio, sizeof(macio)) <= 0)
     61       
     62        pci_reg_t pci_reg;
     63        if (ofw_get_property(device, "assigned-addresses", &pci_reg, sizeof(pci_reg)) <= 0)
    6464                return false;
    65         keyboard->addr = (void *) macio.addr.addr_lo;
    66         keyboard->size = macio.size_lo;
     65       
     66        macio->addr = (void *) pci_reg.addr.addr_lo;
     67        macio->size = pci_reg.size_lo;
    6768
    6869        return true;
  • boot/genarch/ofw.h

    r26c67a8 rf817d3a  
    7575        void *addr;
    7676        uint32_t size;
    77 } keyboard_t;
     77} macio_t;
    7878
    7979typedef struct {
     
    123123extern int ofw_memmap(memmap_t *map);
    124124extern int ofw_screen(screen_t *screen);
    125 extern int ofw_keyboard(keyboard_t *keyboard);
     125extern int ofw_macio(macio_t *macio);
    126126extern int setup_palette(void);
    127127extern void ofw_quiesce(void);
  • kernel/arch/ppc32/include/boot/boot.h

    r26c67a8 rf817d3a  
    8080        uintptr_t addr;
    8181        unsigned int size;
    82 } keyboard_t;
     82} macio_t;
    8383
    8484typedef struct {
     
    8686        taskmap_t taskmap;
    8787        screen_t screen;
    88         keyboard_t keyboard;
     88        macio_t macio;
    8989} bootinfo_t;
    9090
  • kernel/arch/ppc32/src/drivers/cuda.c

    r26c67a8 rf817d3a  
    237237int cuda_get_scancode(void)
    238238{
    239         uint8_t kind;
    240         uint8_t data[4];
    241        
    242         receive_packet(&kind, 4, data);
    243        
    244         if ((kind == PACKET_ADB) && (data[0] == 0x40) && (data[1] == 0x2c))
    245                 return data[2];
     239        if (cuda) {
     240                uint8_t kind;
     241                uint8_t data[4];
     242               
     243                receive_packet(&kind, 4, data);
     244               
     245                if ((kind == PACKET_ADB) && (data[0] == 0x40) && (data[1] == 0x2c))
     246                        return data[2];
     247        }
    246248       
    247249        return -1;
     
    272274void cuda_grab(void)
    273275{
    274         ipl_t ipl = interrupts_disable();
    275         spinlock_lock(&cuda_irq.lock);
    276         cuda_irq.notif_cfg.notify = false;
    277         spinlock_unlock(&cuda_irq.lock);
    278         interrupts_restore(ipl);
     276        if (cuda) {
     277                ipl_t ipl = interrupts_disable();
     278                spinlock_lock(&cuda_irq.lock);
     279                cuda_irq.notif_cfg.notify = false;
     280                spinlock_unlock(&cuda_irq.lock);
     281                interrupts_restore(ipl);
     282        }
    279283}
    280284
     
    283287void cuda_release(void)
    284288{
    285         ipl_t ipl = interrupts_disable();
    286         spinlock_lock(&cuda_irq.lock);
    287         if (cuda_irq.notif_cfg.answerbox)
    288                 cuda_irq.notif_cfg.notify = true;
    289         spinlock_unlock(&cuda_irq.unlock);
    290         interrupts_restore(ipl);
     289        if (cuda) {
     290                ipl_t ipl = interrupts_disable();
     291                spinlock_lock(&cuda_irq.lock);
     292                if (cuda_irq.notif_cfg.answerbox)
     293                        cuda_irq.notif_cfg.notify = true;
     294                spinlock_unlock(&cuda_irq.unlock);
     295                interrupts_restore(ipl);
     296        }
    291297}
    292298
     
    294300void cuda_init(devno_t devno, uintptr_t base, size_t size)
    295301{
    296         cuda = (uint8_t *) hw_map(base, size); 
     302        cuda = (uint8_t *) hw_map(base, size);
    297303       
    298304        chardev_initialize("cuda_kbd", &kbrd, &ops);
     
    307313       
    308314        pic_enable_interrupt(CUDA_IRQ);
    309 
     315       
    310316        sysinfo_set_item_val("kbd", NULL, true);
    311317        sysinfo_set_item_val("kbd.devno", NULL, devno);
     
    346352
    347353void arch_reboot(void) {
    348         send_packet(PACKET_CUDA, 1, CUDA_RESET);
     354        if (cuda)
     355                send_packet(PACKET_CUDA, 1, CUDA_RESET);
     356       
    349357        asm volatile (
    350358                "b 0\n"
  • kernel/arch/ppc32/src/drivers/pic.c

    r26c67a8 rf817d3a  
    3939#include <bitops.h>
    4040
    41 static volatile uint32_t *pic;
     41static volatile uint32_t *pic = NULL;
    4242
    4343void pic_init(uintptr_t base, size_t size)
     
    4848void pic_enable_interrupt(int intnum)
    4949{
    50         if (intnum < 32) {
    51                 pic[PIC_MASK_LOW] = pic[PIC_MASK_LOW] | (1 << intnum);
    52         } else {
    53                 pic[PIC_MASK_HIGH] = pic[PIC_MASK_HIGH] | (1 << (intnum - 32));
     50        if (pic) {
     51                if (intnum < 32)
     52                        pic[PIC_MASK_LOW] = pic[PIC_MASK_LOW] | (1 << intnum);
     53                else
     54                        pic[PIC_MASK_HIGH] = pic[PIC_MASK_HIGH] | (1 << (intnum - 32));
    5455        }
    5556       
     
    5859void pic_disable_interrupt(int intnum)
    5960{
    60         if (intnum < 32) {
    61                 pic[PIC_MASK_LOW] = pic[PIC_MASK_LOW] & (~(1 << intnum));
    62         } else {
    63                 pic[PIC_MASK_HIGH] = pic[PIC_MASK_HIGH] & (~(1 << (intnum - 32)));
     61        if (pic) {
     62                if (intnum < 32)
     63                        pic[PIC_MASK_LOW] = pic[PIC_MASK_LOW] & (~(1 << intnum));
     64                else
     65                        pic[PIC_MASK_HIGH] = pic[PIC_MASK_HIGH] & (~(1 << (intnum - 32)));
    6466        }
    6567}
     
    6769void pic_ack_interrupt(int intnum)
    6870{
    69         if (intnum < 32)
    70                 pic[PIC_ACK_LOW] = 1 << intnum;
    71         else
    72                 pic[PIC_ACK_HIGH] = 1 << (intnum - 32);
     71        if (pic) {
     72                if (intnum < 32)
     73                        pic[PIC_ACK_LOW] = 1 << intnum;
     74                else
     75                        pic[PIC_ACK_HIGH] = 1 << (intnum - 32);
     76        }
    7377}
    7478
     
    7680int pic_get_pending(void)
    7781{
    78         int pending;
    79 
    80         pending = pic[PIC_PENDING_LOW];
    81         if (pending)
    82                 return fnzb32(pending);
    83        
    84         pending = pic[PIC_PENDING_HIGH];
    85         if (pending)
    86                 return fnzb32(pending) + 32;
     82        if (pic) {
     83                int pending;
     84               
     85                pending = pic[PIC_PENDING_LOW];
     86                if (pending)
     87                        return fnzb32(pending);
     88               
     89                pending = pic[PIC_PENDING_HIGH];
     90                if (pending)
     91                        return fnzb32(pending) + 32;
     92        }
    8793       
    8894        return -1;
  • kernel/arch/ppc32/src/ppc32.c

    r26c67a8 rf817d3a  
    7777        if (config.cpu_active == 1) {
    7878                /* Initialize framebuffer */
    79                 unsigned int visual;
    80                
    81                 switch (bootinfo.screen.bpp) {
    82                 case 8:
    83                         visual = VISUAL_INDIRECT_8;
    84                         break;
    85                 case 16:
    86                         visual = VISUAL_RGB_5_5_5;
    87                         break;
    88                 case 24:
    89                         visual = VISUAL_RGB_8_8_8;
    90                         break;
    91                 case 32:
    92                         visual = VISUAL_RGB_0_8_8_8;
    93                         break;
    94                 default:
    95                         panic("Unsupported bits per pixel.");
     79                if (bootinfo.screen.addr) {
     80                        unsigned int visual;
     81                       
     82                        switch (bootinfo.screen.bpp) {
     83                        case 8:
     84                                visual = VISUAL_INDIRECT_8;
     85                                break;
     86                        case 16:
     87                                visual = VISUAL_RGB_5_5_5;
     88                                break;
     89                        case 24:
     90                                visual = VISUAL_RGB_8_8_8;
     91                                break;
     92                        case 32:
     93                                visual = VISUAL_RGB_0_8_8_8;
     94                                break;
     95                        default:
     96                                panic("Unsupported bits per pixel.");
     97                        }
     98                        fb_properties_t prop = {
     99                                .addr = bootinfo.screen.addr,
     100                                .offset = 0,
     101                                .x = bootinfo.screen.width,
     102                                .y = bootinfo.screen.height,
     103                                .scan = bootinfo.screen.scanline,
     104                                .visual = visual,
     105                        };
     106                        fb_init(&prop);
    96107                }
    97                 fb_properties_t prop = {
    98                         .addr = bootinfo.screen.addr,
    99                         .offset = 0,
    100                         .x = bootinfo.screen.width,
    101                         .y = bootinfo.screen.height,
    102                         .scan = bootinfo.screen.scanline,
    103                         .visual = visual,
    104                 };
    105                 fb_init(&prop);
    106108               
    107109                /* Initialize IRQ routing */
    108110                irq_init(IRQ_COUNT, IRQ_COUNT);
    109        
    110                 /* Initialize PIC */
    111                 pic_init(bootinfo.keyboard.addr, PAGE_SIZE);
    112111               
    113                 /* Initialize I/O controller */
    114                 cuda_init(device_assign_devno(),
    115                     bootinfo.keyboard.addr + 0x16000, 2 * PAGE_SIZE);
     112                if (bootinfo.macio.addr) {
     113                        /* Initialize PIC */
     114                        pic_init(bootinfo.macio.addr, PAGE_SIZE);
     115                       
     116                        /* Initialize I/O controller */
     117                        cuda_init(device_assign_devno(),
     118                            bootinfo.macio.addr + 0x16000, 2 * PAGE_SIZE);
     119                }
    116120               
    117121                /* Merge all zones to 1 big zone */
  • uspace/srv/kbd/arch/ppc32/src/kbd.c

    r26c67a8 rf817d3a  
    184184int kbd_arch_init(void)
    185185{
     186        if (!sysinfo_value("kdb"))
     187                return 0;
     188       
    186189        return ipc_register_irq(sysinfo_value("kbd.inr"), sysinfo_value("kbd.devno"), 0, &cuda_kbd);
    187190}
Note: See TracChangeset for help on using the changeset viewer.