Changeset edebc15c in mainline


Ignore:
Timestamp:
2008-07-27T03:50:53Z (16 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4541ae4
Parents:
5e8ddf5
Message:

physical memory detection in MSIM (discontinous regions supported)
remove Sgi Indy (ARC) support — it was unmaintaned, untested for years and without uspace support

Files:
3 deleted
19 edited

Legend:

Unmodified
Added
Removed
  • HelenOS.config

    r5e8ddf5 redebc15c  
    4646@ "bgxemul" GXEmul big endian
    4747@ "lgxemul" GXEmul little endian
    48 @ "indy" Sgi Indy
    4948! [PLATFORM=mips32] MACHINE (choice)
    5049
  • Makefile

    r5e8ddf5 redebc15c  
    8383                IMAGE = ecoff
    8484        endif
    85        
    86         ifeq ($(MACHINE),indy)
    87                 UARCH = mips32eb
    88                 IMAGE = ecoff
    89         endif
    9085endif
    9186
  • contrib/conf/msim.conf

    r5e8ddf5 redebc15c  
    33#
    44
    5 add dcpu mips1
     5add dcpu cpu0
    66
    7 add rwm mainmem 0x00000000 8M
     7add rwm mainmem 0x00000000
     8mainmem generic 16M
    89mainmem load "/dev/zero"
    910
    10 add rom bootmem 0x1fc00000 2048k
     11add rom bootmem 0x1fc00000
     12bootmem generic 4096k
    1113bootmem load "image.boot"
    1214
  • kernel/arch/mips32/Makefile.inc

    r5e8ddf5 redebc15c  
    5757#
    5858
    59 ifeq ($(MACHINE),indy)
    60         # GCC 4.0.1 compiled for mipsEL has problems compiling in
    61         # BigEndian mode with the swl/swr/lwl/lwr instructions.
    62         # We have to compile it with mips-sgi-irix5 to get it right.
    63        
    64         BFD_NAME = elf32-bigmips
    65         BFD = ecoff-bigmips --impure
    66         TARGET = mips-sgi-irix5
    67         TOOLCHAIN_DIR = /usr/local/mips/bin
    68         KERNEL_LOAD_ADDRESS = 0x88002000
    69         GCC_CFLAGS += -EB -DBIG_ENDIAN -DARCH_HAS_FPU -march=r4600
    70         INIT_ADDRESS = 0
    71         INIT_SIZE = 0
    72 endif
    7359ifeq ($(MACHINE),lgxemul)
    7460        BFD_NAME = elf32-tradlittlemips
     
    124110        arch/$(ARCH)/src/fpu_context.c \
    125111        arch/$(ARCH)/src/ddi/ddi.c \
    126         arch/$(ARCH)/src/drivers/arc.c \
    127112        arch/$(ARCH)/src/drivers/msim.c \
    128113        arch/$(ARCH)/src/drivers/serial.c \
  • kernel/arch/mips32/include/drivers/msim.h

    r5e8ddf5 redebc15c  
    3636#define KERN_mips32_MSIM_H_
    3737
     38/** Address of devices. */
     39#define MSIM_VIDEORAM           0xB0000000
     40#define MSIM_KBD_ADDRESS        0xB0000000
     41#define MSIM_KBD_IRQ            2
     42
    3843#include <console/chardev.h>
    3944
  • kernel/arch/mips32/include/drivers/serial.h

    r5e8ddf5 redebc15c  
    3838#include <console/chardev.h>
    3939
     40#define SERIAL_ADDRESS    0xB8000000
     41
    4042#define SERIAL_MAX        4
    4143#define SERIAL_COM1       0x3f8
     
    4446#define SERIAL_COM2_IRQ   3
    4547
    46 #define P_WRITEB(where,what)     (*((volatile char *) (0xB8000000+where))=what)
    47 #define P_READB(where)           (*((volatile char *)(0xB8000000+where)))
     48#define P_WRITEB(where, what)     (*((volatile char *) (SERIAL_ADDRESS + where)) = what)
     49#define P_READB(where)            (*((volatile char *) (SERIAL_ADDRESS + where)))
    4850
    49 #define SERIAL_READ(x)           P_READB(x)
    50 #define SERIAL_WRITE(x,c)        P_WRITEB(x,c)
     51#define SERIAL_READ(x)            P_READB(x)
     52#define SERIAL_WRITE(x, c)        P_WRITEB(x, c)
     53
    5154/* Interrupt enable register */
    5255#define SERIAL_READ_IER(x)              (P_READB((x) + 1))
    53 #define SERIAL_WRITE_IER(x,c)           (P_WRITEB((x)+1,c))
     56#define SERIAL_WRITE_IER(x,c)           (P_WRITEB((x) + 1, c))
     57
    5458/* Interrupt identification register */
    5559#define SERIAL_READ_IIR(x)             (P_READB((x) + 2))
     60
    5661/* Line status register */
    5762#define SERIAL_READ_LSR(x)             (P_READB((x) + 5))
  • kernel/arch/mips32/include/mm/as.h

    r5e8ddf5 redebc15c  
    3939
    4040#define KERNEL_ADDRESS_SPACE_START_ARCH         (unsigned long) 0x80000000
    41 #define KERNEL_ADDRESS_SPACE_END_ARCH           (unsigned long) 0xffffffff
     41#define KERNEL_ADDRESS_SPACE_END_ARCH           (unsigned long) 0x9fffffff
    4242#define USER_ADDRESS_SPACE_START_ARCH           (unsigned long) 0x00000000
    4343#define USER_ADDRESS_SPACE_END_ARCH             (unsigned long) 0x7fffffff
  • kernel/arch/mips32/include/mm/tlb.h

    r5e8ddf5 redebc15c  
    3636#define KERN_mips32_TLB_H_
    3737
     38#include <arch/types.h>
     39#include <typedefs.h>
     40#include <arch/mm/asid.h>
    3841#include <arch/exception.h>
    3942
     
    4750#define TLB_KSTACK_WIRED_INDEX  0
    4851
    49 #define TLB_PAGE_MASK_16K       (0x3<<13)
     52#define TLB_PAGE_MASK_16K       (0x3 << 13)
    5053
    5154#define PAGE_UNCACHED                   2
     
    160163extern void tlb_refill(istate_t *istate);
    161164extern void tlb_modified(istate_t *istate);
     165extern void tlb_prepare_entry_lo(entry_lo_t *lo, bool g, bool v, bool d, bool cacheable, uintptr_t pfn);
     166extern void tlb_prepare_entry_hi(entry_hi_t *hi, asid_t asid, uintptr_t addr);
    162167
    163168#endif
  • kernel/arch/mips32/src/console.c

    r5e8ddf5 redebc15c  
    3535#include <console/console.h>
    3636#include <arch/console.h>
    37 #include <arch/drivers/arc.h>
    3837#include <arch/drivers/serial.h>
    3938#include <arch/drivers/msim.h>
     
    4140void console_init(devno_t devno)
    4241{
    43         if (!arc_console()) {
    44                 if (serial_init())
    45                         serial_console(devno);
    46                 else
    47                         msim_console(devno);
    48         }
     42        if (serial_init())
     43                serial_console(devno);
     44        else
     45                msim_console(devno);
    4946}
    5047
  • kernel/arch/mips32/src/drivers/msim.c

    r5e8ddf5 redebc15c  
    4040#include <console/console.h>
    4141#include <sysinfo/sysinfo.h>
    42 
    43 /** Address of devices. */
    44 #define MSIM_VIDEORAM           0xB0000000
    45 #define MSIM_KBD_ADDRESS        0xB0000000
    46 #define MSIM_KBD_IRQ            2
    4742
    4843static chardev_t console;
  • kernel/arch/mips32/src/interrupt.c

    r5e8ddf5 redebc15c  
    3939#include <arch/cp0.h>
    4040#include <time/clock.h>
    41 #include <arch/drivers/arc.h>
    4241#include <ipc/sysipc.h>
    4342#include <ddi/device.h>
  • kernel/arch/mips32/src/mips32.c

    r5e8ddf5 redebc15c  
    4949
    5050#include <arch/interrupt.h>
    51 #include <arch/drivers/arc.h>
    5251#include <console/chardev.h>
    5352#include <arch/barrier.h>
     
    9897        /* Initialize dispatch table */
    9998        exception_init();
    100         arc_init();
    10199
    102100        /* Copy the exception vectors to the right places */
     
    188186void arch_reboot(void)
    189187{
    190         if (!arc_reboot())
    191                 ___halt();
     188        ___halt();
    192189       
    193190        while (1)
  • kernel/arch/mips32/src/mm/as.c

    r5e8ddf5 redebc15c  
    4545void as_arch_init(void)
    4646{
    47         as_operations = &as_pt_operations;
     47        as_operations = &as_pt_operations;
    4848        asid_fifo_init();
    4949}
  • kernel/arch/mips32/src/mm/frame.c

    r5e8ddf5 redebc15c  
    3333 */
    3434
     35#include <macros.h>
    3536#include <arch/mm/frame.h>
     37#include <arch/mm/tlb.h>
    3638#include <mm/frame.h>
     39#include <mm/asid.h>
    3740#include <config.h>
    38 #include <arch/drivers/arc.h>
     41#include <arch/drivers/msim.h>
     42#include <arch/drivers/serial.h>
     43#include <print.h>
     44#include <debug.h>
     45
     46#define TLB_PAGE_MASK_1M        (0xff << 13)
     47
     48#define ZERO_FRAMES                     4096
     49#define ZERO_PAGE_WIDTH         20  /* 1M */
     50#define ZERO_PAGE_SIZE          (1 << ZERO_PAGE_WIDTH)
     51#define ZERO_PAGE_ASID          ASID_INVALID
     52#define ZERO_PAGE_TLBI          0
     53#define ZERO_PAGE_ADDR          0
     54#define ZERO_PAGE_OFFSET        (ZERO_PAGE_SIZE / sizeof(uint32_t) - 1)
     55#define ZERO_PAGE_VALUE         (*((volatile uint32_t *) ZERO_PAGE_ADDR + ZERO_PAGE_OFFSET))
     56
     57#define MAX_REGIONS                     32
     58
     59typedef struct {
     60        pfn_t start;
     61        pfn_t count;
     62} phys_region_t;
     63
     64static count_t phys_regions_count = 0;
     65static phys_region_t phys_regions[MAX_REGIONS];
     66
     67
     68/** Check whether frame is available
     69 *
     70 * Returns true if given frame is generally available for use.
     71 * Returns false if given frame is used for physical memory
     72 * mapped devices and cannot be used.
     73 *
     74 */
     75static bool frame_available(pfn_t frame)
     76{
     77        /* MSIM device (dprinter) */
     78        if (frame == (KA2PA(MSIM_VIDEORAM) >> ZERO_PAGE_WIDTH))
     79                return false;
     80       
     81        /* MSIM device (dkeyboard) */
     82        if (frame == (KA2PA(MSIM_KBD_ADDRESS) >> ZERO_PAGE_WIDTH))
     83                return false;
     84       
     85        /* Simics device (serial line) */
     86        if (frame == (KA2PA(SERIAL_ADDRESS) >> ZERO_PAGE_WIDTH))
     87                return false;
     88       
     89        return true;
     90}
     91
     92
     93/** Check whether frame is safe to write
     94 *
     95 * Returns true if given frame is safe for read/write test.
     96 * Returns false if given frame should not be touched.
     97 *
     98 */
     99static bool frame_safe(pfn_t frame) __attribute__((unused));
     100static bool frame_safe(pfn_t frame)
     101{
     102        /* Kernel structures */
     103        if ((frame << ZERO_PAGE_WIDTH) < KA2PA(config.base))
     104                return false;
     105       
     106        /* Kernel */
     107        if (overlaps(frame << ZERO_PAGE_WIDTH, ZERO_PAGE_SIZE,
     108            KA2PA(config.base), config.kernel_size))
     109                return false;
     110       
     111        /* Kernel stack */
     112        if (overlaps(frame << ZERO_PAGE_WIDTH, ZERO_PAGE_SIZE,
     113            KA2PA(config.stack_base), config.stack_size))
     114                return false;
     115       
     116        /* Init tasks */
     117        bool safe = true;
     118        count_t i;
     119        for (i = 0; i < init.cnt; i++)
     120                if (overlaps(frame << ZERO_PAGE_WIDTH, ZERO_PAGE_SIZE,
     121                    KA2PA(init.tasks[i].addr), init.tasks[i].size)) {
     122                        safe = false;
     123                        break;
     124                }
     125       
     126        return safe;
     127}
     128
     129static void frame_add_region(pfn_t start_frame, pfn_t end_frame)
     130{
     131        if (end_frame > start_frame) {
     132                /* Convert 1M frames to 16K frames */
     133                pfn_t first = ADDR2PFN(start_frame << ZERO_PAGE_WIDTH);
     134                pfn_t count = ADDR2PFN((end_frame - start_frame - 1) << ZERO_PAGE_WIDTH);
     135               
     136                /* Interrupt vector frame is blacklisted */
     137                pfn_t conf_frame;
     138                if (start_frame == 0)
     139                        conf_frame = 1;
     140                else
     141                        conf_frame = first;
     142               
     143                zone_create(first, count, conf_frame, 0);
     144               
     145                if (phys_regions_count < MAX_REGIONS) {
     146                        phys_regions[phys_regions_count].start = first;
     147                        phys_regions[phys_regions_count].count = count;
     148                        phys_regions_count++;
     149                }
     150        }
     151}
     152
    39153
    40154/** Create memory zones
    41155 *
    42  * If ARC is known, read information from ARC, otherwise
    43  * assume some defaults.
    44  * - blacklist first FRAME because there is an exception vector
     156 * Walk through available 1 MB chunks of physical
     157 * memory and create zones.
     158 *
    45159 */
    46160void frame_arch_init(void)
    47161{
    48         if (!arc_frame_init()) {
    49                 zone_create(0, ADDR2PFN(CONFIG_MEMORY_SIZE), 1, 0);
    50                 /*
    51                  * Blacklist interrupt vector
    52                  */
    53                 frame_mark_unavailable(0, 1);
     162        cp0_index_write(ZERO_PAGE_TLBI);
     163        tlbr();
     164       
     165        uint32_t orig_pagemask = cp0_pagemask_read();
     166        uint32_t orig_lo0 = cp0_entry_lo0_read();
     167        uint32_t orig_lo1 = cp0_entry_lo1_read();
     168        uint32_t orig_hi = cp0_entry_hi_read();
     169               
     170        pfn_t start_frame = 0;
     171        pfn_t frame;
     172        bool avail = true;
     173       
     174        /* Walk through all 1 MB frames */
     175        for (frame = 0; frame < ZERO_FRAMES; frame++) {
     176                if (!frame_available(frame))
     177                        avail = false;
     178                else {
     179                        if (frame_safe(frame)) {
     180                                entry_lo_t lo0;
     181                                entry_lo_t lo1;
     182                                entry_hi_t hi;
     183                                tlb_prepare_entry_lo(&lo0, false, true, true, false, frame << (ZERO_PAGE_WIDTH - 12));
     184                                tlb_prepare_entry_lo(&lo1, false, false, false, false, 0);
     185                                tlb_prepare_entry_hi(&hi, ZERO_PAGE_ASID, ZERO_PAGE_ADDR);
     186                               
     187                                cp0_index_write(ZERO_PAGE_TLBI);
     188                                cp0_pagemask_write(TLB_PAGE_MASK_1M);
     189                                cp0_entry_lo0_write(lo0.value);
     190                                cp0_entry_lo1_write(lo1.value);
     191                                cp0_entry_hi_write(hi.value);
     192                                tlbwi();
     193                               
     194                                ZERO_PAGE_VALUE = 0;
     195                                if (ZERO_PAGE_VALUE != 0)
     196                                        avail = false;
     197                                else {
     198                                        ZERO_PAGE_VALUE = 0xdeadbeef;
     199                                        if (ZERO_PAGE_VALUE != 0xdeadbeef)
     200                                                avail = false;
     201                                }
     202                        }
     203                }
     204               
     205                if (!avail) {
     206                        frame_add_region(start_frame, frame);
     207                        start_frame = frame + 1;
     208                        avail = true;
     209                }
    54210        }
     211       
     212        frame_add_region(start_frame, frame);
     213       
     214        /* Cleanup TLB */
     215        cp0_index_write(ZERO_PAGE_TLBI);
     216        cp0_pagemask_write(orig_pagemask);
     217        cp0_entry_lo0_write(orig_lo0);
     218        cp0_entry_lo1_write(orig_lo1);
     219        cp0_entry_hi_write(orig_hi);
     220        tlbwi();
     221       
     222        /* Blacklist interrupt vector frame */
     223        frame_mark_unavailable(0, 1);
     224}
     225
     226
     227void physmem_print(void)
     228{
     229        printf("Base       Size\n");
     230        printf("---------- ----------\n");
     231       
     232        count_t i;
     233        for (i = 0; i < phys_regions_count; i++) {
     234                printf("%#10x %10u\n",
     235                        PFN2ADDR(phys_regions[i].start), PFN2ADDR(phys_regions[i].count));
     236        }       
    55237}
    56238
  • kernel/arch/mips32/src/mm/tlb.c

    r5e8ddf5 redebc15c  
    5454static pte_t *find_mapping_and_check(uintptr_t badvaddr, int access, istate_t *istate, int *pfrc);
    5555
    56 static void prepare_entry_lo(entry_lo_t *lo, bool g, bool v, bool d, bool cacheable, uintptr_t pfn);
    57 static void prepare_entry_hi(entry_hi_t *hi, asid_t asid, uintptr_t addr);
    58 
    5956/** Initialize TLB
    6057 *
     
    7774                tlbwi();
    7875        }
    79 
    8076               
    8177        /*
     
    132128        pte->a = 1;
    133129
    134         prepare_entry_hi(&hi, asid, badvaddr);
    135         prepare_entry_lo(&lo, pte->g, pte->p, pte->d, pte->cacheable, pte->pfn);
     130        tlb_prepare_entry_hi(&hi, asid, badvaddr);
     131        tlb_prepare_entry_lo(&lo, pte->g, pte->p, pte->d, pte->cacheable, pte->pfn);
    136132
    137133        /*
     
    179175         */
    180176        hi.value = cp0_entry_hi_read();
    181         prepare_entry_hi(&hi, hi.asid, badvaddr);
     177        tlb_prepare_entry_hi(&hi, hi.asid, badvaddr);
    182178        cp0_entry_hi_write(hi.value);
    183179        tlbp();
     
    222218        pte->a = 1;
    223219
    224         prepare_entry_lo(&lo, pte->g, pte->p, pte->d, pte->cacheable, pte->pfn);
     220        tlb_prepare_entry_lo(&lo, pte->g, pte->p, pte->d, pte->cacheable, pte->pfn);
    225221
    226222        /*
     
    263259         */
    264260        hi.value = cp0_entry_hi_read();
    265         prepare_entry_hi(&hi, hi.asid, badvaddr);
     261        tlb_prepare_entry_hi(&hi, hi.asid, badvaddr);
    266262        cp0_entry_hi_write(hi.value);
    267263        tlbp();
     
    313309        pte->d = 1;
    314310
    315         prepare_entry_lo(&lo, pte->g, pte->p, pte->w, pte->cacheable, pte->pfn);
     311        tlb_prepare_entry_lo(&lo, pte->g, pte->p, pte->w, pte->cacheable, pte->pfn);
    316312
    317313        /*
     
    446442}
    447443
    448 void prepare_entry_lo(entry_lo_t *lo, bool g, bool v, bool d, bool cacheable, uintptr_t pfn)
     444void tlb_prepare_entry_lo(entry_lo_t *lo, bool g, bool v, bool d, bool cacheable, uintptr_t pfn)
    449445{
    450446        lo->value = 0;
     
    456452}
    457453
    458 void prepare_entry_hi(entry_hi_t *hi, asid_t asid, uintptr_t addr)
     454void tlb_prepare_entry_hi(entry_hi_t *hi, asid_t asid, uintptr_t addr)
    459455{
    460456        hi->value = ALIGN_DOWN(addr, PAGE_SIZE * 2);
     
    586582        for (i = 0; i < cnt + 1; i += 2) {
    587583                hi.value = 0;
    588                 prepare_entry_hi(&hi, asid, page + i * PAGE_SIZE);
     584                tlb_prepare_entry_hi(&hi, asid, page + i * PAGE_SIZE);
    589585                cp0_entry_hi_write(hi.value);
    590586
  • kernel/doc/arch/mips32

    r5e8ddf5 redebc15c  
    44mips32 is the second port of SPARTAN kernel originally written by Jakub Jermar.
    55It was first developed to run on MIPS R4000 32-bit simulator.
    6 Now it can run on real hardware as well.
    76It can be compiled and run either as little- or big-endian.
    87
    98HARDWARE REQUIREMENTS
    10         o SGI Indy R4600
    119        o emulated MIPS 4K CPU
    1210
  • kernel/generic/include/config.h

    r5e8ddf5 redebc15c  
    4141#define STACK_SIZE              PAGE_SIZE
    4242
    43 #define CONFIG_MEMORY_SIZE      (16 * 1024 * 1024)
    44 
    4543#define CONFIG_INIT_TASKS       32
    4644
  • kernel/generic/include/macros.h

    r5e8ddf5 redebc15c  
    4949#define max(a,b)        ((a) > (b) ? (a) : (b))
    5050
    51 /** Return true if the interlvals overlap.
     51/** Return true if the intervals overlap.
    5252 *
    5353 * @param s1 Start address of the first interval.
     
    7070#define SIZE2MB(size) (size >> 20)
    7171
     72#define KB2SIZE(size) (size << 10)
     73#define MB2SIZE(size) (size << 20)
     74
    7275#define STRING(arg) STRING_ARG(arg)
    7376#define STRING_ARG(arg) #arg
  • kernel/kernel.config

    r5e8ddf5 redebc15c  
    8282@ "lgxemul" GXEmul Little Endian
    8383@ "bgxemul" GXEmul Big Endian
    84 @ "indy" SGI Indy
    8584! [ARCH=mips32] MACHINE (choice)
    8685
Note: See TracChangeset for help on using the changeset viewer.