Changeset 8b863a62 in mainline for kernel/arch


Ignore:
Timestamp:
2014-04-16T17:14:06Z (12 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f857e8b
Parents:
dba3e2c (diff), 70b570c (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

Location:
kernel/arch
Files:
56 added
66 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/abs32le/include/arch/mm/frame.h

    rdba3e2c r8b863a62  
    3939#define FRAME_SIZE   (1 << FRAME_WIDTH)
    4040
     41#define FRAME_LOWPRIO  0
     42
    4143#include <typedefs.h>
    4244
  • kernel/arch/abs32le/include/arch/mm/page.h

    rdba3e2c r8b863a62  
    5757
    5858/* Page table sizes for each level. */
    59 #define PTL0_SIZE_ARCH  ONE_FRAME
    60 #define PTL1_SIZE_ARCH  0
    61 #define PTL2_SIZE_ARCH  0
    62 #define PTL3_SIZE_ARCH  ONE_FRAME
     59#define PTL0_FRAMES_ARCH  1
     60#define PTL1_FRAMES_ARCH  1
     61#define PTL2_FRAMES_ARCH  1
     62#define PTL3_FRAMES_ARCH  1
    6363
    6464/* Macros calculating indices for each level. */
  • kernel/arch/amd64/include/arch/mm/frame.h

    rdba3e2c r8b863a62  
    3939#define FRAME_SIZE   (1 << FRAME_WIDTH)
    4040
     41#define FRAME_LOWPRIO  0x1000
     42
    4143#ifndef __ASM__
    4244
  • kernel/arch/amd64/include/arch/mm/page.h

    rdba3e2c r8b863a62  
    6161
    6262/* Page table sizes for each level. */
    63 #define PTL0_SIZE_ARCH  ONE_FRAME
    64 #define PTL1_SIZE_ARCH  ONE_FRAME
    65 #define PTL2_SIZE_ARCH  ONE_FRAME
    66 #define PTL3_SIZE_ARCH  ONE_FRAME
     63#define PTL0_FRAMES_ARCH  1
     64#define PTL1_FRAMES_ARCH  1
     65#define PTL2_FRAMES_ARCH  1
     66#define PTL3_FRAMES_ARCH  1
    6767
    6868/* Macros calculating indices into page tables in each level. */
  • kernel/arch/amd64/src/ddi/ddi.c

    rdba3e2c r8b863a62  
    4242#include <errno.h>
    4343#include <arch/cpu.h>
     44#include <cpu.h>
    4445#include <arch.h>
    4546#include <align.h>
     
    5859int ddi_iospace_enable_arch(task_t *task, uintptr_t ioaddr, size_t size)
    5960{
    60         size_t bits = ioaddr + size;
    61         if (bits > IO_PORTS)
     61        size_t elements = ioaddr + size;
     62        if (elements > IO_PORTS)
    6263                return ENOENT;
    6364       
    64         if (task->arch.iomap.bits < bits) {
     65        if (task->arch.iomap.elements < elements) {
    6566                /*
    6667                 * The I/O permission bitmap is too small and needs to be grown.
    6768                 */
    6869               
    69                 uint8_t *newmap = (uint8_t *) malloc(BITS2BYTES(bits), FRAME_ATOMIC);
    70                 if (!newmap)
     70                void *store = malloc(bitmap_size(elements), FRAME_ATOMIC);
     71                if (!store)
    7172                        return ENOMEM;
    7273               
    7374                bitmap_t oldiomap;
    74                 bitmap_initialize(&oldiomap, task->arch.iomap.map,
     75                bitmap_initialize(&oldiomap, task->arch.iomap.elements,
    7576                    task->arch.iomap.bits);
    76                 bitmap_initialize(&task->arch.iomap, newmap, bits);
     77               
     78                bitmap_initialize(&task->arch.iomap, elements, store);
    7779               
    7880                /*
    7981                 * Mark the new range inaccessible.
    8082                 */
    81                 bitmap_set_range(&task->arch.iomap, oldiomap.bits,
    82                     bits - oldiomap.bits);
     83                bitmap_set_range(&task->arch.iomap, oldiomap.elements,
     84                    elements - oldiomap.elements);
    8385               
    8486                /*
     
    8890                if (oldiomap.bits) {
    8991                        bitmap_copy(&task->arch.iomap, &oldiomap,
    90                             oldiomap.bits);
    91                         free(oldiomap.map);
     92                            oldiomap.elements);
     93                       
     94                        free(oldiomap.bits);
    9295                }
    9396        }
     
    9699         * Enable the range and we are done.
    97100         */
    98         bitmap_clear_range(&task->arch.iomap, (size_t) ioaddr, (size_t) size);
     101        bitmap_clear_range(&task->arch.iomap, (size_t) ioaddr, size);
    99102       
    100103        /*
     
    118121        /* First, copy the I/O Permission Bitmap. */
    119122        irq_spinlock_lock(&TASK->lock, false);
     123       
    120124        size_t ver = TASK->arch.iomapver;
    121         size_t bits = TASK->arch.iomap.bits;
    122         if (bits) {
    123                 ASSERT(TASK->arch.iomap.map);
     125        size_t elements = TASK->arch.iomap.elements;
     126       
     127        if (elements > 0) {
     128                ASSERT(TASK->arch.iomap.bits);
    124129               
    125130                bitmap_t iomap;
    126                 bitmap_initialize(&iomap, CPU->arch.tss->iomap,
    127                     TSS_IOMAP_SIZE * 8);
    128                 bitmap_copy(&iomap, &TASK->arch.iomap, bits);
     131                bitmap_initialize(&iomap, TSS_IOMAP_SIZE * 8,
     132                    CPU->arch.tss->iomap);
     133                bitmap_copy(&iomap, &TASK->arch.iomap, elements);
    129134               
    130135                /*
     
    132137                 * I/O access.
    133138                 */
    134                 bitmap_set_range(&iomap, bits, ALIGN_UP(bits, 8) - bits);
     139                bitmap_set_range(&iomap, elements,
     140                    ALIGN_UP(elements, 8) - elements);
     141               
    135142                /*
    136143                 * It is safe to set the trailing eight bits because of the
    137144                 * extra convenience byte in TSS_IOMAP_SIZE.
    138145                 */
    139                 bitmap_set_range(&iomap, ALIGN_UP(bits, 8), 8);
     146                bitmap_set_range(&iomap, ALIGN_UP(elements, 8), 8);
    140147        }
     148       
    141149        irq_spinlock_unlock(&TASK->lock, false);
    142150       
    143151        /*
    144152         * Second, adjust TSS segment limit.
    145          * Take the extra ending byte will all bits set into account.
     153         * Take the extra ending byte with all bits set into account.
    146154         */
    147155        ptr_16_64_t cpugdtr;
     
    149157       
    150158        descriptor_t *gdt_p = (descriptor_t *) cpugdtr.base;
    151         gdt_tss_setlimit(&gdt_p[TSS_DES], TSS_BASIC_SIZE + BITS2BYTES(bits));
     159        size_t size = bitmap_size(elements);
     160        gdt_tss_setlimit(&gdt_p[TSS_DES], TSS_BASIC_SIZE + size);
    152161        gdtr_load(&cpugdtr);
    153162       
  • kernel/arch/amd64/src/interrupt.c

    rdba3e2c r8b863a62  
    3535#include <arch/interrupt.h>
    3636#include <print.h>
     37#include <log.h>
    3738#include <debug.h>
    3839#include <panic.h>
     
    6667void istate_decode(istate_t *istate)
    6768{
    68         printf("cs =%0#18" PRIx64 "\trip=%0#18" PRIx64 "\t"
     69        log_printf("cs =%0#18" PRIx64 "\trip=%0#18" PRIx64 "\t"
    6970            "rfl=%0#18" PRIx64 "\terr=%0#18" PRIx64 "\n",
    7071            istate->cs, istate->rip, istate->rflags, istate->error_word);
    7172       
    7273        if (istate_from_uspace(istate))
    73                 printf("ss =%0#18" PRIx64 "\n", istate->ss);
    74        
    75         printf("rax=%0#18" PRIx64 "\trbx=%0#18" PRIx64 "\t"
     74                log_printf("ss =%0#18" PRIx64 "\n", istate->ss);
     75       
     76        log_printf("rax=%0#18" PRIx64 "\trbx=%0#18" PRIx64 "\t"
    7677            "rcx=%0#18" PRIx64 "\trdx=%0#18" PRIx64 "\n",
    7778            istate->rax, istate->rbx, istate->rcx, istate->rdx);
    7879       
    79         printf("rsi=%0#18" PRIx64 "\trdi=%0#18" PRIx64 "\t"
     80        log_printf("rsi=%0#18" PRIx64 "\trdi=%0#18" PRIx64 "\t"
    8081            "rbp=%0#18" PRIx64 "\trsp=%0#18" PRIx64 "\n",
    8182            istate->rsi, istate->rdi, istate->rbp,
     
    8384            (uintptr_t) &istate->rsp);
    8485       
    85         printf("r8 =%0#18" PRIx64 "\tr9 =%0#18" PRIx64 "\t"
     86        log_printf("r8 =%0#18" PRIx64 "\tr9 =%0#18" PRIx64 "\t"
    8687            "r10=%0#18" PRIx64 "\tr11=%0#18" PRIx64 "\n",
    8788            istate->r8, istate->r9, istate->r10, istate->r11);
    8889       
    89         printf("r12=%0#18" PRIx64 "\tr13=%0#18" PRIx64 "\t"
     90        log_printf("r12=%0#18" PRIx64 "\tr13=%0#18" PRIx64 "\t"
    9091            "r14=%0#18" PRIx64 "\tr15=%0#18" PRIx64 "\n",
    9192            istate->r12, istate->r13, istate->r14, istate->r15);
     
    193194                 */
    194195#ifdef CONFIG_DEBUG
    195                 printf("cpu%u: spurious interrupt (inum=%u)\n", CPU->id, inum);
     196                log(LF_ARCH, LVL_DEBUG, "cpu%u: spurious interrupt (inum=%u)",
     197                    CPU->id, inum);
    196198#endif
    197199        }
  • kernel/arch/amd64/src/proc/task.c

    rdba3e2c r8b863a62  
    3434
    3535#include <proc/task.h>
     36#include <typedefs.h>
     37#include <adt/bitmap.h>
    3638#include <mm/slab.h>
    37 #include <typedefs.h>
    3839
    3940/** Perform amd64 specific task initialization.
     
    4546{
    4647        task->arch.iomapver = 0;
    47         bitmap_initialize(&task->arch.iomap, NULL, 0);
     48        bitmap_initialize(&task->arch.iomap, 0, NULL);
    4849}
    4950
     
    5556void task_destroy_arch(task_t *task)
    5657{
    57         if (task->arch.iomap.map)
    58                 free(task->arch.iomap.map);
     58        if (task->arch.iomap.bits != NULL)
     59                free(task->arch.iomap.bits);
    5960}
    6061
  • kernel/arch/arm32/Makefile.inc

    rdba3e2c r8b863a62  
    3636
    3737ifeq ($(CONFIG_FPU),y)
    38 # This is necessary to allow vmsr insn and fpexc manipulation
    39 # Use vfp32 to allow context save/restore of d16-d31 regs.
    40 AFLAGS += -mfloat-abi=hard -mfpu=vfp3
     38        # This is necessary to allow vmsr insn and fpexc manipulation
     39        # Use vfp32 to allow context save/restore of d16-d31 regs.
     40        AFLAGS += -mfloat-abi=hard -mfpu=vfp3
    4141endif
    4242
     
    8686
    8787ifeq ($(MACHINE),beaglebone)
    88         ARCH_SOURCES += arch/$(KARCH)/src/mach/beaglebone/beaglebone.c
     88        ARCH_SOURCES += arch/$(KARCH)/src/mach/beaglebone/beaglebone.c
     89endif
     90
     91ifeq ($(MACHINE),raspberrypi)
     92        ARCH_SOURCES += arch/$(KARCH)/src/mach/raspberrypi/raspberrypi.c
    8993endif
    9094
  • kernel/arch/arm32/_link.ld.in

    rdba3e2c r8b863a62  
    1313#elif defined MACHINE_beaglebone
    1414#define KERNEL_LOAD_ADDRESS 0x80a00000
     15#elif defined MACHINE_raspberrypi
     16#define KERNEL_LOAD_ADDRESS 0x80a08000
    1517#else
    1618#define KERNEL_LOAD_ADDRESS 0x80a00000
  • kernel/arch/arm32/include/arch/asm.h

    rdba3e2c r8b863a62  
    3838
    3939#include <typedefs.h>
     40#include <arch/cp15.h>
    4041#include <arch/stack.h>
    4142#include <config.h>
     
    5152 * chapter 2.3.8 p.2-22 (52 in the PDF)
    5253 *
    53  * @note Although mcr p15, 0, R0, c7, c0, 4 is defined in ARM Architecture
    54  * reference manual for armv4/5 CP15 implementation is mandatory only for
    55  * armv6+.
     54 * @note Although CP15WFI (mcr p15, 0, R0, c7, c0, 4) is defined in ARM
     55 * Architecture reference manual for armv4/5, CP15 implementation is mandatory
     56 * only for armv6+.
    5657 */
    5758NO_TRACE static inline void cpu_sleep(void)
     
    6061        asm volatile ( "wfe" );
    6162#elif defined(PROCESSOR_ARCH_armv6) | defined(PROCESSOR_arm926ej_s) | defined(PROCESSOR_arm920t)
    62         asm volatile ( "mcr p15, 0, R0, c7, c0, 4" );
     63        WFI_write(0);
    6364#endif
    6465}
  • kernel/arch/arm32/include/arch/cp15.h

    rdba3e2c r8b863a62  
    171171        CCSIDR_LINESIZE_MASK = 0x7,
    172172        CCSIDR_LINESIZE_SHIFT = 0,
     173#define CCSIDR_SETS(val) \
     174        (((val >> CCSIDR_NUMSETS_SHIFT) & CCSIDR_NUMSETS_MASK) + 1)
     175#define CCSIDR_WAYS(val) \
     176        (((val >> CCSIDR_ASSOC_SHIFT) & CCSIDR_ASSOC_MASK) + 1)
     177/* The register value is log(linesize_in_words) - 2 */
     178#define CCSIDR_LINESIZE_LOG(val) \
     179        (((val >> CCSIDR_LINESIZE_SHIFT) & CCSIDR_LINESIZE_MASK) + 2 + 2)
    173180};
    174181CONTROL_REG_GEN_READ(CCSIDR, c0, 1, c0, 0);
     
    187194        CLIDR_UNI_CACHE = 0x4,
    188195        CLIDR_CACHE_MASK = 0x7,
    189 #define CLIDR_CACHE(level, val)   ((val >> (level - 1) * 3) & CLIDR_CACHE_MASK)
     196/** levels counted from 0 */
     197#define CLIDR_CACHE(level, val)   ((val >> (level * 3)) & CLIDR_CACHE_MASK)
    190198};
    191199CONTROL_REG_GEN_READ(CLIDR, c0, 1, c0, 1);
     
    223231        SCTLR_FAST_IRQ_EN_FLAG       = 1 << 21, /* Disable impl. specific feat*/
    224232        SCTLR_UNALIGNED_EN_FLAG      = 1 << 22, /* Must be 1 on armv7 */
     233        SCTLR_EXTENDED_PT_EN_FLAG    = 1 << 23,
    225234        SCTLR_IRQ_VECTORS_EN_FLAG    = 1 << 24,
    226235        SCTLR_BIG_ENDIAN_EXC_FLAG    = 1 << 25,
     
    293302
    294303/* Memory protection and control registers */
     304enum {
     305        TTBR_ADDR_MASK = 0xffffff80,
     306        TTBR_NOS_FLAG = 1 << 5,
     307        TTBR_RGN_MASK = 0x3 << 3,
     308        TTBR_RGN_NO_CACHE = 0x0 << 3,
     309        TTBR_RGN_WBWA_CACHE = 0x1 << 3,
     310        TTBR_RGN_WT_CACHE = 0x2 << 3,
     311        TTBR_RGN_WB_CACHE = 0x3 << 3,
     312        TTBR_S_FLAG = 1 << 1,
     313        TTBR_C_FLAG = 1 << 0,
     314};
    295315CONTROL_REG_GEN_READ(TTBR0, c2, 0, c0, 0);
    296316CONTROL_REG_GEN_WRITE(TTBR0, c2, 0, c0, 0);
     
    363383
    364384CONTROL_REG_GEN_WRITE(DCIMVAC, c7, 0, c6, 1);
    365 CONTROL_REG_GEN_WRITE(DCIMSW, c7, 0, c6, 2);
     385CONTROL_REG_GEN_WRITE(DCISW, c7, 0, c6, 2);
    366386
    367387CONTROL_REG_GEN_WRITE(ATS1CPR, c7, 0, c8, 0);
     
    369389CONTROL_REG_GEN_WRITE(ATS1CUR, c7, 0, c8, 2);
    370390CONTROL_REG_GEN_WRITE(ATS1CUW, c7, 0, c8, 3);
    371 CONTROL_REG_GEN_WRITE(ATS1NSOPR, c7, 0, c8, 4);
    372 CONTROL_REG_GEN_WRITE(ATS1NSOPW, c7, 0, c8, 5);
    373 CONTROL_REG_GEN_WRITE(ATS1NSOUR, c7, 0, c8, 6);
    374 CONTROL_REG_GEN_WRITE(ATS1NSOUW, c7, 0, c8, 7);
     391CONTROL_REG_GEN_WRITE(ATS12NSOPR, c7, 0, c8, 4);
     392CONTROL_REG_GEN_WRITE(ATS12NSOPW, c7, 0, c8, 5);
     393CONTROL_REG_GEN_WRITE(ATS12NSOUR, c7, 0, c8, 6);
     394CONTROL_REG_GEN_WRITE(ATS12NSOUW, c7, 0, c8, 7);
    375395
    376396
  • kernel/arch/arm32/include/arch/mach/integratorcp/integratorcp.h

    rdba3e2c r8b863a62  
    4646#define ICP_IRQC_MAX_IRQ  8
    4747#define ICP_KBD_IRQ       3
    48 #define ICP_TIMER_IRQ    6
     48#define ICP_TIMER_IRQ     6
     49#define ICP_UART0_IRQ     1
    4950
    5051/** Timer frequency */
  • kernel/arch/arm32/include/arch/mm/frame.h

    rdba3e2c r8b863a62  
    4040#define FRAME_SIZE   (1 << FRAME_WIDTH)
    4141
     42#define FRAME_LOWPRIO  0
     43
    4244#ifndef __ASM__
    4345
     
    6062#define PHYSMEM_START_ADDR       0x80000000
    6163#define BOOT_PAGE_TABLE_ADDRESS  0x80008000
     64
     65#elif defined MACHINE_raspberrypi
     66
     67#define PHYSMEM_START_ADDR       0x00000000
     68#define BOOT_PAGE_TABLE_ADDRESS  0x00010000
    6269
    6370#else
  • kernel/arch/arm32/include/arch/mm/page.h

    rdba3e2c r8b863a62  
    4141#include <arch/exception.h>
    4242#include <arch/barrier.h>
     43#include <arch/cp15.h>
    4344#include <trace.h>
    4445
     
    7273
    7374/* Page table sizes for each level. */
    74 #define PTL0_SIZE_ARCH          FOUR_FRAMES
    75 #define PTL1_SIZE_ARCH          0
    76 #define PTL2_SIZE_ARCH          0
    77 #define PTL3_SIZE_ARCH          ONE_FRAME
     75#define PTL0_FRAMES_ARCH  4
     76#define PTL1_FRAMES_ARCH  1
     77#define PTL2_FRAMES_ARCH  1
     78#define PTL3_FRAMES_ARCH  1
    7879
    7980/* Macros calculating indices into page tables for each level. */
     
    9596/* Set PTE address accessors for each level. */
    9697#define SET_PTL0_ADDRESS_ARCH(ptl0) \
    97         (set_ptl0_addr((pte_t *) (ptl0)))
     98        set_ptl0_addr((pte_t *) (ptl0))
    9899#define SET_PTL1_ADDRESS_ARCH(ptl0, i, a) \
    99         (((pte_t *) (ptl0))[(i)].l0.coarse_table_addr = (a) >> 10)
     100        set_ptl1_addr((pte_t*) (ptl0), i, a)
    100101#define SET_PTL2_ADDRESS_ARCH(ptl1, i, a)
    101102#define SET_PTL3_ADDRESS_ARCH(ptl2, i, a)
    102103#define SET_FRAME_ADDRESS_ARCH(ptl3, i, a) \
    103         (((pte_t *) (ptl3))[(i)].l1.frame_base_addr = (a) >> 12)
     104        set_ptl3_addr((pte_t*) (ptl3), i, a)
    104105
    105106/* Get PTE flags accessors for each level. */
     
    129130        set_pt_level1_present((pte_t *) (ptl3), (size_t) (i))
    130131
     132
     133#define pt_coherence(page) pt_coherence_m(page, 1)
     134
    131135#if defined(PROCESSOR_ARCH_armv6) | defined(PROCESSOR_ARCH_armv7_a)
    132136#include "page_armv6.h"
     
    137141#endif
    138142
     143/** Sets the address of level 0 page table.
     144 *
     145 * @param pt Pointer to the page table to set.
     146 *
     147 * Page tables are always in cacheable memory.
     148 * Make sure the memory type is correct, and in sync with:
     149 * init_boot_pt (boot/arch/arm32/src/mm.c)
     150 * init_ptl0_section (boot/arch/arm32/src/mm.c)
     151 * set_pt_level1_flags (kernel/arch/arm32/include/arch/mm/page_armv6.h)
     152 */
     153NO_TRACE static inline void set_ptl0_addr(pte_t *pt)
     154{
     155        uint32_t val = (uint32_t)pt & TTBR_ADDR_MASK;
     156        val |= TTBR_RGN_WBWA_CACHE | TTBR_C_FLAG;
     157        TTBR0_write(val);
     158}
     159
     160NO_TRACE static inline void set_ptl1_addr(pte_t *pt, size_t i, uintptr_t address)
     161{
     162        pt[i].l0.coarse_table_addr = address >> 10;
     163        pt_coherence(&pt[i].l0);
     164}
     165
     166NO_TRACE static inline void set_ptl3_addr(pte_t *pt, size_t i, uintptr_t address)
     167{
     168        pt[i].l1.frame_base_addr = address >> 12;
     169        pt_coherence(&pt[i].l1);
     170}
     171
    139172#endif
    140173
  • kernel/arch/arm32/include/arch/mm/page_armv4.h

    rdba3e2c r8b863a62  
    4848        (((pte_t *) (pte))->l0.descriptor_type != 0)
    4949#define PTE_GET_FRAME_ARCH(pte) \
    50         (((pte_t *) (pte))->l1.frame_base_addr << FRAME_WIDTH)
     50        (((uintptr_t) ((pte_t *) (pte))->l1.frame_base_addr) << FRAME_WIDTH)
    5151#define PTE_WRITABLE_ARCH(pte) \
    5252        (((pte_t *) (pte))->l1.access_permission_0 == PTE_AP_USER_RW_KERNEL_RW)
     
    120120#define PTE_DESCRIPTOR_SMALL_PAGE       2
    121121
    122 
    123 /** Sets the address of level 0 page table.
    124  *
    125  * @param pt Pointer to the page table to set.
    126  *
    127  */
    128 NO_TRACE static inline void set_ptl0_addr(pte_t *pt)
    129 {
    130         asm volatile (
    131                 "mcr p15, 0, %[pt], c2, c0, 0\n"
    132                 :: [pt] "r" (pt)
    133         );
    134 }
    135 
     122#define pt_coherence_m(pt, count) \
     123do { \
     124        for (unsigned i = 0; i < count; ++i) \
     125                DCCMVAU_write((uintptr_t)(pt + i)); \
     126        read_barrier(); \
     127} while (0)
    136128
    137129/** Returns level 0 page table entry flags.
     
    223215       
    224216        /* default access permission */
    225         p->access_permission_0 = p->access_permission_1 = 
     217        p->access_permission_0 = p->access_permission_1 =
    226218            p->access_permission_2 = p->access_permission_3 =
    227219            PTE_AP_USER_NO_KERNEL_RW;
     
    229221        if (flags & PAGE_USER)  {
    230222                if (flags & PAGE_READ) {
    231                         p->access_permission_0 = p->access_permission_1 = 
    232                             p->access_permission_2 = p->access_permission_3 = 
     223                        p->access_permission_0 = p->access_permission_1 =
     224                            p->access_permission_2 = p->access_permission_3 =
    233225                            PTE_AP_USER_RO_KERNEL_RW;
    234226                }
    235227                if (flags & PAGE_WRITE) {
    236                         p->access_permission_0 = p->access_permission_1 = 
    237                             p->access_permission_2 = p->access_permission_3 = 
    238                             PTE_AP_USER_RW_KERNEL_RW; 
     228                        p->access_permission_0 = p->access_permission_1 =
     229                            p->access_permission_2 = p->access_permission_3 =
     230                            PTE_AP_USER_RW_KERNEL_RW;
    239231                }
    240232        }
  • kernel/arch/arm32/include/arch/mm/page_armv6.h

    rdba3e2c r8b863a62  
    4141#endif
    4242
     43
    4344/* Macros for querying the last-level PTE entries. */
    4445#define PTE_VALID_ARCH(pte) \
     
    4748        (((pte_t *) (pte))->l0.descriptor_type != 0)
    4849#define PTE_GET_FRAME_ARCH(pte) \
    49         (((pte_t *) (pte))->l1.frame_base_addr << FRAME_WIDTH)
     50        (((uintptr_t) ((pte_t *) (pte))->l1.frame_base_addr) << FRAME_WIDTH)
    5051#define PTE_WRITABLE_ARCH(pte) \
    5152        (((pte_t *) (pte))->l1.access_permission_1 != PTE_AP1_RO)
     
    125126#define PTE_DESCRIPTOR_SMALL_PAGE_NX    3
    126127
    127 /** Sets the address of level 0 page table.
    128  *
    129  * @param pt Pointer to the page table to set.
    130  *
    131  */
    132 NO_TRACE static inline void set_ptl0_addr(pte_t *pt)
    133 {
    134         asm volatile (
    135                 "mcr p15, 0, %[pt], c2, c0, 0\n"
    136                 :: [pt] "r" (pt)
    137         );
    138 }
     128
     129/**
     130 * For an ARMv7 implementation that does not include the Large Physical Address Extension,
     131 * and in implementations of architecture versions before ARMv7, if the translation tables
     132 * are held in Write-Back Cacheable memory, the caches must be cleaned to the point of
     133 * unification after writing to the translation tables and before the DSB instruction. This
     134 * ensures that the updated translation table are visible to a hardware translation table walk.
     135 *
     136 * Therefore, an example instruction sequence for writing a translation table entry,
     137 * covering changes to the instruction
     138 * or data mappings in a uniprocessor system is:
     139 * STR rx, [Translation table entry]
     140 * ; write new entry to the translation table
     141 * Clean cache line [Translation table entry] : This operation is not required with the
     142 * ; Multiprocessing Extensions.
     143 * DSB
     144 * ; ensures visibility of the data cleaned from the D Cache
     145 * Invalidate TLB entry by MVA (and ASID if non-global) [page address]
     146 * Invalidate BTC
     147 * DSB
     148 * ; ensure completion of the Invalidate TLB operation
     149 * ISB
     150 * ; ensure table changes visible to instruction fetch
     151 *
     152 * ARM Architecture reference chp. B3.10.1 p. B3-1375
     153 * @note: see TTRB0/1 for pt memory type
     154 */
     155#define pt_coherence_m(pt, count) \
     156do { \
     157        for (unsigned i = 0; i < count; ++i) \
     158                DCCMVAU_write((uintptr_t)(pt + i)); \
     159        read_barrier(); \
     160} while (0)
    139161
    140162
     
    206228                p->ns = 0;
    207229        }
     230        pt_coherence(p);
    208231}
    209232
     
    232255                        p->descriptor_type = PTE_DESCRIPTOR_SMALL_PAGE_NX;
    233256        }
    234        
    235         /* tex=0 buf=1 and cache=1 => normal memory
    236          * tex=0 buf=1 and cache=0 => shareable device mmio
    237          */
    238         p->cacheable = (flags & PAGE_CACHEABLE);
    239         p->bufferable = 1;
    240         p->tex = 0;
    241        
     257
     258        if (flags & PAGE_CACHEABLE) {
     259                /*
     260                 * Write-through, no write-allocate memory, see ch. B3.8.2
     261                 * (p. B3-1358) of ARM Architecture reference manual.
     262                 * Make sure the memory type is correct, and in sync with:
     263                 * init_boot_pt (boot/arch/arm32/src/mm.c)
     264                 * init_ptl0_section (boot/arch/arm32/src/mm.c)
     265                 * set_ptl0_addr (kernel/arch/arm32/include/arch/mm/page.h)
     266                 */
     267                p->tex = 5;
     268                p->cacheable = 0;
     269                p->bufferable = 1;
     270        } else {
     271                /*
     272                 * Shareable device memory, see ch. B3.8.2 (p. B3-1358) of
     273                 * ARM Architecture reference manual.
     274                 */
     275                p->tex = 0;
     276                p->cacheable = 0;
     277                p->bufferable = 1;
     278        }
     279       
     280#if defined(PROCESSOR_ARCH_armv6)
     281        /* FIXME: this disables caches */
     282        p->shareable = 1;
     283#else
    242284        /* Shareable is ignored for devices (non-cacheable),
    243          * turn it on for normal memory. */
    244         p->shareable = 1;
     285         * turn it off for normal memory. */
     286        p->shareable = 0;
     287#endif
    245288       
    246289        p->non_global = !(flags & PAGE_GLOBAL);
     
    256299                        p->access_permission_1 = PTE_AP1_RO;
    257300        }
     301        pt_coherence(p);
    258302}
    259303
     
    264308        p->should_be_zero_0 = 0;
    265309        p->should_be_zero_1 = 0;
    266         write_barrier();
    267310        p->descriptor_type = PTE_DESCRIPTOR_COARSE_TABLE;
     311        pt_coherence(p);
    268312}
    269313
     
    273317
    274318        p->descriptor_type = PTE_DESCRIPTOR_SMALL_PAGE;
     319        pt_coherence(p);
    275320}
    276321
  • kernel/arch/arm32/src/cpu/cpu.c

    rdba3e2c r8b863a62  
    157157#endif
    158158#ifdef PROCESSOR_ARCH_armv7_a
    159          /* ICache coherency is elaborate on in barrier.h.
     159         /* ICache coherency is elaborated on in barrier.h.
    160160          * VIPT and PIPT caches need maintenance only on code modify,
    161161          * so it should be safe for general use.
     
    166166                control_reg |=
    167167                    SCTLR_INST_CACHE_EN_FLAG | SCTLR_BRANCH_PREDICT_EN_FLAG;
     168        } else {
     169                control_reg &=
     170                    ~(SCTLR_INST_CACHE_EN_FLAG | SCTLR_BRANCH_PREDICT_EN_FLAG);
    168171        }
    169172#endif
     
    204207#ifdef PROCESSOR_ARCH_armv7_a
    205208        CSSELR_write((level & CCSELR_LEVEL_MASK) << CCSELR_LEVEL_SHIFT);
    206         const unsigned ls_log = 2 +
    207             ((CCSIDR_read() >> CCSIDR_LINESIZE_SHIFT) & CCSIDR_LINESIZE_MASK);
    208         return ls_log + 2; //return log2(bytes)
     209        const uint32_t ccsidr = CCSIDR_read();
     210        return CCSIDR_LINESIZE_LOG(ccsidr);
    209211#endif
    210212        return 0;
     
    217219#ifdef PROCESSOR_ARCH_armv7_a
    218220        CSSELR_write((level & CCSELR_LEVEL_MASK) << CCSELR_LEVEL_SHIFT);
    219         const unsigned ways = 1 +
    220             ((CCSIDR_read() >> CCSIDR_ASSOC_SHIFT) & CCSIDR_ASSOC_MASK);
    221         return ways;
     221        const uint32_t ccsidr = CCSIDR_read();
     222        return CCSIDR_WAYS(ccsidr);
    222223#endif
    223224        return 0;
     
    229230#ifdef PROCESSOR_ARCH_armv7_a
    230231        CSSELR_write((level & CCSELR_LEVEL_MASK) << CCSELR_LEVEL_SHIFT);
    231         const unsigned sets = 1 +
    232             ((CCSIDR_read() >> CCSIDR_NUMSETS_SHIFT) & CCSIDR_NUMSETS_MASK);
    233         return sets;
     232        const uint32_t ccsidr = CCSIDR_read();
     233        return CCSIDR_SETS(ccsidr);
    234234#endif
    235235        return 0;
     
    241241#ifdef PROCESSOR_ARCH_armv7_a
    242242        const uint32_t val = CLIDR_read();
    243         for (unsigned i = 1; i <= 7; ++i) {
     243        for (unsigned i = 0; i < 8; ++i) {
    244244                const unsigned ctype = CLIDR_CACHE(i, val);
    245245                switch (ctype) {
     
    280280                const unsigned ways = dcache_ways(i);
    281281                const unsigned sets = dcache_sets(i);
    282                 const unsigned way_shift =  31 - log2(ways);
     282                const unsigned way_shift = 32 - log2(ways);
    283283                const unsigned set_shift = dcache_linesize_log(i);
    284284                dcache_clean_manual(i, false, ways, sets, way_shift, set_shift);
     
    293293                const unsigned ways = dcache_ways(i);
    294294                const unsigned sets = dcache_sets(i);
    295                 const unsigned way_shift =  31 - log2(ways);
     295                const unsigned way_shift = 32 - log2(ways);
    296296                const unsigned set_shift = dcache_linesize_log(i);
    297297                dcache_clean_manual(i, true, ways, sets, way_shift, set_shift);
  • kernel/arch/arm32/src/mach/beagleboardxm/beagleboardxm.c

    rdba3e2c r8b863a62  
    6060
    6161static struct beagleboard {
    62         amdm37x_irc_regs_t *irc_addr;
     62        omap_irc_regs_t *irc_addr;
    6363        omap_uart_t uart;
    6464        amdm37x_gpt_t timer;
     
    8585static void bb_timer_irq_handler(irq_t *irq)
    8686{
     87        amdm37x_gpt_irq_ack(&beagleboard.timer);
     88
    8789        /*
    8890         * We are holding a lock which prevents preemption.
    8991         * Release the lock, call clock() and reacquire the lock again.
    9092         */
    91         amdm37x_gpt_irq_ack(&beagleboard.timer);
    9293        spinlock_unlock(&irq->lock);
    9394        clock();
     
    102103            PAGE_NOT_CACHEABLE);
    103104        ASSERT(beagleboard.irc_addr);
    104         amdm37x_irc_init(beagleboard.irc_addr);
     105        omap_irc_init(beagleboard.irc_addr);
    105106
    106107        /* Initialize timer. Use timer1, because it is in WKUP power domain
     
    122123
    123124        /* Enable timer interrupt */
    124         amdm37x_irc_enable(beagleboard.irc_addr, AMDM37x_GPT1_IRQ);
     125        omap_irc_enable(beagleboard.irc_addr, AMDM37x_GPT1_IRQ);
    125126
    126127        /* Start timer here */
     
    146147static void bbxm_irq_exception(unsigned int exc_no, istate_t *istate)
    147148{
    148         const unsigned inum = amdm37x_irc_inum_get(beagleboard.irc_addr);
    149         amdm37x_irc_irq_ack(beagleboard.irc_addr);
     149        const unsigned inum = omap_irc_inum_get(beagleboard.irc_addr);
    150150
    151151        irq_t *irq = irq_dispatch_and_lock(inum);
     
    159159                    CPU->id, inum);
    160160        }
     161        /** amdm37x manual ch. 12.5.2 (p. 2428) places irc ack at the end
     162         * of ISR. DO this to avoid strange behavior. */
     163        omap_irc_irq_ack(beagleboard.irc_addr);
    161164}
    162165
     
    185188                indev_t *srln = srln_wire(srln_instance, sink);
    186189                omap_uart_input_wire(&beagleboard.uart, srln);
    187                 amdm37x_irc_enable(beagleboard.irc_addr, AMDM37x_UART3_IRQ);
     190                omap_irc_enable(beagleboard.irc_addr, AMDM37x_UART3_IRQ);
    188191        }
    189192#endif
  • kernel/arch/arm32/src/mach/beaglebone/beaglebone.c

    rdba3e2c r8b863a62  
    6363
    6464static struct beaglebone {
    65         am335x_irc_regs_t *irc_addr;
     65        omap_irc_regs_t *irc_addr;
    6666        am335x_cm_per_regs_t *cm_per_addr;
    6767        am335x_cm_dpll_regs_t *cm_dpll_addr;
     
    104104
    105105        /* Initialize the interrupt controller */
    106         am335x_irc_init(bbone.irc_addr);
     106        omap_irc_init(bbone.irc_addr);
    107107}
    108108
     
    153153        }
    154154        /* Enable the interrupt */
    155         am335x_irc_enable(bbone.irc_addr, AM335x_DMTIMER2_IRQ);
     155        omap_irc_enable(bbone.irc_addr, AM335x_DMTIMER2_IRQ);
    156156        /* Start the timer */
    157157        am335x_timer_start(&bbone.timer);
     
    176176static void bbone_irq_exception(unsigned int exc_no, istate_t *istate)
    177177{
    178         const unsigned inum = am335x_irc_inum_get(bbone.irc_addr);
    179         am335x_irc_irq_ack(bbone.irc_addr);
     178        const unsigned inum = omap_irc_inum_get(bbone.irc_addr);
    180179
    181180        irq_t *irq = irq_dispatch_and_lock(inum);
     
    187186                printf("Spurious interrupt\n");
    188187        }
     188
     189        omap_irc_irq_ack(bbone.irc_addr);
    189190}
    190191
     
    213214                indev_t *srln = srln_wire(srln_instance, sink);
    214215                omap_uart_input_wire(&bbone.uart, srln);
    215                 am335x_irc_enable(bbone.irc_addr, AM335x_UART0_IRQ);
     216                omap_irc_enable(bbone.irc_addr, AM335x_UART0_IRQ);
    216217        }
    217218#endif
  • kernel/arch/arm32/src/mach/gta02/gta02.c

    rdba3e2c r8b863a62  
    4141#include <genarch/fb/fb.h>
    4242#include <abi/fb/visuals.h>
    43 #include <genarch/drivers/s3c24xx_uart/s3c24xx_uart.h>
    44 #include <genarch/drivers/s3c24xx_irqc/s3c24xx_irqc.h>
    45 #include <genarch/drivers/s3c24xx_timer/s3c24xx_timer.h>
     43#include <genarch/drivers/s3c24xx/uart.h>
     44#include <genarch/drivers/s3c24xx/irqc.h>
     45#include <genarch/drivers/s3c24xx/timer.h>
    4646#include <genarch/srln/srln.h>
    4747#include <sysinfo/sysinfo.h>
     
    4949#include <ddi/ddi.h>
    5050#include <ddi/device.h>
     51#include <log.h>
    5152
    5253#define GTA02_MEMORY_START      0x30000000      /* physical */
     
    149150        } else {
    150151                /* Spurious interrupt.*/
    151                 printf("cpu%d: spurious interrupt (inum=%d)\n",
     152                log(LF_ARCH, LVL_DEBUG, "cpu%d: spurious interrupt (inum=%d)",
    152153                    CPU->id, inum);
    153154        }
  • kernel/arch/arm32/src/mach/integratorcp/integratorcp.c

    rdba3e2c r8b863a62  
    3737#include <ipc/irq.h>
    3838#include <console/chardev.h>
     39#include <genarch/drivers/pl011/pl011.h>
    3940#include <genarch/drivers/pl050/pl050.h>
    40 #include <genarch/drivers/arm926_uart/arm926_uart.h>
    4141#include <genarch/kbrd/kbrd.h>
    4242#include <genarch/srln/srln.h>
    4343#include <console/console.h>
    4444#include <sysinfo/sysinfo.h>
    45 #include <print.h>
    4645#include <ddi/device.h>
    4746#include <mm/page.h>
     
    5352#include <abi/fb/visuals.h>
    5453#include <ddi/ddi.h>
    55 #include <print.h>
     54#include <log.h>
     55
    5656
    5757
     
    6161        icp_hw_map_t hw_map;
    6262        irq_t timer_irq;
    63         arm926_uart_t uart;
     63        pl011_uart_t uart;
    6464} icp;
    6565
     
    275275                        } else {
    276276                                /* Spurious interrupt.*/
    277                                 printf("cpu%d: spurious interrupt (inum=%d)\n",
     277                                log(LF_ARCH, LVL_DEBUG,
     278                                    "cpu%d: spurious interrupt (inum=%d)",
    278279                                    CPU->id, i);
    279280                        }
     
    314315                stdout_wire(fbdev);
    315316#endif
    316 #ifdef CONFIG_ARM926_UART
    317         if (arm926_uart_init(&icp.uart, ARM926_UART0_IRQ,
    318             ARM926_UART0_BASE_ADDRESS, sizeof(arm926_uart_regs_t)))
     317#ifdef CONFIG_PL011_UART
     318        if (pl011_uart_init(&icp.uart, ICP_UART0_IRQ, ICP_UART))
    319319                stdout_wire(&icp.uart.outdev);
    320320#endif
     
    350350            ICP_KBD);
    351351
    352 #ifdef CONFIG_ARM926_UART
     352#ifdef CONFIG_PL011_UART
    353353        srln_instance_t *srln_instance = srln_init();
    354354        if (srln_instance) {
    355355                indev_t *sink = stdin_wire();
    356356                indev_t *srln = srln_wire(srln_instance, sink);
    357                 arm926_uart_input_wire(&icp.uart, srln);
    358                 icp_irqc_unmask(ARM926_UART0_IRQ);
     357                pl011_uart_input_wire(&icp.uart, srln);
     358                icp_irqc_unmask(ICP_UART0_IRQ);
    359359        }
    360360#endif
  • kernel/arch/arm32/src/machine_func.c

    rdba3e2c r8b863a62  
    4343#include <arch/mach/beagleboardxm/beagleboardxm.h>
    4444#include <arch/mach/beaglebone/beaglebone.h>
     45#include <arch/mach/raspberrypi/raspberrypi.h>
    4546
    4647/** Pointer to machine_ops structure being used. */
     
    5859#elif defined(MACHINE_beaglebone)
    5960        machine_ops = &bbone_machine_ops;
     61#elif defined(MACHINE_raspberrypi)
     62        machine_ops = &raspberrypi_machine_ops;
    6063#else
    6164#error Machine type not defined.
  • kernel/arch/arm32/src/mm/frame.c

    rdba3e2c r8b863a62  
    8888void boot_page_table_free(void)
    8989{
    90         unsigned int i;
    91         for (i = 0; i < BOOT_PAGE_TABLE_SIZE_IN_FRAMES; i++)
    92                 frame_free(i * FRAME_SIZE + BOOT_PAGE_TABLE_ADDRESS);
     90        frame_free(BOOT_PAGE_TABLE_ADDRESS,
     91            BOOT_PAGE_TABLE_SIZE_IN_FRAMES);
    9392}
    9493
  • kernel/arch/arm32/src/mm/page.c

    rdba3e2c r8b863a62  
    6969#ifdef HIGH_EXCEPTION_VECTORS
    7070        /* Create mapping for exception table at high offset */
    71         uintptr_t ev_frame = (uintptr_t) frame_alloc(ONE_FRAME, FRAME_NONE);
     71        uintptr_t ev_frame = frame_alloc(1, FRAME_NONE, 0);
    7272        page_mapping_insert(AS_KERNEL, EXC_BASE_ADDRESS, ev_frame, flags);
    7373#else
  • kernel/arch/arm32/src/mm/tlb.c

    rdba3e2c r8b863a62  
    3737#include <arch/mm/asid.h>
    3838#include <arch/asm.h>
     39#include <arch/cp15.h>
    3940#include <typedefs.h>
    4041#include <arch/mm/page.h>
     42#include <arch/cache.h>
    4143
    4244/** Invalidate all entries in TLB.
     
    4648void tlb_invalidate_all(void)
    4749{
    48         asm volatile (
    49                 "eor r1, r1\n"
    50                 "mcr p15, 0, r1, c8, c7, 0\n"
    51                 ::: "r1"
    52         );
     50        TLBIALL_write(0);
     51        /*
     52         * "A TLB maintenance operation is only guaranteed to be complete after
     53         * the execution of a DSB instruction."
     54         * "An ISB instruction, or a return from an exception, causes the
     55         * effect of all completed TLB maintenance operations that appear in
     56         * program order before the ISB or return from exception to be visible
     57         * to all subsequent instructions, including the instruction fetches
     58         * for those instructions."
     59         * ARM Architecture reference Manual ch. B3.10.1 p. B3-1374 B3-1375
     60         */
     61        read_barrier();
     62        inst_barrier();
    5363}
    5464
     
    6070{
    6171        tlb_invalidate_all();
     72        // TODO: why not TLBIASID_write(asid) ?
    6273}
    6374
     
    6576 *
    6677 * @param page Virtual adress of the page
    67  */ 
     78 */
    6879static inline void invalidate_page(uintptr_t page)
    6980{
    70         asm volatile (
    71                 "mcr p15, 0, %[page], c8, c7, 1\n"
    72                 :: [page] "r" (page)
    73         );
     81        //TODO: What about TLBIMVAA?
     82        TLBIMVA_write(page);
     83        /*
     84         * "A TLB maintenance operation is only guaranteed to be complete after
     85         * the execution of a DSB instruction."
     86         * "An ISB instruction, or a return from an exception, causes the
     87         * effect of all completed TLB maintenance operations that appear in
     88         * program order before the ISB or return from exception to be visible
     89         * to all subsequent instructions, including the instruction fetches
     90         * for those instructions."
     91         * ARM Architecture reference Manual ch. B3.10.1 p. B3-1374 B3-1375
     92         */
     93        read_barrier();
     94        inst_barrier();
    7495}
    7596
     
    83104void tlb_invalidate_pages(asid_t asid __attribute__((unused)), uintptr_t page, size_t cnt)
    84105{
    85         unsigned int i;
    86 
    87         for (i = 0; i < cnt; i++)
     106        for (unsigned i = 0; i < cnt; i++)
    88107                invalidate_page(page + i * PAGE_SIZE);
    89108}
  • kernel/arch/arm32/src/ras.c

    rdba3e2c r8b863a62  
    5151void ras_init(void)
    5252{
    53         uintptr_t frame;
    54 
    55         frame = (uintptr_t) frame_alloc(ONE_FRAME,
    56             FRAME_ATOMIC | FRAME_HIGHMEM);
     53        uintptr_t frame =
     54            frame_alloc(1, FRAME_ATOMIC | FRAME_HIGHMEM, 0);
    5755        if (!frame)
    58                 frame = (uintptr_t) frame_alloc(ONE_FRAME, FRAME_LOWMEM);
     56                frame = frame_alloc(1, FRAME_LOWMEM, 0);
     57       
    5958        ras_page = (uintptr_t *) km_map(frame,
    6059            PAGE_SIZE, PAGE_READ | PAGE_WRITE | PAGE_USER | PAGE_CACHEABLE);
    61 
     60       
    6261        memsetb(ras_page, PAGE_SIZE, 0);
    6362        ras_page[RAS_START] = 0;
  • kernel/arch/ia32/include/arch/mm/frame.h

    rdba3e2c r8b863a62  
    3939#define FRAME_SIZE   (1 << FRAME_WIDTH)
    4040
     41#define FRAME_LOWPRIO  0x1000
     42
    4143#ifndef __ASM__
    4244
  • kernel/arch/ia32/include/arch/mm/page.h

    rdba3e2c r8b863a62  
    6666
    6767/* Page table sizes for each level. */
    68 #define PTL0_SIZE_ARCH  ONE_FRAME
    69 #define PTL1_SIZE_ARCH  0
    70 #define PTL2_SIZE_ARCH  0
    71 #define PTL3_SIZE_ARCH  ONE_FRAME
     68#define PTL0_FRAMES_ARCH  1
     69#define PTL1_FRAMES_ARCH  1
     70#define PTL2_FRAMES_ARCH  1
     71#define PTL3_FRAMES_ARCH  1
    7272
    7373/* Macros calculating indices for each level. */
  • kernel/arch/ia32/src/ddi/ddi.c

    rdba3e2c r8b863a62  
    5959int ddi_iospace_enable_arch(task_t *task, uintptr_t ioaddr, size_t size)
    6060{
    61         size_t bits = ioaddr + size;
    62         if (bits > IO_PORTS)
     61        size_t elements = ioaddr + size;
     62        if (elements > IO_PORTS)
    6363                return ENOENT;
    6464       
    65         if (task->arch.iomap.bits < bits) {
     65        if (task->arch.iomap.elements < elements) {
    6666                /*
    6767                 * The I/O permission bitmap is too small and needs to be grown.
    6868                 */
    6969               
    70                 uint8_t *newmap = (uint8_t *) malloc(BITS2BYTES(bits), FRAME_ATOMIC);
    71                 if (!newmap)
     70                void *store = malloc(bitmap_size(elements), FRAME_ATOMIC);
     71                if (!store)
    7272                        return ENOMEM;
    7373               
    7474                bitmap_t oldiomap;
    75                 bitmap_initialize(&oldiomap, task->arch.iomap.map,
     75                bitmap_initialize(&oldiomap, task->arch.iomap.elements,
    7676                    task->arch.iomap.bits);
    77                 bitmap_initialize(&task->arch.iomap, newmap, bits);
     77               
     78                bitmap_initialize(&task->arch.iomap, elements, store);
    7879               
    7980                /*
    8081                 * Mark the new range inaccessible.
    8182                 */
    82                 bitmap_set_range(&task->arch.iomap, oldiomap.bits,
    83                     bits - oldiomap.bits);
     83                bitmap_set_range(&task->arch.iomap, oldiomap.elements,
     84                    elements - oldiomap.elements);
    8485               
    8586                /*
     
    8990                if (oldiomap.bits) {
    9091                        bitmap_copy(&task->arch.iomap, &oldiomap,
    91                             oldiomap.bits);
    92                         free(oldiomap.map);
     92                            oldiomap.elements);
     93                       
     94                        free(oldiomap.bits);
    9395                }
    9496        }
     
    9799         * Enable the range and we are done.
    98100         */
    99         bitmap_clear_range(&task->arch.iomap, (size_t) ioaddr, (size_t) size);
     101        bitmap_clear_range(&task->arch.iomap, (size_t) ioaddr, size);
    100102       
    101103        /*
     
    119121        /* First, copy the I/O Permission Bitmap. */
    120122        irq_spinlock_lock(&TASK->lock, false);
     123       
    121124        size_t ver = TASK->arch.iomapver;
    122         size_t bits = TASK->arch.iomap.bits;
    123         if (bits) {
    124                 ASSERT(TASK->arch.iomap.map);
     125        size_t elements = TASK->arch.iomap.elements;
     126       
     127        if (elements > 0) {
     128                ASSERT(TASK->arch.iomap.bits);
    125129               
    126130                bitmap_t iomap;
    127                 bitmap_initialize(&iomap, CPU->arch.tss->iomap,
    128                     TSS_IOMAP_SIZE * 8);
    129                 bitmap_copy(&iomap, &TASK->arch.iomap, bits);
     131                bitmap_initialize(&iomap, TSS_IOMAP_SIZE * 8,
     132                    CPU->arch.tss->iomap);
     133                bitmap_copy(&iomap, &TASK->arch.iomap, elements);
    130134               
    131135                /*
     
    133137                 * I/O access.
    134138                 */
    135                 bitmap_set_range(&iomap, bits, ALIGN_UP(bits, 8) - bits);
     139                bitmap_set_range(&iomap, elements,
     140                    ALIGN_UP(elements, 8) - elements);
     141               
    136142                /*
    137143                 * It is safe to set the trailing eight bits because of the
    138144                 * extra convenience byte in TSS_IOMAP_SIZE.
    139145                 */
    140                 bitmap_set_range(&iomap, ALIGN_UP(bits, 8), 8);
     146                bitmap_set_range(&iomap, ALIGN_UP(elements, 8), 8);
    141147        }
     148       
    142149        irq_spinlock_unlock(&TASK->lock, false);
    143150       
     
    150157       
    151158        descriptor_t *gdt_p = (descriptor_t *) cpugdtr.base;
    152         gdt_setlimit(&gdt_p[TSS_DES], TSS_BASIC_SIZE + BITS2BYTES(bits));
     159        size_t size = bitmap_size(elements);
     160        gdt_setlimit(&gdt_p[TSS_DES], TSS_BASIC_SIZE + size);
    153161        gdtr_load(&cpugdtr);
    154162       
  • kernel/arch/ia32/src/drivers/i8259.c

    rdba3e2c r8b863a62  
    4242#include <arch/asm.h>
    4343#include <arch.h>
    44 #include <print.h>
     44#include <log.h>
    4545#include <interrupt.h>
    4646
     
    129129{
    130130#ifdef CONFIG_DEBUG
    131         printf("cpu%u: PIC spurious interrupt\n", CPU->id);
     131        log(LF_ARCH, LVL_DEBUG, "cpu%u: PIC spurious interrupt", CPU->id);
    132132#endif
    133133}
  • kernel/arch/ia32/src/proc/task.c

    rdba3e2c r8b863a62  
    4040/** Perform ia32 specific task initialization.
    4141 *
    42  * @param t Task to be initialized.
     42 * @param task Task to be initialized.
     43 *
    4344 */
    44 void task_create_arch(task_t *t)
     45void task_create_arch(task_t *task)
    4546{
    46         t->arch.iomapver = 0;
    47         bitmap_initialize(&t->arch.iomap, NULL, 0);
     47        task->arch.iomapver = 0;
     48        bitmap_initialize(&task->arch.iomap, 0, NULL);
    4849}
    4950
    5051/** Perform ia32 specific task destruction.
    5152 *
    52  * @param t Task to be initialized.
     53 * @param task Task to be initialized.
     54 *
    5355 */
    54 void task_destroy_arch(task_t *t)
     56void task_destroy_arch(task_t *task)
    5557{
    56         if (t->arch.iomap.map)
    57                 free(t->arch.iomap.map);
     58        if (task->arch.iomap.bits != NULL)
     59                free(task->arch.iomap.bits);
    5860}
    5961
  • kernel/arch/ia32/src/smp/apic.c

    rdba3e2c r8b863a62  
    4242#include <interrupt.h>
    4343#include <arch/interrupt.h>
    44 #include <print.h>
     44#include <log.h>
    4545#include <arch/asm.h>
    4646#include <arch.h>
     
    135135{
    136136#ifdef CONFIG_DEBUG
    137         printf("cpu%u: APIC spurious interrupt\n", CPU->id);
     137        log(LF_ARCH, LVL_DEBUG, "cpu%u: APIC spurious interrupt", CPU->id);
    138138#endif
    139139}
     
    241241        esr.value = l_apic[ESR];
    242242       
    243         if (esr.send_checksum_error)
    244                 printf("Send Checksum Error\n");
    245         if (esr.receive_checksum_error)
    246                 printf("Receive Checksum Error\n");
    247         if (esr.send_accept_error)
    248                 printf("Send Accept Error\n");
    249         if (esr.receive_accept_error)
    250                 printf("Receive Accept Error\n");
    251         if (esr.send_illegal_vector)
    252                 printf("Send Illegal Vector\n");
    253         if (esr.received_illegal_vector)
    254                 printf("Received Illegal Vector\n");
    255         if (esr.illegal_register_address)
    256                 printf("Illegal Register Address\n");
     243        if (esr.err_bitmap) {
     244                log_begin(LF_ARCH, LVL_ERROR);
     245                log_printf("APIC errors detected:");
     246                if (esr.send_checksum_error)
     247                        log_printf("\nSend Checksum Error");
     248                if (esr.receive_checksum_error)
     249                        log_printf("\nReceive Checksum Error");
     250                if (esr.send_accept_error)
     251                        log_printf("\nSend Accept Error");
     252                if (esr.receive_accept_error)
     253                        log_printf("\nReceive Accept Error");
     254                if (esr.send_illegal_vector)
     255                        log_printf("\nSend Illegal Vector");
     256                if (esr.received_illegal_vector)
     257                        log_printf("\nReceived Illegal Vector");
     258                if (esr.illegal_register_address)
     259                        log_printf("\nIllegal Register Address");
     260                log_end();
     261        }
    257262       
    258263        return !esr.err_bitmap;
     
    270275                        retries = 0;
    271276#ifdef CONFIG_DEBUG
    272                         printf("IPI is pending.\n");
     277                        log(LF_ARCH, LVL_DEBUG, "IPI is pending.");
    273278#endif
    274279                        delay(20);
     
    489494{
    490495#ifdef LAPIC_VERBOSE
    491         printf("LVT on cpu%u, LAPIC ID: %" PRIu8 "\n",
     496        log_begin(LF_ARCH, LVL_DEBUG);
     497        log_printf("LVT on cpu%u, LAPIC ID: %" PRIu8 "\n",
    492498            CPU->id, l_apic_id());
    493499       
    494500        lvt_tm_t tm;
    495501        tm.value = l_apic[LVT_Tm];
    496         printf("LVT Tm: vector=%" PRIu8 ", %s, %s, %s\n",
     502        log_printf("LVT Tm: vector=%" PRIu8 ", %s, %s, %s\n",
    497503            tm.vector, delivs_str[tm.delivs], mask_str[tm.masked],
    498504            tm_mode_str[tm.mode]);
     
    500506        lvt_lint_t lint;
    501507        lint.value = l_apic[LVT_LINT0];
    502         printf("LVT LINT0: vector=%" PRIu8 ", %s, %s, %s, irr=%u, %s, %s\n",
     508        log_printf("LVT LINT0: vector=%" PRIu8 ", %s, %s, %s, irr=%u, %s, %s\n",
    503509            tm.vector, delmod_str[lint.delmod], delivs_str[lint.delivs],
    504510            intpol_str[lint.intpol], lint.irr, trigmod_str[lint.trigger_mode],
     
    506512       
    507513        lint.value = l_apic[LVT_LINT1];
    508         printf("LVT LINT1: vector=%" PRIu8 ", %s, %s, %s, irr=%u, %s, %s\n",
     514        log_printf("LVT LINT1: vector=%" PRIu8 ", %s, %s, %s, irr=%u, %s, %s\n",
    509515            tm.vector, delmod_str[lint.delmod], delivs_str[lint.delivs],
    510516            intpol_str[lint.intpol], lint.irr, trigmod_str[lint.trigger_mode],
     
    513519        lvt_error_t error;
    514520        error.value = l_apic[LVT_Err];
    515         printf("LVT Err: vector=%" PRIu8 ", %s, %s\n", error.vector,
     521        log_printf("LVT Err: vector=%" PRIu8 ", %s, %s\n", error.vector,
    516522            delivs_str[error.delivs], mask_str[error.masked]);
     523        log_end();
    517524#endif
    518525}
  • kernel/arch/ia32/src/smp/mps.c

    rdba3e2c r8b863a62  
    3636
    3737#include <config.h>
    38 #include <print.h>
     38#include <log.h>
    3939#include <debug.h>
    4040#include <arch/smp/mps.h>
     
    181181        buf[6] = 0;
    182182       
    183         printf("MPS: bus=%" PRIu8 " (%s)\n", bus->bus_id, buf);
     183        log(LF_ARCH, LVL_DEBUG, "MPS: bus=%" PRIu8 " (%s)", bus->bus_id, buf);
    184184#endif
    185185}
     
    205205{
    206206#ifdef MPSCT_VERBOSE
    207         printf("MPS: ");
     207        log_begin(LF_ARCH, LVL_DEBUG);
     208        log_printf("MPS: ");
    208209       
    209210        switch (iointr->intr_type) {
    210211        case 0:
    211                 printf("INT");
    212                 break;
    213         case 1:
    214                 printf("NMI");
    215                 break;
    216         case 2:
    217                 printf("SMI");
    218                 break;
    219         case 3:
    220                 printf("ExtINT");
    221                 break;
    222         }
    223        
    224         printf(", ");
     212                log_printf("INT");
     213                break;
     214        case 1:
     215                log_printf("NMI");
     216                break;
     217        case 2:
     218                log_printf("SMI");
     219                break;
     220        case 3:
     221                log_printf("ExtINT");
     222                break;
     223        }
     224       
     225        log_printf(", ");
    225226       
    226227        switch (iointr->poel & 3) {
    227228        case 0:
    228                 printf("bus-like");
    229                 break;
    230         case 1:
    231                 printf("active high");
    232                 break;
    233         case 2:
    234                 printf("reserved");
    235                 break;
    236         case 3:
    237                 printf("active low");
    238                 break;
    239         }
    240        
    241         printf(", ");
     229                log_printf("bus-like");
     230                break;
     231        case 1:
     232                log_printf("active high");
     233                break;
     234        case 2:
     235                log_printf("reserved");
     236                break;
     237        case 3:
     238                log_printf("active low");
     239                break;
     240        }
     241       
     242        log_printf(", ");
    242243       
    243244        switch ((iointr->poel >> 2) & 3) {
    244245        case 0:
    245                 printf("bus-like");
    246                 break;
    247         case 1:
    248                 printf("edge-triggered");
    249                 break;
    250         case 2:
    251                 printf("reserved");
    252                 break;
    253         case 3:
    254                 printf("level-triggered");
    255                 break;
    256         }
    257        
    258         printf(", bus=%" PRIu8 " irq=%" PRIu8 " io_apic=%" PRIu8" pin=%"
    259             PRIu8 "\n", iointr->src_bus_id, iointr->src_bus_irq,
     246                log_printf("bus-like");
     247                break;
     248        case 1:
     249                log_printf("edge-triggered");
     250                break;
     251        case 2:
     252                log_printf("reserved");
     253                break;
     254        case 3:
     255                log_printf("level-triggered");
     256                break;
     257        }
     258       
     259        log_printf(", bus=%" PRIu8 " irq=%" PRIu8 " io_apic=%" PRIu8" pin=%"
     260            PRIu8, iointr->src_bus_id, iointr->src_bus_irq,
    260261            iointr->dst_io_apic_id, iointr->dst_io_apic_pin);
     262        log_end();
    261263#endif
    262264}
     
    266268{
    267269#ifdef MPSCT_VERBOSE
    268         printf("MPS: ");
     270        log_begin(LF_ARCH, LVL_DEBUG);
     271        log_printf("MPS: ");
    269272       
    270273        switch (lintr->intr_type) {
    271274        case 0:
    272                 printf("INT");
    273                 break;
    274         case 1:
    275                 printf("NMI");
    276                 break;
    277         case 2:
    278                 printf("SMI");
    279                 break;
    280         case 3:
    281                 printf("ExtINT");
    282                 break;
    283         }
    284        
    285         printf(", ");
     275                log_printf("INT");
     276                break;
     277        case 1:
     278                log_printf("NMI");
     279                break;
     280        case 2:
     281                log_printf("SMI");
     282                break;
     283        case 3:
     284                log_printf("ExtINT");
     285                break;
     286        }
     287       
     288        log_printf(", ");
    286289       
    287290        switch (lintr->poel & 3) {
    288291        case 0:
    289                 printf("bus-like");
    290                 break;
    291         case 1:
    292                 printf("active high");
    293                 break;
    294         case 2:
    295                 printf("reserved");
    296                 break;
    297         case 3:
    298                 printf("active low");
    299                 break;
    300         }
    301        
    302         printf(", ");
     292                log_printf("bus-like");
     293                break;
     294        case 1:
     295                log_printf("active high");
     296                break;
     297        case 2:
     298                log_printf("reserved");
     299                break;
     300        case 3:
     301                log_printf("active low");
     302                break;
     303        }
     304       
     305        log_printf(", ");
    303306       
    304307        switch ((lintr->poel >> 2) & 3) {
    305308        case 0:
    306                 printf("bus-like");
    307                 break;
    308         case 1:
    309                 printf("edge-triggered");
    310                 break;
    311         case 2:
    312                 printf("reserved");
    313                 break;
    314         case 3:
    315                 printf("level-triggered");
    316                 break;
    317         }
    318        
    319         printf(", bus=%" PRIu8 " irq=%" PRIu8 " l_apic=%" PRIu8" pin=%"
    320             PRIu8 "\n", lintr->src_bus_id, lintr->src_bus_irq,
     309                log_printf("bus-like");
     310                break;
     311        case 1:
     312                log_printf("edge-triggered");
     313                break;
     314        case 2:
     315                log_printf("reserved");
     316                break;
     317        case 3:
     318                log_printf("level-triggered");
     319                break;
     320        }
     321       
     322        log_printf(", bus=%" PRIu8 " irq=%" PRIu8 " l_apic=%" PRIu8" pin=%"
     323            PRIu8, lintr->src_bus_id, lintr->src_bus_irq,
    321324            lintr->dst_l_apic_id, lintr->dst_l_apic_pin);
     325        log_end();
    322326#endif
    323327}
     
    332336                switch (cur[CT_EXT_ENTRY_TYPE]) {
    333337                default:
    334                         printf("MPS: Skipping MP Configuration Table extended "
    335                             "entry type %" PRIu8 "\n", cur[CT_EXT_ENTRY_TYPE]);
     338                        log(LF_ARCH, LVL_NOTE, "MPS: Skipping MP Configuration"
     339                            " Table extended entry type %" PRIu8,
     340                            cur[CT_EXT_ENTRY_TYPE]);
    336341                }
    337342        }
     
    341346{
    342347        if (ct->signature != CT_SIGNATURE) {
    343                 printf("MPS: Wrong ct->signature\n");
     348                log(LF_ARCH, LVL_WARN, "MPS: Wrong ct->signature");
    344349                return;
    345350        }
    346351       
    347352        if (!mps_ct_check()) {
    348                 printf("MPS: Wrong ct checksum\n");
     353                log(LF_ARCH, LVL_WARN, "MPS: Wrong ct checksum");
    349354                return;
    350355        }
    351356       
    352357        if (ct->oem_table) {
    353                 printf("MPS: ct->oem_table not supported\n");
     358                log(LF_ARCH, LVL_WARN, "MPS: ct->oem_table not supported");
    354359                return;
    355360        }
     
    402407                         * Something is wrong. Fallback to UP mode.
    403408                         */
    404                         printf("MPS: ct badness %" PRIu8 "\n", *cur);
     409                        log(LF_ARCH, LVL_WARN, "MPS: ct badness %" PRIu8, *cur);
    405410                        return;
    406411                }
     
    418423         * Not yet implemented.
    419424         */
    420         printf("MPS: Default configuration not supported\n");
     425        log(LF_ARCH, LVL_WARN, "MPS: Default configuration not supported");
    421426}
    422427
     
    449454       
    450455fs_found:
    451         printf("%p: MPS Floating Pointer Structure\n", fs);
     456        log(LF_ARCH, LVL_NOTE, "%p: MPS Floating Pointer Structure", fs);
    452457       
    453458        if ((fs->config_type == 0) && (fs->configuration_table)) {
    454459                if (fs->mpfib2 >> 7) {
    455                         printf("MPS: PIC mode not supported\n");
     460                        log(LF_ARCH, LVL_WARN, "MPS: PIC mode not supported\n");
    456461                        return;
    457462                }
  • kernel/arch/ia32/src/smp/smp.c

    rdba3e2c r8b863a62  
    5252#include <mm/slab.h>
    5353#include <mm/as.h>
    54 #include <print.h>
     54#include <log.h>
    5555#include <memstr.h>
    5656#include <arch/drivers/i8259.h>
     
    129129               
    130130                if (ops->cpu_apic_id(i) == bsp_l_apic) {
    131                         printf("kmp: bad processor entry #%u, will not send IPI "
    132                             "to myself\n", i);
     131                        log(LF_ARCH, LVL_ERROR, "kmp: bad processor entry #%u, "
     132                            "will not send IPI to myself", i);
    133133                        continue;
    134134                }
     
    162162                        if (waitq_sleep_timeout(&ap_completion_wq, 1000000,
    163163                            SYNCH_FLAGS_NONE) == ESYNCH_TIMEOUT) {
    164                                 printf("%s: waiting for cpu%u (APIC ID = %d) "
    165                                     "timed out\n", __FUNCTION__, i,
    166                                     ops->cpu_apic_id(i));
     164                                log(LF_ARCH, LVL_NOTE, "%s: waiting for cpu%u "
     165                                    "(APIC ID = %d) timed out", __FUNCTION__,
     166                                    i, ops->cpu_apic_id(i));
    167167                        }
    168168                } else
    169                         printf("INIT IPI for l_apic%d failed\n",
     169                        log(LF_ARCH, LVL_ERROR, "INIT IPI for l_apic%d failed",
    170170                            ops->cpu_apic_id(i));
    171171        }
  • kernel/arch/ia64/include/arch/mm/frame.h

    rdba3e2c r8b863a62  
    3939#define FRAME_SIZE   (1 << FRAME_WIDTH)
    4040
     41#define FRAME_LOWPRIO  0
     42
    4143#ifndef __ASM__
    4244
  • kernel/arch/ia64/src/ddi/ddi.c

    rdba3e2c r8b863a62  
    11/*
    22 * Copyright (c) 2006 Jakub Jermar
    3  * Copyright (c) 2008 Jakub vana
     3 * Copyright (c) 2008 Jakub Vana
    44 * All rights reserved.
    55 *
     
    5656{
    5757        if (!task->arch.iomap) {
    58                 uint8_t *map;
    59 
    6058                task->arch.iomap = malloc(sizeof(bitmap_t), 0);
    61                 map = malloc(BITS2BYTES(IO_MEMMAP_PAGES), 0);
    62                 if(!map)
     59                if (task->arch.iomap == NULL)
    6360                        return ENOMEM;
    64                 bitmap_initialize(task->arch.iomap, map, IO_MEMMAP_PAGES);
     61               
     62                void *store = malloc(bitmap_size(IO_MEMMAP_PAGES), 0);
     63                if (store == NULL)
     64                        return ENOMEM;
     65               
     66                bitmap_initialize(task->arch.iomap, IO_MEMMAP_PAGES, store);
    6567                bitmap_clear_range(task->arch.iomap, 0, IO_MEMMAP_PAGES);
    6668        }
     
    6971        size = ALIGN_UP(size + ioaddr - 4 * iopage, PORTS_PER_PAGE);
    7072        bitmap_set_range(task->arch.iomap, iopage, size / 4);
    71 
     73       
    7274        return 0;
    7375}
  • kernel/arch/ia64/src/drivers/ski.c

    rdba3e2c r8b863a62  
    6161static outdev_operations_t skidev_ops = {
    6262        .write = ski_putchar,
    63         .redraw = NULL
     63        .redraw = NULL,
     64        .scroll_up = NULL,
     65        .scroll_down = NULL
    6466};
    6567
  • kernel/arch/ia64/src/mm/vhpt.c

    rdba3e2c r8b863a62  
    4242uintptr_t vhpt_set_up(void)
    4343{
    44         vhpt_base = frame_alloc(VHPT_WIDTH - FRAME_WIDTH,
    45             FRAME_KA | FRAME_ATOMIC);
    46         if (!vhpt_base)
     44        uintptr_t vhpt_frame =
     45            frame_alloc(SIZE2FRAMES(VHPT_SIZE), FRAME_ATOMIC, 0);
     46        if (!vhpt_frame)
    4747                panic("Kernel configured with VHPT but no memory for table.");
     48       
     49        vhpt_base = (vhpt_entry_t *) PA2KA(vhpt_frame);
    4850        vhpt_invalidate_all();
    4951        return (uintptr_t) vhpt_base;
     
    8284void vhpt_invalidate_all()
    8385{
    84         memsetb(vhpt_base, 1 << VHPT_WIDTH, 0);
     86        memsetb(vhpt_base, VHPT_SIZE, 0);
    8587}
    8688
  • kernel/arch/mips32/include/arch/asm.h

    rdba3e2c r8b863a62  
    4242NO_TRACE static inline void cpu_sleep(void)
    4343{
    44         /*
    45          * Unfortunatelly most of the simulators do not support
    46          *
    47          * asm volatile (
    48          *     "wait"
    49          * );
    50          *
    51          */
     44        asm volatile ("wait");
    5245}
    5346
  • kernel/arch/mips32/include/arch/mm/frame.h

    rdba3e2c r8b863a62  
    3939#define FRAME_SIZE   (1 << FRAME_WIDTH)
    4040
     41#define FRAME_LOWPRIO  0
     42
    4143#ifndef __ASM__
    4244
  • kernel/arch/mips32/include/arch/mm/page.h

    rdba3e2c r8b863a62  
    2727 */
    2828
    29 /** @addtogroup mips32mm       
     29/** @addtogroup mips32mm
    3030 * @{
    3131 */
     
    7070 * - PTL3 has 4096 entries (12 bits)
    7171 */
    72  
     72
    7373/* Macros describing number of entries in each level. */
    74 #define PTL0_ENTRIES_ARCH       64
    75 #define PTL1_ENTRIES_ARCH       0
    76 #define PTL2_ENTRIES_ARCH       0
    77 #define PTL3_ENTRIES_ARCH       4096
     74#define PTL0_ENTRIES_ARCH  64
     75#define PTL1_ENTRIES_ARCH  0
     76#define PTL2_ENTRIES_ARCH  0
     77#define PTL3_ENTRIES_ARCH  4096
    7878
    7979/* Macros describing size of page tables in each level. */
    80 #define PTL0_SIZE_ARCH          ONE_FRAME
    81 #define PTL1_SIZE_ARCH          0
    82 #define PTL2_SIZE_ARCH          0
    83 #define PTL3_SIZE_ARCH          ONE_FRAME
     80#define PTL0_FRAMES_ARCH  1
     81#define PTL1_FRAMES_ARCH  1
     82#define PTL2_FRAMES_ARCH  1
     83#define PTL3_FRAMES_ARCH  1
    8484
    8585/* Macros calculating entry indices for each level. */
    86 #define PTL0_INDEX_ARCH(vaddr)  ((vaddr) >> 26)
    87 #define PTL1_INDEX_ARCH(vaddr)  0
    88 #define PTL2_INDEX_ARCH(vaddr)  0
    89 #define PTL3_INDEX_ARCH(vaddr)  (((vaddr) >> 14) & 0xfff)
     86#define PTL0_INDEX_ARCH(vaddr)  ((vaddr) >> 26)
     87#define PTL1_INDEX_ARCH(vaddr)  0
     88#define PTL2_INDEX_ARCH(vaddr)  0
     89#define PTL3_INDEX_ARCH(vaddr)  (((vaddr) >> 14) & 0xfff)
    9090
    9191/* Set accessor for PTL0 address. */
    9292#define SET_PTL0_ADDRESS_ARCH(ptl0)
    9393
    94 /* Get PTE address accessors for each level. */ 
     94/* Get PTE address accessors for each level. */
    9595#define GET_PTL1_ADDRESS_ARCH(ptl0, i) \
    9696        (((pte_t *) (ptl0))[(i)].pfn << 12)
     
    196196        p->p = 1;
    197197}
    198        
    199198
    200199extern void page_arch_init(void);
  • kernel/arch/mips32/src/debugger.c

    rdba3e2c r8b863a62  
    3939#include <console/cmd.h>
    4040#include <print.h>
     41#include <log.h>
    4142#include <panic.h>
    4243#include <arch.h>
     
    294295        cmd_initialize(&bkpts_info);
    295296        if (!cmd_register(&bkpts_info))
    296                 printf("Cannot register command %s\n", bkpts_info.name);
     297                log(LF_OTHER, LVL_WARN, "Cannot register command %s",
     298                    bkpts_info.name);
    297299       
    298300        cmd_initialize(&delbkpt_info);
    299301        if (!cmd_register(&delbkpt_info))
    300                 printf("Cannot register command %s\n", delbkpt_info.name);
     302                log(LF_OTHER, LVL_WARN, "Cannot register command %s",
     303                    delbkpt_info.name);
    301304       
    302305        cmd_initialize(&addbkpt_info);
    303306        if (!cmd_register(&addbkpt_info))
    304                 printf("Cannot register command %s\n", addbkpt_info.name);
     307                log(LF_OTHER, LVL_WARN, "Cannot register command %s",
     308                    addbkpt_info.name);
    305309       
    306310        cmd_initialize(&addbkpte_info);
    307311        if (!cmd_register(&addbkpte_info))
    308                 printf("Cannot register command %s\n", addbkpte_info.name);
     312                log(LF_OTHER, LVL_WARN, "Cannot register command %s",
     313                    addbkpte_info.name);
    309314#endif /* CONFIG_KCONSOLE */
    310315}
  • kernel/arch/mips32/src/exception.c

    rdba3e2c r8b863a62  
    4848#include <arch/debugger.h>
    4949#include <symtab.h>
     50#include <log.h>
    5051
    5152static const char *exctable[] = {
     
    7475void istate_decode(istate_t *istate)
    7576{
    76         printf("epc=%#010" PRIx32 "\tsta=%#010" PRIx32 "\t"
     77        log_printf("epc=%#010" PRIx32 "\tsta=%#010" PRIx32 "\t"
    7778            "lo =%#010" PRIx32 "\thi =%#010" PRIx32 "\n",
    7879            istate->epc, istate->status, istate->lo, istate->hi);
    7980       
    80         printf("a0 =%#010" PRIx32 "\ta1 =%#010" PRIx32 "\t"
     81        log_printf("a0 =%#010" PRIx32 "\ta1 =%#010" PRIx32 "\t"
    8182            "a2 =%#010" PRIx32 "\ta3 =%#010" PRIx32 "\n",
    8283            istate->a0, istate->a1, istate->a2, istate->a3);
    8384       
    84         printf("t0 =%#010" PRIx32 "\tt1 =%#010" PRIx32 "\t"
     85        log_printf("t0 =%#010" PRIx32 "\tt1 =%#010" PRIx32 "\t"
    8586            "t2 =%#010" PRIx32 "\tt3 =%#010" PRIx32 "\n",
    8687            istate->t0, istate->t1, istate->t2, istate->t3);
    8788       
    88         printf("t4 =%#010" PRIx32 "\tt5 =%#010" PRIx32 "\t"
     89        log_printf("t4 =%#010" PRIx32 "\tt5 =%#010" PRIx32 "\t"
    8990            "t6 =%#010" PRIx32 "\tt7 =%#010" PRIx32 "\n",
    9091            istate->t4, istate->t5, istate->t6, istate->t7);
    9192       
    92         printf("t8 =%#010" PRIx32 "\tt9 =%#010" PRIx32 "\t"
     93        log_printf("t8 =%#010" PRIx32 "\tt9 =%#010" PRIx32 "\t"
    9394            "v0 =%#010" PRIx32 "\tv1 =%#010" PRIx32 "\n",
    9495            istate->t8, istate->t9, istate->v0, istate->v1);
    9596       
    96         printf("s0 =%#010" PRIx32 "\ts1 =%#010" PRIx32 "\t"
     97        log_printf("s0 =%#010" PRIx32 "\ts1 =%#010" PRIx32 "\t"
    9798            "s2 =%#010" PRIx32 "\ts3 =%#010" PRIx32 "\n",
    9899            istate->s0, istate->s1, istate->s2, istate->s3);
    99100       
    100         printf("s4 =%#010" PRIx32 "\ts5 =%#010" PRIx32 "\t"
     101        log_printf("s4 =%#010" PRIx32 "\ts5 =%#010" PRIx32 "\t"
    101102            "s6 =%#010" PRIx32 "\ts7 =%#010" PRIx32 "\n",
    102103            istate->s4, istate->s5, istate->s6, istate->s7);
    103104       
    104         printf("s8 =%#010" PRIx32 "\tat =%#010" PRIx32 "\t"
     105        log_printf("s8 =%#010" PRIx32 "\tat =%#010" PRIx32 "\t"
    105106            "kt0=%#010" PRIx32 "\tkt1=%#010" PRIx32 "\n",
    106107            istate->s8, istate->at, istate->kt0, istate->kt1);
    107108       
    108         printf("sp =%#010" PRIx32 "\tra =%#010" PRIx32 "\t"
     109        log_printf("sp =%#010" PRIx32 "\tra =%#010" PRIx32 "\t"
    109110            "gp =%#010" PRIx32 "\n",
    110111            istate->sp, istate->ra, istate->gp);
     
    194195                                 */
    195196#ifdef CONFIG_DEBUG
    196                                 printf("cpu%u: spurious interrupt (inum=%u)\n",
     197                                log(LF_ARCH, LVL_DEBUG,
     198                                    "cpu%u: spurious interrupt (inum=%u)",
    197199                                    CPU->id, i);
    198200#endif
  • kernel/arch/mips32/src/mach/malta/malta.c

    rdba3e2c r8b863a62  
    9292static outdev_operations_t yamon_outdev_ops = {
    9393        .write = yamon_putchar,
    94         .redraw = NULL
     94        .redraw = NULL,
     95        .scroll_up = NULL,
     96        .scroll_down = NULL
    9597};
    9698
     
    103105void malta_input_init(void)
    104106{
     107        (void) stdin_wire();
    105108}
    106109
  • kernel/arch/mips32/src/mm/tlb.c

    rdba3e2c r8b863a62  
    4343#include <synch/mutex.h>
    4444#include <print.h>
     45#include <log.h>
    4546#include <debug.h>
    4647#include <align.h>
     
    4849#include <symtab.h>
    4950
    50 #define PFN_SHIFT       12
    51 #define VPN_SHIFT       12
    52 #define ADDR2VPN(a)     ((a) >> VPN_SHIFT)
    53 #define ADDR2VPN2(a)    (ADDR2VPN((a)) >> 1)
    54 #define VPN2ADDR(vpn)   ((vpn) << VPN_SHIFT)
    55 #define VPN22ADDR(vpn2) (VPN2ADDR(vpn2) << 1)
    56 #define PFN2ADDR(pfn)   ((pfn) << PFN_SHIFT)
    57 
    58 #define BANK_SELECT_BIT(a)      (((a) >> PAGE_WIDTH) & 1)
    59        
     51#define PFN_SHIFT  12
     52#define VPN_SHIFT  12
     53
     54#define ADDR2HI_VPN(a)   ((a) >> VPN_SHIFT)
     55#define ADDR2HI_VPN2(a)  (ADDR2HI_VPN((a)) >> 1)
     56
     57#define HI_VPN2ADDR(vpn)    ((vpn) << VPN_SHIFT)
     58#define HI_VPN22ADDR(vpn2)  (HI_VPN2ADDR(vpn2) << 1)
     59
     60#define LO_PFN2ADDR(pfn)  ((pfn) << PFN_SHIFT)
     61
     62#define BANK_SELECT_BIT(a)  (((a) >> PAGE_WIDTH) & 1)
    6063
    6164/** Initialize TLB.
     
    215218         */
    216219        if (index.p) {
    217                 printf("%s: TLBP failed in exception handler (badvaddr=%#"
     220                log(LF_ARCH, LVL_WARN, "%s: TLBP failed in exception handler (badvaddr=%#"
    218221                    PRIxn ", ASID=%d).\n", __func__, badvaddr,
    219222                    AS ? AS->asid : -1);
     
    266269{
    267270        hi->value = 0;
    268         hi->vpn2 = ADDR2VPN2(ALIGN_DOWN(addr, PAGE_SIZE));
     271        hi->vpn2 = ADDR2HI_VPN2(ALIGN_DOWN(addr, PAGE_SIZE));
    269272        hi->asid = asid;
    270273}
     
    295298               
    296299                printf("%-4u %-6u %0#10x %-#6x  %1u%1u%1u%1u  %0#10x\n",
    297                     i, hi.asid, VPN22ADDR(hi.vpn2), mask.mask,
    298                     lo0.g, lo0.v, lo0.d, lo0.c, PFN2ADDR(lo0.pfn));
     300                    i, hi.asid, HI_VPN22ADDR(hi.vpn2), mask.mask,
     301                    lo0.g, lo0.v, lo0.d, lo0.c, LO_PFN2ADDR(lo0.pfn));
    299302                printf("                               %1u%1u%1u%1u  %0#10x\n",
    300                     lo1.g, lo1.v, lo1.d, lo1.c, PFN2ADDR(lo1.pfn));
     303                    lo1.g, lo1.v, lo1.d, lo1.c, LO_PFN2ADDR(lo1.pfn));
    301304        }
    302305       
  • kernel/arch/mips64/include/arch/mm/frame.h

    rdba3e2c r8b863a62  
    3939#define FRAME_SIZE   (1 << FRAME_WIDTH)
    4040
     41#define FRAME_LOWPRIO  0
     42
    4143#ifndef __ASM__
    4244
  • kernel/arch/ppc32/include/arch/mm/frame.h

    rdba3e2c r8b863a62  
    3939#define FRAME_SIZE   (1 << FRAME_WIDTH)
    4040
     41#define FRAME_LOWPRIO  0
     42
    4143#ifndef __ASM__
    4244
  • kernel/arch/ppc32/include/arch/mm/page.h

    rdba3e2c r8b863a62  
    7070
    7171/* Page table sizes for each level. */
    72 #define PTL0_SIZE_ARCH  ONE_FRAME
    73 #define PTL1_SIZE_ARCH  0
    74 #define PTL2_SIZE_ARCH  0
    75 #define PTL3_SIZE_ARCH  ONE_FRAME
     72#define PTL0_FRAMES_ARCH  1
     73#define PTL1_FRAMES_ARCH  1
     74#define PTL2_FRAMES_ARCH  1
     75#define PTL3_FRAMES_ARCH  1
    7676
    7777/* Macros calculating indices into page tables on each level. */
  • kernel/arch/ppc32/src/interrupt.c

    rdba3e2c r8b863a62  
    4444#include <arch/mm/pht.h>
    4545#include <print.h>
     46#include <log.h>
    4647
    4748void start_decrementer(void)
     
    5556void istate_decode(istate_t *istate)
    5657{
    57         printf("r0 =%0#10" PRIx32 "\tr1 =%0#10" PRIx32 "\t"
     58        log_printf("r0 =%0#10" PRIx32 "\tr1 =%0#10" PRIx32 "\t"
    5859            "r2 =%0#10" PRIx32 "\n", istate->r0, istate->sp, istate->r2);
    5960       
    60         printf("r3 =%0#10" PRIx32 "\tr4 =%0#10" PRIx32 "\t"
     61        log_printf("r3 =%0#10" PRIx32 "\tr4 =%0#10" PRIx32 "\t"
    6162            "r5 =%0#10" PRIx32 "\n", istate->r3, istate->r4, istate->r5);
    6263       
    63         printf("r6 =%0#10" PRIx32 "\tr7 =%0#10" PRIx32 "\t"
     64        log_printf("r6 =%0#10" PRIx32 "\tr7 =%0#10" PRIx32 "\t"
    6465            "r8 =%0#10" PRIx32 "\n", istate->r6, istate->r7, istate->r8);
    6566       
    66         printf("r9 =%0#10" PRIx32 "\tr10=%0#10" PRIx32 "\t"
     67        log_printf("r9 =%0#10" PRIx32 "\tr10=%0#10" PRIx32 "\t"
    6768            "r11=%0#10" PRIx32 "\n", istate->r9, istate->r10, istate->r11);
    6869       
    69         printf("r12=%0#10" PRIx32 "\tr13=%0#10" PRIx32 "\t"
     70        log_printf("r12=%0#10" PRIx32 "\tr13=%0#10" PRIx32 "\t"
    7071            "r14=%0#10" PRIx32 "\n", istate->r12, istate->r13, istate->r14);
    7172       
    72         printf("r15=%0#10" PRIx32 "\tr16=%0#10" PRIx32 "\t"
     73        log_printf("r15=%0#10" PRIx32 "\tr16=%0#10" PRIx32 "\t"
    7374            "r17=%0#10" PRIx32 "\n", istate->r15, istate->r16, istate->r17);
    7475       
    75         printf("r18=%0#10" PRIx32 "\tr19=%0#10" PRIx32 "\t"
     76        log_printf("r18=%0#10" PRIx32 "\tr19=%0#10" PRIx32 "\t"
    7677            "r20=%0#10" PRIx32 "\n", istate->r18, istate->r19, istate->r20);
    7778       
    78         printf("r21=%0#10" PRIx32 "\tr22=%0#10" PRIx32 "\t"
     79        log_printf("r21=%0#10" PRIx32 "\tr22=%0#10" PRIx32 "\t"
    7980            "r23=%0#10" PRIx32 "\n", istate->r21, istate->r22, istate->r23);
    8081       
    81         printf("r24=%0#10" PRIx32 "\tr25=%0#10" PRIx32 "\t"
     82        log_printf("r24=%0#10" PRIx32 "\tr25=%0#10" PRIx32 "\t"
    8283            "r26=%0#10" PRIx32 "\n", istate->r24, istate->r25, istate->r26);
    8384       
    84         printf("r27=%0#10" PRIx32 "\tr28=%0#10" PRIx32 "\t"
     85        log_printf("r27=%0#10" PRIx32 "\tr28=%0#10" PRIx32 "\t"
    8586            "r29=%0#10" PRIx32 "\n", istate->r27, istate->r28, istate->r29);
    8687       
    87         printf("r30=%0#10" PRIx32 "\tr31=%0#10" PRIx32 "\n",
     88        log_printf("r30=%0#10" PRIx32 "\tr31=%0#10" PRIx32 "\n",
    8889            istate->r30, istate->r31);
    8990       
    90         printf("cr =%0#10" PRIx32 "\tpc =%0#10" PRIx32 "\t"
     91        log_printf("cr =%0#10" PRIx32 "\tpc =%0#10" PRIx32 "\t"
    9192            "lr =%0#10" PRIx32 "\n", istate->cr, istate->pc, istate->lr);
    9293       
    93         printf("ctr=%0#10" PRIx32 "\txer=%0#10" PRIx32 "\t"
     94        log_printf("ctr=%0#10" PRIx32 "\txer=%0#10" PRIx32 "\t"
    9495            "dar=%0#10" PRIx32 "\n", istate->ctr, istate->xer, istate->dar);
    9596       
    96         printf("srr1=%0#10" PRIx32 "\n", istate->srr1);
     97        log_printf("srr1=%0#10" PRIx32 "\n", istate->srr1);
    9798}
    9899
     
    130131                         */
    131132#ifdef CONFIG_DEBUG
    132                         printf("cpu%u: spurious interrupt (inum=%" PRIu8 ")\n",
    133                             CPU->id, inum);
     133                        log(LF_ARCH, LVL_DEBUG, "cpu%u: spurious interrupt"
     134                            " (inum=%" PRIu8 ")", CPU->id, inum);
    134135#endif
    135136                }
  • kernel/arch/sparc64/include/arch/mm/frame.h

    rdba3e2c r8b863a62  
    4646#endif
    4747
     48#ifndef __ASM__
     49
     50#include <typedefs.h>
     51
     52extern uintptr_t end_of_identity;
     53
     54extern void frame_low_arch_init(void);
     55extern void frame_high_arch_init(void);
     56#define physmem_print()
     57
     58#endif
     59
    4860#endif
    4961
  • kernel/arch/sparc64/include/arch/mm/sun4u/frame.h

    rdba3e2c r8b863a62  
    2727 */
    2828
    29 /** @addtogroup sparc64mm       
     29/** @addtogroup sparc64mm
    3030 * @{
    3131 */
     
    4141 * Therefore, the kernel uses 8K only internally on the TLB and TSB levels.
    4242 */
    43 #define MMU_FRAME_WIDTH         13      /* 8K */
    44 #define MMU_FRAME_SIZE          (1 << MMU_FRAME_WIDTH)
     43#define MMU_FRAME_WIDTH  13  /* 8K */
     44#define MMU_FRAME_SIZE   (1 << MMU_FRAME_WIDTH)
    4545
    4646/*
     
    4949 * each 16K page with a pair of adjacent 8K pages.
    5050 */
    51 #define FRAME_WIDTH             14      /* 16K */
    52 #define FRAME_SIZE              (1 << FRAME_WIDTH)
     51#define FRAME_WIDTH  14  /* 16K */
     52#define FRAME_SIZE   (1 << FRAME_WIDTH)
     53
     54#define FRAME_LOWPRIO  0
    5355
    5456#ifndef __ASM__
     
    7274typedef union frame_address frame_address_t;
    7375
    74 extern uintptr_t end_of_identity;
    75 
    76 extern void frame_low_arch_init(void);
    77 extern void frame_high_arch_init(void);
    78 #define physmem_print()
    79 
    8076#endif
    8177
  • kernel/arch/sparc64/include/arch/mm/sun4v/frame.h

    rdba3e2c r8b863a62  
    2727 */
    2828
    29 /** @addtogroup sparc64mm       
     29/** @addtogroup sparc64mm
    3030 * @{
    3131 */
     
    3636#define KERN_sparc64_sun4v_FRAME_H_
    3737
    38 #define MMU_FRAME_WIDTH         13      /* 8K */
    39 #define MMU_FRAME_SIZE          (1 << MMU_FRAME_WIDTH)
     38#define MMU_FRAME_WIDTH  13  /* 8K */
     39#define MMU_FRAME_SIZE   (1 << MMU_FRAME_WIDTH)
    4040
    41 #define FRAME_WIDTH             13
    42 #define FRAME_SIZE              (1 << FRAME_WIDTH)
     41#define FRAME_WIDTH  13
     42#define FRAME_SIZE   (1 << FRAME_WIDTH)
    4343
    44 #ifndef __ASM__
    45 
    46 #include <typedefs.h>
    47 
    48 extern void frame_low_arch_init(void);
    49 extern void frame_high_arch_init(void);
    50 #define physmem_print()
    51 
    52 #endif
     44#define FRAME_LOWPRIO  0
    5345
    5446#endif
  • kernel/arch/sparc64/include/arch/trap/sun4v/mmu.h

    rdba3e2c r8b863a62  
    102102        nop
    103103
     104        /* exclude pages beyond the end of memory from the identity mapping */
     105        sethi %hi(end_of_identity), %g4
     106        ldx [%g4 + %lo(end_of_identity)], %g4
     107        cmp %g1, %g4
     108        bgeu %xcc, 0f
     109        nop
     110
    104111        /*
    105112         * Installing the identity does not fit into 32 instructions, call
  • kernel/arch/sparc64/src/drivers/kbd.c

    rdba3e2c r8b863a62  
    4444#include <align.h>
    4545#include <str.h>
    46 #include <print.h>
     46#include <log.h>
    4747#include <sysinfo/sysinfo.h>
    4848
     
    7171        ofw_tree_property_t *prop = ofw_tree_getprop(node, "interrupts");
    7272        if ((!prop) || (!prop->value)) {
    73                 printf("ns16550: Unable to find interrupts property\n");
     73                log(LF_ARCH, LVL_ERROR,
     74                    "ns16550: Unable to find interrupts property");
    7475                return false;
    7576        }
     
    8283        prop = ofw_tree_getprop(node, "reg");
    8384        if ((!prop) || (!prop->value)) {
    84                 printf("ns16550: Unable to find reg property\n");
     85                log(LF_ARCH, LVL_ERROR,
     86                    "ns16550: Unable to find reg property");
    8587                return false;
    8688        }
     
    9193        if (!ofw_ebus_apply_ranges(node->parent,
    9294            ((ofw_ebus_reg_t *) prop->value), &pa)) {
    93                 printf("ns16550: Failed to determine address\n");
     95                log(LF_ARCH, LVL_ERROR,
     96                    "ns16550: Failed to determine address");
    9497                return false;
    9598        }
     
    101104            ((ofw_ebus_reg_t *) prop->value), interrupts, &inr, &cir,
    102105            &cir_arg)) {
    103                 printf("ns16550: Failed to determine interrupt\n");
     106                log(LF_ARCH, LVL_ERROR,
     107                    "ns16550: Failed to determine interrupt");
    104108                return false;
    105109        }
     
    117121            PAGE_WRITE | PAGE_NOT_CACHEABLE) + offset);
    118122       
    119         ns16550_instance_t *ns16550_instance = ns16550_init(ns16550, inr, cir, cir_arg);
     123        ns16550_instance_t *ns16550_instance = ns16550_init(ns16550, inr, cir,
     124            cir_arg);
    120125        if (ns16550_instance) {
    121126                kbrd_instance_t *kbrd_instance = kbrd_init();
  • kernel/arch/sparc64/src/drivers/niagara.c

    rdba3e2c r8b863a62  
    6363static outdev_operations_t niagara_ops = {
    6464        .write = niagara_putchar,
    65         .redraw = NULL
     65        .redraw = NULL,
     66        .scroll_up = NULL,
     67        .scroll_down = NULL
    6668};
    6769
  • kernel/arch/sparc64/src/drivers/pci.c

    rdba3e2c r8b863a62  
    4343#include <typedefs.h>
    4444#include <debug.h>
    45 #include <print.h>
     45#include <log.h>
    4646#include <str.h>
    4747#include <arch/asm.h>
     
    213213                 * Unsupported model.
    214214                 */
    215                 printf("Unsupported PCI controller model (%s).\n",
     215                log(LF_ARCH, LVL_WARN, "Unsupported PCI controller model (%s).",
    216216                    (char *) prop->value);
    217217        }
  • kernel/arch/sparc64/src/drivers/scr.c

    rdba3e2c r8b863a62  
    4646#include <align.h>
    4747#include <print.h>
     48#include <log.h>
    4849
    4950#define FFB_REG_24BPP   7
     
    8182       
    8283        if (scr_type == SCR_UNKNOWN) {
    83                 printf("Unknown screen device.\n");
     84                log(LF_ARCH, LVL_ERROR, "Unknown screen device.");
    8485                return;
    8586        }
     
    117118        case SCR_ATYFB:
    118119                if (prop->size / sizeof(ofw_pci_reg_t) < 2) {
    119                         printf("Too few screen registers.\n");
     120                        log(LF_ARCH, LVL_ERROR, "Too few screen registers.");
    120121                        return;
    121122                }
     
    124125               
    125126                if (!ofw_pci_reg_absolutize(node, pci_reg, &pci_abs_reg)) {
    126                         printf("Failed to absolutize fb register.\n");
     127                        log(LF_ARCH, LVL_ERROR,
     128                            "Failed to absolutize fb register.");
    127129                        return;
    128130                }
     
    130132                if (!ofw_pci_apply_ranges(node->parent, &pci_abs_reg,
    131133                    &fb_addr)) {
    132                         printf("Failed to determine screen address.\n");
     134                        log(LF_ARCH, LVL_ERROR,
     135                            "Failed to determine screen address.");
    133136                        return;
    134137                }
     
    152155                        break;
    153156                default:
    154                         printf("Unsupported bits per pixel.\n");
     157                        log(LF_ARCH, LVL_ERROR,
     158                            "Unsupported bits per pixel.");
    155159                        return;
    156160                }
     
    159163        case SCR_XVR:
    160164                if (prop->size / sizeof(ofw_pci_reg_t) < 2) {
    161                         printf("Too few screen registers.\n");
     165                        log(LF_ARCH, LVL_ERROR,
     166                            "Too few screen registers.");
    162167                        return;
    163168                }
     
    166171               
    167172                if (!ofw_pci_reg_absolutize(node, pci_reg, &pci_abs_reg)) {
    168                         printf("Failed to absolutize fb register.\n");
     173                        log(LF_ARCH, LVL_ERROR,
     174                            "Failed to absolutize fb register.");
    169175                        return;
    170176                }
     
    172178                if (!ofw_pci_apply_ranges(node->parent, &pci_abs_reg,
    173179                    &fb_addr)) {
    174                         printf("Failed to determine screen address.\n");
     180                        log(LF_ARCH, LVL_ERROR,
     181                            "Failed to determine screen address.");
    175182                        return;
    176183                }
     
    196203                        break;
    197204                default:
    198                         printf("Unsupported bits per pixel.\n");
     205                        log(LF_ARCH, LVL_ERROR,
     206                            "Unsupported bits per pixel.");
    199207                        return;
    200208                }
     
    207215                upa_reg = &((ofw_upa_reg_t *) prop->value)[FFB_REG_24BPP];
    208216                if (!ofw_upa_apply_ranges(node->parent, upa_reg, &fb_addr)) {
    209                         printf("Failed to determine screen address.\n");
     217                        log(LF_ARCH, LVL_ERROR,
     218                            "Failed to determine screen address.");
    210219                        return;
    211220                }
     
    219228                        break;
    220229                default:
    221                         printf("Not implemented.\n");
     230                        log(LF_ARCH, LVL_WARN, "Not implemented.");
    222231                        return;
    223232                }
     
    225234                sbus_reg = &((ofw_sbus_reg_t *) prop->value)[0];
    226235                if (!ofw_sbus_apply_ranges(node->parent, sbus_reg, &fb_addr)) {
    227                         printf("Failed to determine screen address.\n");
     236                        log(LF_ARCH, LVL_ERROR,
     237                            "Failed to determine screen address.");
    228238                        return;
    229239                }
     
    233243        case SCR_QEMU_VGA:
    234244                if (prop->size / sizeof(ofw_pci_reg_t) < 2) {
    235                         printf("Too few screen registers.\n");
     245                        log(LF_ARCH, LVL_ERROR, "Too few screen registers.");
    236246                        return;
    237247                }
     
    240250
    241251                if (!ofw_pci_reg_absolutize(node, pci_reg, &pci_abs_reg)) {
    242                         printf("Failed to absolutize fb register.\n");
     252                        log(LF_ARCH, LVL_ERROR,
     253                            "Failed to absolutize fb register.");
    243254                        return;
    244255                }
     
    246257                if (!ofw_pci_apply_ranges(node->parent, &pci_abs_reg,
    247258                    &fb_addr)) {
    248                         printf("Failed to determine screen address.\n");
     259                        log(LF_ARCH, LVL_ERROR,
     260                            "Failed to determine screen address.");
    249261                        return;
    250262                }
     
    268280                        break;
    269281                default:
    270                         printf("Unsupported bits per pixel.\n");
     282                        log(LF_ARCH, LVL_ERROR, "Unsupported bits per pixel.");
    271283                        return;
    272284                }
  • kernel/arch/sparc64/src/mm/sun4u/as.c

    rdba3e2c r8b863a62  
    6363{
    6464#ifdef CONFIG_TSB
    65         /*
    66          * The order must be calculated with respect to the emulated
    67          * 16K page size.
    68          *
    69          */
    70         uint8_t order = fnzb32(((ITSB_ENTRY_COUNT + DTSB_ENTRY_COUNT) *
    71             sizeof(tsb_entry_t)) >> FRAME_WIDTH);
    72        
    73         uintptr_t tsb = (uintptr_t) frame_alloc(order, flags | FRAME_KA);
    74        
    75         if (!tsb)
     65        uintptr_t tsb_phys =
     66            frame_alloc(SIZE2FRAMES((ITSB_ENTRY_COUNT + DTSB_ENTRY_COUNT) *
     67            sizeof(tsb_entry_t)), flags, 0);
     68        if (!tsb_phys)
    7669                return -1;
    7770       
    78         as->arch.itsb = (tsb_entry_t *) tsb;
    79         as->arch.dtsb = (tsb_entry_t *) (tsb + ITSB_ENTRY_COUNT *
     71        tsb_entry_t *tsb = (tsb_entry_t *) PA2KA(tsb_phys);
     72       
     73        as->arch.itsb = tsb;
     74        as->arch.dtsb = tsb + ITSB_ENTRY_COUNT;
     75       
     76        memsetb(as->arch.itsb, (ITSB_ENTRY_COUNT + DTSB_ENTRY_COUNT) *
     77            sizeof(tsb_entry_t), 0);
     78#endif
     79       
     80        return 0;
     81}
     82
     83int as_destructor_arch(as_t *as)
     84{
     85#ifdef CONFIG_TSB
     86        size_t frames = SIZE2FRAMES((ITSB_ENTRY_COUNT + DTSB_ENTRY_COUNT) *
    8087            sizeof(tsb_entry_t));
    81        
    82         memsetb(as->arch.itsb,
    83             (ITSB_ENTRY_COUNT + DTSB_ENTRY_COUNT) * sizeof(tsb_entry_t), 0);
    84 #endif
    85        
    86         return 0;
    87 }
    88 
    89 int as_destructor_arch(as_t *as)
    90 {
    91 #ifdef CONFIG_TSB
    92         /*
    93          * The count must be calculated with respect to the emualted 16K page
    94          * size.
    95          */
    96         size_t cnt = ((ITSB_ENTRY_COUNT + DTSB_ENTRY_COUNT) *
    97             sizeof(tsb_entry_t)) >> FRAME_WIDTH;
    98         frame_free(KA2PA((uintptr_t) as->arch.itsb));
    99        
    100         return cnt;
     88        frame_free(KA2PA((uintptr_t) as->arch.itsb), frames);
     89       
     90        return frames;
    10191#else
    10292        return 0;
  • kernel/arch/sparc64/src/mm/sun4v/as.c

    rdba3e2c r8b863a62  
    6666{
    6767#ifdef CONFIG_TSB
    68         uint8_t order = fnzb32(
    69                 (TSB_ENTRY_COUNT * sizeof(tsb_entry_t)) >> FRAME_WIDTH);
    70        
    71         uintptr_t tsb = (uintptr_t) frame_alloc(order, flags);
    72        
     68        uintptr_t tsb =
     69            frame_alloc(SIZE2FRAMES(TSB_ENTRY_COUNT * sizeof(tsb_entry_t)),
     70            flags, 0);
    7371        if (!tsb)
    7472                return -1;
     
    9290{
    9391#ifdef CONFIG_TSB
    94         size_t cnt = (TSB_ENTRY_COUNT * sizeof(tsb_entry_t)) >> FRAME_WIDTH;
    95         frame_free((uintptr_t) as->arch.tsb_description.tsb_base);
     92        size_t frames = SIZE2FRAMES(TSB_ENTRY_COUNT * sizeof(tsb_entry_t));
     93        frame_free(as->arch.tsb_description.tsb_base, frames);
    9694       
    97         return cnt;
     95        return frames;
    9896#else
    9997        return 0;
  • kernel/arch/sparc64/src/mm/sun4v/frame.c

    rdba3e2c r8b863a62  
    101101         */
    102102        frame_mark_unavailable(ADDR2PFN(KA2PA(PFN2ADDR(0))), 1);
     103
     104        /* PA2KA will work only on low-memory. */
     105        end_of_identity = PA2KA(config.physmem_end - FRAME_SIZE) + PAGE_SIZE;
    103106}
    104107
  • kernel/arch/sparc64/src/mm/sun4v/tlb.c

    rdba3e2c r8b863a62  
    4646#include <arch.h>
    4747#include <print.h>
     48#include <log.h>
    4849#include <typedefs.h>
    4950#include <config.h>
     
    251252        uintptr_t va = DMISS_ADDRESS(page_and_ctx);
    252253        uint16_t ctx = DMISS_CONTEXT(page_and_ctx);
     254        as_t *as = AS;
    253255
    254256        if (ctx == ASID_KERNEL) {
     
    256258                        /* NULL access in kernel */
    257259                        panic("NULL pointer dereference.");
     260                } else if (va >= end_of_identity) {
     261                        /* Kernel non-identity */
     262                        as = AS_KERNEL;
     263                } else {
     264                        panic("Unexpected kernel page fault.");
    258265                }
    259                 panic("Unexpected kernel page fault.");
    260         }
    261 
    262         t = page_mapping_find(AS, va, true);
     266        }
     267
     268        t = page_mapping_find(as, va, true);
    263269        if (t) {
    264270                /*
     
    295301        uintptr_t va = DMISS_ADDRESS(page_and_ctx);
    296302        uint16_t ctx = DMISS_CONTEXT(page_and_ctx);
    297 
    298         t = page_mapping_find(AS, va, true);
     303        as_t *as = AS;
     304
     305        if (ctx == ASID_KERNEL)
     306                as = AS_KERNEL;
     307
     308        t = page_mapping_find(as, va, true);
    299309        if (t && PTE_WRITABLE(t)) {
    300310                /*
     
    326336void tlb_print(void)
    327337{
    328         printf("Operation not possible on Niagara.\n");
     338        log(LF_ARCH, LVL_WARN, "Operation not possible on Niagara.");
    329339}
    330340
  • kernel/arch/sparc64/src/smp/sun4u/smp.c

    rdba3e2c r8b863a62  
    4343#include <typedefs.h>
    4444#include <synch/waitq.h>
    45 #include <print.h>
     45#include <log.h>
    4646#include <arch/cpu_node.h>
    4747
     
    108108        if (waitq_sleep_timeout(&ap_completion_wq, 1000000, SYNCH_FLAGS_NONE) ==
    109109            ESYNCH_TIMEOUT)
    110                 printf("%s: waiting for processor (mid = %" PRIu32
    111                     ") timed out\n", __func__, mid);
     110                log(LF_ARCH, LVL_NOTE, "%s: waiting for processor (mid = %" PRIu32
     111                    ") timed out", __func__, mid);
    112112}
    113113
  • kernel/arch/sparc64/src/sun4v/md.c

    rdba3e2c r8b863a62  
    3636#include <panic.h>
    3737#include <func.h>
    38 #include <print.h>
     38#include <log.h>
    3939#include <str.h>
    4040#include <arch/sun4v/md.h>
     
    310310        retval = retval;
    311311        if (retval != HV_EOK) {
    312                 printf("Could not retrieve machine description, "
    313                     "error=%" PRIu64 ".\n", retval);
     312                log(LF_ARCH, LVL_ERROR, "Could not retrieve machine "
     313                    "description, error=%" PRIu64 ".", retval);
    314314        }
    315315}
  • kernel/arch/sparc64/src/sun4v/start.S

    rdba3e2c r8b863a62  
    345345        .quad 0
    346346
     347/*
     348 * This variable is used by the fast_data_access_MMU_miss trap handler.
     349 * In runtime, it is modified to contain the address of the end of physical
     350 * memory.
     351 */
     352.global end_of_identity
     353end_of_identity:
     354        .quad -1
     355
    347356.global kernel_8k_tlb_data_template
    348357kernel_8k_tlb_data_template:
  • kernel/arch/sparc64/src/trap/sun4u/interrupt.c

    rdba3e2c r8b863a62  
    4242#include <arch/asm.h>
    4343#include <arch/barrier.h>
    44 #include <print.h>
     44#include <log.h>
    4545#include <arch.h>
    4646#include <mm/tlb.h>
     
    9696                 */
    9797#ifdef CONFIG_DEBUG
    98                 printf("cpu%u: spurious interrupt (intrcv=%#" PRIx64
    99                     ", data0=%#" PRIx64 ")\n", CPU->id, intrcv, data0);
     98                log(LF_ARCH, LVL_DEBUG,
     99                    "cpu%u: spurious interrupt (intrcv=%#" PRIx64 ", data0=%#"
     100                    PRIx64 ")", CPU->id, intrcv, data0);
    100101#else
    101102                (void) intrcv;
  • kernel/arch/sparc64/src/trap/sun4v/interrupt.c

    rdba3e2c r8b863a62  
    4242#include <arch/asm.h>
    4343#include <arch/barrier.h>
    44 #include <print.h>
     44#include <log.h>
    4545#include <arch.h>
    4646#include <mm/tlb.h>
     
    111111                        ((void (*)(void)) data1)();
    112112                } else {
    113                         printf("Spurious interrupt on %" PRIu64 ", data = %" PRIx64 ".\n",
    114                             CPU->arch.id, data1);
     113                        log(LF_ARCH, LVL_DEBUG, "Spurious interrupt on %" PRIu64
     114                            ", data = %" PRIx64 ".", CPU->arch.id, data1);
    115115                }
    116116        }
Note: See TracChangeset for help on using the changeset viewer.