Changeset e731b0d in mainline for kernel/arch/ppc32


Ignore:
Timestamp:
2009-08-20T16:58:55Z (16 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b9c7425
Parents:
a11099f
Message:

make ppc32 OFW usage on par with sparc64, make appropriate modifications elsewhere

  • introduce ofw_tree_walk_by_device_type() to gather all OFW devices of a given type
  • ppc32 uses canonized OFW tree, mac-io and display devices are detected in kernel (not by the boot loader) by means of device type
  • various busses (PCI, EBUS, etc.) stay sparc64 specific for now
  • boot memcpy() is defined in a common way
  • BALLOC_MAX_SIZE is platform-dependent
  • ppc32 and sparc64 boot loaders cleanup (removal of obsolete stuff, data is not passed by global variables if not necessary, etc.)
  • balloc and OFW tree canonizer have now a provision to support different mapping of the data during boot time and kernel run-time
  • OFW tree canonizer uses balloc_rebase() to store pointers suitable for access during kernel run-time (with potentially different memory mapping than during boot time)
Location:
kernel/arch/ppc32
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/ppc32/include/boot/boot.h

    ra11099f re731b0d  
    4141#define TEMP_STACK_SIZE  0x1000
    4242
    43 #define TASKMAP_MAX_RECORDS  32
    44 #define MEMMAP_MAX_RECORDS   32
     43#define TASKMAP_MAX_RECORDS        32
     44#define MEMMAP_MAX_RECORDS         32
     45#define BOOTINFO_TASK_NAME_BUFLEN  32
    4546
    4647#ifndef __ASM__
    4748
    48 #define BOOTINFO_TASK_NAME_BUFLEN 32
    49 
    5049#include <arch/types.h>
     50#include <config.h>
     51#include <genarch/ofw/ofw_tree.h>
    5152
    5253typedef struct {
     
    7374
    7475typedef struct {
    75         uintptr_t addr;
    76         unsigned int width;
    77         unsigned int height;
    78         unsigned int bpp;
    79         unsigned int scanline;
    80 } screen_t;
    81 
    82 typedef struct {
    83         uintptr_t addr;
    84         unsigned int size;
    85 } macio_t;
    86 
    87 typedef struct {
    8876        memmap_t memmap;
    8977        taskmap_t taskmap;
    90         screen_t screen;
    91         macio_t macio;
     78        ballocs_t ballocs;
     79        ofw_tree_node_t *ofw_root;
    9280} bootinfo_t;
    9381
  • kernel/arch/ppc32/src/mm/tlb.c

    ra11099f re731b0d  
    4545static unsigned int seed = 10;
    4646static unsigned int seed_real __attribute__ ((section("K_UNMAPPED_DATA_START"))) = 42;
    47 
    48 
    49 #define TLB_FLUSH \
    50         "tlbie %0\n" \
    51         "addi %0, %0, 0x1000\n"
    5247
    5348
     
    451446                "sync\n"
    452447               
    453                 TLB_FLUSH
    454                 TLB_FLUSH
    455                 TLB_FLUSH
    456                 TLB_FLUSH
    457                 TLB_FLUSH
    458                 TLB_FLUSH
    459                 TLB_FLUSH
    460                 TLB_FLUSH
    461                
    462                 TLB_FLUSH
    463                 TLB_FLUSH
    464                 TLB_FLUSH
    465                 TLB_FLUSH
    466                 TLB_FLUSH
    467                 TLB_FLUSH
    468                 TLB_FLUSH
    469                 TLB_FLUSH
    470                
    471                 TLB_FLUSH
    472                 TLB_FLUSH
    473                 TLB_FLUSH
    474                 TLB_FLUSH
    475                 TLB_FLUSH
    476                 TLB_FLUSH
    477                 TLB_FLUSH
    478                 TLB_FLUSH
    479                
    480                 TLB_FLUSH
    481                 TLB_FLUSH
    482                 TLB_FLUSH
    483                 TLB_FLUSH
    484                 TLB_FLUSH
    485                 TLB_FLUSH
    486                 TLB_FLUSH
    487                 TLB_FLUSH
    488                
    489                 TLB_FLUSH
    490                 TLB_FLUSH
    491                 TLB_FLUSH
    492                 TLB_FLUSH
    493                 TLB_FLUSH
    494                 TLB_FLUSH
    495                 TLB_FLUSH
    496                 TLB_FLUSH
    497                
    498                 TLB_FLUSH
    499                 TLB_FLUSH
    500                 TLB_FLUSH
    501                 TLB_FLUSH
    502                 TLB_FLUSH
    503                 TLB_FLUSH
    504                 TLB_FLUSH
    505                 TLB_FLUSH
    506                
    507                 TLB_FLUSH
    508                 TLB_FLUSH
    509                 TLB_FLUSH
    510                 TLB_FLUSH
    511                 TLB_FLUSH
    512                 TLB_FLUSH
    513                 TLB_FLUSH
    514                 TLB_FLUSH
    515                
    516                 TLB_FLUSH
    517                 TLB_FLUSH
    518                 TLB_FLUSH
    519                 TLB_FLUSH
    520                 TLB_FLUSH
    521                 TLB_FLUSH
    522                 TLB_FLUSH
    523                 TLB_FLUSH
     448                ".rept 64\n"
     449                "tlbie %0\n"
     450                "addi %0, %0, 0x1000\n"
     451                ".endr\n"
    524452               
    525453                "eieio\n"
  • kernel/arch/ppc32/src/ppc32.c

    ra11099f re731b0d  
    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                fb_init(&fb_prop);
     146        }
     147       
     148        /* Consider only a single device for now */
     149        return false;
     150}
     151
    81152void arch_post_mm_init(void)
    82153{
    83154        if (config.cpu_active == 1) {
    84 
    85155#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                 }
     156                ofw_tree_walk_by_device_type("display", display_register, NULL);
    116157#endif
    117158               
     
    132173}
    133174
    134 void arch_post_smp_init(void)
    135 {
    136         if (bootinfo.macio.addr) {
     175static bool macio_register(ofw_tree_node_t *node, void *arg)
     176{
     177        ofw_pci_reg_t *assigned_address = NULL;
     178       
     179        ofw_tree_property_t *prop = ofw_tree_getprop(node, "assigned-addresses");
     180        if ((prop) && (prop->value))
     181                assigned_address = ((ofw_pci_reg_t *) prop->value);
     182       
     183        if (assigned_address) {
    137184                /* Initialize PIC */
    138185                cir_t cir;
    139186                void *cir_arg;
    140                 pic_init(bootinfo.macio.addr, PAGE_SIZE, &cir, &cir_arg);
    141 
     187                pic_init(assigned_address[0].addr, PAGE_SIZE, &cir, &cir_arg);
     188               
    142189#ifdef CONFIG_MAC_KBD
    143                 uintptr_t pa = bootinfo.macio.addr + 0x16000;
     190                uintptr_t pa = assigned_address[0].addr + 0x16000;
    144191                uintptr_t aligned_addr = ALIGN_DOWN(pa, PAGE_SIZE);
    145192                size_t offset = pa - aligned_addr;
    146193                size_t size = 2 * PAGE_SIZE;
    147                        
     194               
    148195                cuda_t *cuda = (cuda_t *)
    149196                    (hw_map(aligned_addr, offset + size) + offset);
    150                        
     197               
    151198                /* Initialize I/O controller */
    152199                cuda_instance_t *cuda_instance =
     
    163210#endif
    164211        }
     212       
     213        /* Consider only a single device for now */
     214        return false;
     215}
     216
     217void arch_post_smp_init(void)
     218{
     219        ofw_tree_walk_by_device_type("mac-io", macio_register, NULL);
    165220}
    166221
Note: See TracChangeset for help on using the changeset viewer.