Changeset b50b5af2 in mainline for kernel/arch/ppc32/src/ppc32.c


Ignore:
Timestamp:
2009-08-22T10:48:00Z (15 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
04803bf
Parents:
1ea99cc (diff), a71c158 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/ppc32/src/ppc32.c

    r1ea99cc rb50b5af2  
    4141#include <genarch/fb/fb.h>
    4242#include <genarch/fb/visuals.h>
     43#include <genarch/ofw/ofw_tree.h>
     44#include <genarch/ofw/pci.h>
    4345#include <userspace.h>
    4446#include <proc/uarg.h>
     
    4951#include <macros.h>
    5052#include <string.h>
     53#include <print.h>
    5154
    5255#define IRQ_COUNT  64
     
    6366       
    6467        for (i = 0; i < min3(bootinfo.taskmap.count, TASKMAP_MAX_RECORDS, CONFIG_INIT_TASKS); i++) {
    65                 init.tasks[i].addr = PA2KA(bootinfo.taskmap.tasks[i].addr);
     68                init.tasks[i].addr = bootinfo.taskmap.tasks[i].addr;
    6669                init.tasks[i].size = bootinfo.taskmap.tasks[i].size;
    6770                str_cpy(init.tasks[i].name, CONFIG_TASK_NAME_BUFLEN,
    6871                    bootinfo.taskmap.tasks[i].name);
    6972        }
     73       
     74        /* Copy boot allocations info. */
     75        ballocs.base = bootinfo.ballocs.base;
     76        ballocs.size = bootinfo.ballocs.size;
     77       
     78        ofw_tree_init(bootinfo.ofw_root);
    7079}
    7180
     
    7483        /* Initialize dispatch table */
    7584        interrupt_init();
    76 
     85       
    7786        /* Start decrementer */
    7887        start_decrementer();
    7988}
    8089
     90static bool display_register(ofw_tree_node_t *node, void *arg)
     91{
     92        uintptr_t fb_addr = 0;
     93        uint32_t fb_width = 0;
     94        uint32_t fb_height = 0;
     95        uint32_t fb_scanline = 0;
     96        unsigned int visual = VISUAL_UNKNOWN;
     97       
     98        ofw_tree_property_t *prop = ofw_tree_getprop(node, "address");
     99        if ((prop) && (prop->value))
     100                fb_addr = *((uintptr_t *) prop->value);
     101       
     102        prop = ofw_tree_getprop(node, "width");
     103        if ((prop) && (prop->value))
     104                fb_width = *((uint32_t *) prop->value);
     105       
     106        prop = ofw_tree_getprop(node, "height");
     107        if ((prop) && (prop->value))
     108                fb_height = *((uint32_t *) prop->value);
     109       
     110        prop = ofw_tree_getprop(node, "depth");
     111        if ((prop) && (prop->value)) {
     112                uint32_t fb_bpp = *((uint32_t *) prop->value);
     113                switch (fb_bpp) {
     114                case 8:
     115                        visual = VISUAL_INDIRECT_8;
     116                        break;
     117                case 16:
     118                        visual = VISUAL_RGB_5_5_5_BE;
     119                        break;
     120                case 24:
     121                        visual = VISUAL_BGR_8_8_8;
     122                        break;
     123                case 32:
     124                        visual = VISUAL_RGB_0_8_8_8;
     125                        break;
     126                default:
     127                        visual = VISUAL_UNKNOWN;
     128                }
     129        }
     130       
     131        prop = ofw_tree_getprop(node, "linebytes");
     132        if ((prop) && (prop->value))
     133                fb_scanline = *((uint32_t *) prop->value);
     134       
     135        if ((fb_addr) && (fb_width > 0) && (fb_height > 0)
     136            && (fb_scanline > 0) && (visual != VISUAL_UNKNOWN)) {
     137                fb_properties_t fb_prop = {
     138                        .addr = fb_addr,
     139                        .offset = 0,
     140                        .x = fb_width,
     141                        .y = fb_height,
     142                        .scan = fb_scanline,
     143                        .visual = visual,
     144                };
     145               
     146                outdev_t *fbdev = fb_init(&fb_prop);
     147                if (fbdev)
     148                        stdout_wire(fbdev);
     149        }
     150       
     151        return true;
     152}
     153
    81154void arch_post_mm_init(void)
    82155{
    83156        if (config.cpu_active == 1) {
    84 
    85157#ifdef CONFIG_FB
    86                 /* Initialize framebuffer */
    87                 if (bootinfo.screen.addr) {
    88                         unsigned int visual;
    89                        
    90                         switch (bootinfo.screen.bpp) {
    91                         case 8:
    92                                 visual = VISUAL_INDIRECT_8;
    93                                 break;
    94                         case 16:
    95                                 visual = VISUAL_RGB_5_5_5_BE;
    96                                 break;
    97                         case 24:
    98                                 visual = VISUAL_BGR_8_8_8;
    99                                 break;
    100                         case 32:
    101                                 visual = VISUAL_RGB_0_8_8_8;
    102                                 break;
    103                         default:
    104                                 panic("Unsupported bits per pixel.");
    105                         }
    106                         fb_properties_t prop = {
    107                                 .addr = bootinfo.screen.addr,
    108                                 .offset = 0,
    109                                 .x = bootinfo.screen.width,
    110                                 .y = bootinfo.screen.height,
    111                                 .scan = bootinfo.screen.scanline,
    112                                 .visual = visual,
    113                         };
    114                         fb_init(&prop);
    115                 }
     158                ofw_tree_walk_by_device_type("display", display_register, NULL);
    116159#endif
    117160               
     
    132175}
    133176
    134 void arch_post_smp_init(void)
    135 {
    136         if (bootinfo.macio.addr) {
     177static bool macio_register(ofw_tree_node_t *node, void *arg)
     178{
     179        ofw_pci_reg_t *assigned_address = NULL;
     180       
     181        ofw_tree_property_t *prop = ofw_tree_getprop(node, "assigned-addresses");
     182        if ((prop) && (prop->value))
     183                assigned_address = ((ofw_pci_reg_t *) prop->value);
     184       
     185        if (assigned_address) {
    137186                /* Initialize PIC */
    138187                cir_t cir;
    139188                void *cir_arg;
    140                 pic_init(bootinfo.macio.addr, PAGE_SIZE, &cir, &cir_arg);
    141 
     189                pic_init(assigned_address[0].addr, PAGE_SIZE, &cir, &cir_arg);
     190               
    142191#ifdef CONFIG_MAC_KBD
    143                 uintptr_t pa = bootinfo.macio.addr + 0x16000;
     192                uintptr_t pa = assigned_address[0].addr + 0x16000;
    144193                uintptr_t aligned_addr = ALIGN_DOWN(pa, PAGE_SIZE);
    145194                size_t offset = pa - aligned_addr;
    146195                size_t size = 2 * PAGE_SIZE;
    147                        
     196               
    148197                cuda_t *cuda = (cuda_t *)
    149198                    (hw_map(aligned_addr, offset + size) + offset);
    150                        
     199               
    151200                /* Initialize I/O controller */
    152201                cuda_instance_t *cuda_instance =
     
    163212#endif
    164213        }
     214       
     215        /* Consider only a single device for now */
     216        return false;
     217}
     218
     219void arch_post_smp_init(void)
     220{
     221        ofw_tree_walk_by_device_type("mac-io", macio_register, NULL);
    165222}
    166223
     
    180237}
    181238
    182 /** Acquire console back for kernel
    183  *
    184  */
    185 void arch_grab_console(void)
    186 {
    187 #ifdef CONFIG_FB
    188         fb_redraw();
    189 #endif
    190 }
    191 
    192 /** Return console to userspace
    193  *
    194  */
    195 void arch_release_console(void)
    196 {
    197 }
    198 
    199239/** Construct function pointer
    200240 *
Note: See TracChangeset for help on using the changeset viewer.