Changeset 3e828ea in mainline for kernel/arch


Ignore:
Timestamp:
2019-09-23T12:49:29Z (7 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9be2358
Parents:
9259d20 (diff), 1a4ec93f (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.
git-author:
Jiri Svoboda <jiri@…> (2019-09-22 12:49:07)
git-committer:
Jiri Svoboda <jiri@…> (2019-09-23 12:49:29)
Message:

Merge changes from master, especially Meson build

Location:
kernel/arch
Files:
55 added
6 deleted
58 edited
7 moved

Legend:

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

    r9259d20 r3e828ea  
    3737
    3838#define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH  0
     39#define KERNEL_SEPARATE_PTL0_ARCH           0
    3940
    4041#define KERNEL_ADDRESS_SPACE_START_ARCH  UINT32_C(0x80000000)
  • kernel/arch/abs32le/src/abs32le.c

    r9259d20 r3e828ea  
    126126}
    127127
    128 uintptr_t memcpy_from_uspace(void *dst, const void *uspace_src, size_t size)
     128uintptr_t memcpy_from_uspace(void *dst, uspace_addr_t uspace_src, size_t size)
    129129{
    130130        return 0;
    131131}
    132132
    133 uintptr_t memcpy_to_uspace(void *uspace_dst, const void *src, size_t size)
     133uintptr_t memcpy_to_uspace(uspace_addr_t uspace_dst, const void *src, size_t size)
    134134{
    135135        return 0;
  • kernel/arch/amd64/include/arch/interrupt.h

    r9259d20 r3e828ea  
    6161/* NS16550 at COM1 */
    6262#define IRQ_NS16550   4
    63 #define IRQ_PIC_SPUR 7
     63#define IRQ_PIC0_SPUR 7
    6464#define IRQ_MOUSE     12
     65#define IRQ_PIC1_SPUR 15
    6566
    6667/* This one must have four least significant bits set to ones */
     
    7778#define VECTOR_PF                 (IVT_EXCBASE + EXC_PF)
    7879#define VECTOR_CLK                (IVT_IRQBASE + IRQ_CLK)
    79 #define VECTOR_PIC_SPUR           (IVT_IRQBASE + IRQ_PIC_SPUR)
     80#define VECTOR_PIC0_SPUR          (IVT_IRQBASE + IRQ_PIC0_SPUR)
     81#define VECTOR_PIC1_SPUR          (IVT_IRQBASE + IRQ_PIC1_SPUR)
    8082#define VECTOR_SYSCALL            IVT_FREEBASE
    8183#define VECTOR_TLB_SHOOTDOWN_IPI  (IVT_FREEBASE + 1)
    8284#define VECTOR_DEBUG_IPI          (IVT_FREEBASE + 2)
    8385
    84 extern void (*disable_irqs_function)(uint16_t);
    85 extern void (*enable_irqs_function)(uint16_t);
    86 extern void (*eoi_function)(void);
    87 extern const char *irqs_info;
    88 
    8986extern void interrupt_init(void);
    90 extern void trap_virtual_enable_irqs(uint16_t);
    91 extern void trap_virtual_disable_irqs(uint16_t);
    9287
    9388#endif
  • kernel/arch/amd64/include/arch/mm/as.h

    r9259d20 r3e828ea  
    4040
    4141#define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH  0
     42#define KERNEL_SEPARATE_PTL0_ARCH           0
    4243
    4344#define KERNEL_ADDRESS_SPACE_START_ARCH  UINT64_C(0xffff800000000000)
  • kernel/arch/amd64/include/arch/mm/page.h

    r9259d20 r3e828ea  
    3737
    3838#include <arch/mm/frame.h>
    39 #include <trace.h>
    4039
    4140#define PAGE_WIDTH  FRAME_WIDTH
     
    164163#ifndef __ASSEMBLER__
    165164
     165#include <arch/interrupt.h>
    166166#include <mm/mm.h>
    167 #include <arch/interrupt.h>
     167#include <trace.h>
    168168#include <typedefs.h>
    169169
  • kernel/arch/amd64/src/amd64.c

    r9259d20 r3e828ea  
    6060#include <arch/vreg.h>
    6161#include <arch/kseg.h>
     62#include <genarch/pic/pic_ops.h>
    6263
    6364#ifdef CONFIG_SMP
     
    121122                /* PIC */
    122123                i8259_init((i8259_t *) I8259_PIC0_BASE,
    123                     (i8259_t *) I8259_PIC1_BASE, IRQ_PIC1, IVT_IRQBASE,
    124                     IVT_IRQBASE + 8);
    125 
    126                 /*
    127                  * Set the enable/disable IRQs handlers.
    128                  * Set the End-of-Interrupt handler.
    129                  */
    130                 enable_irqs_function = pic_enable_irqs;
    131                 disable_irqs_function = pic_disable_irqs;
    132                 eoi_function = pic_eoi;
    133                 irqs_info = "i8259";
     124                    (i8259_t *) I8259_PIC1_BASE, IVT_IRQBASE);
     125
     126                /* Set PIC operations. */
     127                pic_ops = &i8259_pic_ops;
    134128        }
    135129}
     
    210204                        indev_t *kbrd = kbrd_wire(kbrd_instance, sink);
    211205                        i8042_wire(i8042_instance, kbrd);
    212                         trap_virtual_enable_irqs(1 << IRQ_KBD);
    213                         trap_virtual_enable_irqs(1 << IRQ_MOUSE);
     206                        pic_ops->enable_irqs(1 << IRQ_KBD);
     207                        pic_ops->enable_irqs(1 << IRQ_MOUSE);
    214208                }
    215209        }
     
    236230                        indev_t *srln = srln_wire(srln_instance, sink);
    237231                        ns16550_wire(ns16550_instance, srln);
    238                         trap_virtual_enable_irqs(1 << IRQ_NS16550);
     232                        pic_ops->enable_irqs(1 << IRQ_NS16550);
    239233                }
    240234#endif
     
    247241#endif
    248242
    249         if (irqs_info != NULL)
    250                 sysinfo_set_item_val(irqs_info, NULL, true);
     243        sysinfo_set_item_val(pic_ops->get_name(), NULL, true);
    251244}
    252245
  • kernel/arch/amd64/src/asm.S

    r9259d20 r3e828ea  
    398398        .asciz "Invalid instruction pointer."
    399399
    400 /** Print Unicode character to EGA display.
    401  *
    402  * If CONFIG_EGA is undefined or CONFIG_FB is defined
    403  * then this function does nothing.
     400/** Print Unicode character to an early display device.
    404401 *
    405402 * Since the EGA can only display Extended ASCII (usually
     
    413410 */
    414411FUNCTION_BEGIN(early_putwchar)
     412
     413#if (defined(CONFIG_L4RE_UVMM_EARLY_PRINT))
     414        xorl %eax, %eax  /* RAX==0: uvmm's print hypercall */
     415        mov %rdi, %rcx   /* RCX:    printed character */
     416        vmcall
     417#endif
     418
    415419#if ((defined(CONFIG_EGA)) && (!defined(CONFIG_FB)))
    416420
  • kernel/arch/amd64/src/debug/stacktrace.c

    r9259d20 r3e828ea  
    6969bool uspace_frame_pointer_prev(stack_trace_context_t *ctx, uintptr_t *prev)
    7070{
    71         return !copy_from_uspace((void *) prev,
    72             (uint64_t *) ctx->fp + FRAME_OFFSET_FP_PREV, sizeof(*prev));
     71        return !copy_from_uspace(prev,
     72            ctx->fp + sizeof(uintptr_t) * FRAME_OFFSET_FP_PREV, sizeof(*prev));
    7373}
    7474
    7575bool uspace_return_address_get(stack_trace_context_t *ctx, uintptr_t *ra)
    7676{
    77         return !copy_from_uspace((void *) ra,
    78             (uint64_t *) ctx->fp + FRAME_OFFSET_RA, sizeof(*ra));
     77        return !copy_from_uspace(ra,
     78            ctx->fp + sizeof(uintptr_t) * FRAME_OFFSET_RA, sizeof(*ra));
    7979}
    8080
  • kernel/arch/amd64/src/interrupt.c

    r9259d20 r3e828ea  
    3838#include <panic.h>
    3939#include <genarch/drivers/i8259/i8259.h>
     40#include <genarch/pic/pic_ops.h>
    4041#include <halt.h>
    4142#include <cpu.h>
     
    5758 * Interrupt and exception dispatching.
    5859 */
    59 
    60 void (*disable_irqs_function)(uint16_t irqmask) = NULL;
    61 void (*enable_irqs_function)(uint16_t irqmask) = NULL;
    62 void (*eoi_function)(void) = NULL;
    63 const char *irqs_info = NULL;
     60pic_ops_t *pic_ops = NULL;
    6461
    6562void istate_decode(istate_t *istate)
     
    8986            "r14=%0#18" PRIx64 "\tr15=%0#18" PRIx64 "\n",
    9087            istate->r12, istate->r13, istate->r14, istate->r15);
    91 }
    92 
    93 static void trap_virtual_eoi(void)
    94 {
    95         if (eoi_function)
    96                 eoi_function();
    97         else
    98                 panic("No eoi_function.");
    99 
    10088}
    10189
     
    157145static void tlb_shootdown_ipi(unsigned int n, istate_t *istate)
    158146{
    159         trap_virtual_eoi();
     147        pic_ops->eoi(0);
    160148        tlb_shootdown_ipi_recv();
    161149}
     
    172160        bool ack = false;
    173161        assert(inum < IRQ_COUNT);
    174         assert((inum != IRQ_PIC_SPUR) && (inum != IRQ_PIC1));
     162        assert(inum != IRQ_PIC1);
    175163
    176164        irq_t *irq = irq_dispatch_and_lock(inum);
     
    182170                if (irq->preack) {
    183171                        /* Send EOI before processing the interrupt */
    184                         trap_virtual_eoi();
     172                        pic_ops->eoi(inum);
    185173                        ack = true;
    186174                }
     
    188176                irq_spinlock_unlock(&irq->lock, false);
    189177        } else {
    190                 /*
    191                  * Spurious interrupt.
    192                  */
    193178#ifdef CONFIG_DEBUG
    194                 log(LF_ARCH, LVL_DEBUG, "cpu%u: spurious interrupt (inum=%u)",
    195                     CPU->id, inum);
     179                log(LF_ARCH, LVL_DEBUG, "cpu%u: unhandled IRQ %u", CPU->id,
     180                    inum);
    196181#endif
    197182        }
    198183
    199184        if (!ack)
    200                 trap_virtual_eoi();
     185                pic_ops->eoi(inum);
     186}
     187
     188static void pic_spurious(unsigned int n, istate_t *istate)
     189{
     190        unsigned int inum = n - IVT_IRQBASE;
     191        if (!pic_ops->is_spurious(inum)) {
     192                /* This is actually not a spurious IRQ, so proceed as usual. */
     193                irq_interrupt(n, istate);
     194                return;
     195        }
     196        pic_ops->handle_spurious(n);
     197#ifdef CONFIG_DEBUG
     198        log(LF_ARCH, LVL_DEBUG, "cpu%u: PIC spurious interrupt %u", CPU->id,
     199            inum);
     200#endif
    201201}
    202202
     
    209209
    210210        for (i = 0; i < IRQ_COUNT; i++) {
    211                 if ((i != IRQ_PIC_SPUR) && (i != IRQ_PIC1))
     211                if ((i != IRQ_PIC0_SPUR) && (i != IRQ_PIC1_SPUR) &&
     212                    (i != IRQ_PIC1))
    212213                        exc_register(IVT_IRQBASE + i, "irq", true,
    213214                            (iroutine_t) irq_interrupt);
     
    218219        exc_register(VECTOR_SS, "ss_fault", true, (iroutine_t) ss_fault);
    219220        exc_register(VECTOR_GP, "gp_fault", true, (iroutine_t) gp_fault);
     221        exc_register(VECTOR_PIC0_SPUR, "pic0_spurious", true,
     222            (iroutine_t) pic_spurious);
     223        exc_register(VECTOR_PIC1_SPUR, "pic1_spurious", true,
     224            (iroutine_t) pic_spurious);
    220225
    221226#ifdef CONFIG_SMP
     
    225230}
    226231
    227 void trap_virtual_enable_irqs(uint16_t irqmask)
    228 {
    229         if (enable_irqs_function)
    230                 enable_irqs_function(irqmask);
    231         else
    232                 panic("No enable_irqs_function.");
    233 }
    234 
    235 void trap_virtual_disable_irqs(uint16_t irqmask)
    236 {
    237         if (disable_irqs_function)
    238                 disable_irqs_function(irqmask);
    239         else
    240                 panic("No disable_irqs_function.");
    241 }
    242 
    243232/** @}
    244233 */
  • kernel/arch/amd64/src/userspace.c

    r9259d20 r3e828ea  
    6666            "iretq\n"
    6767            :: [udata_des] "i" (GDT_SELECTOR(UDATA_DES) | PL_USER),
    68               [stack_top] "r" ((uint8_t *) kernel_uarg->uspace_stack +
     68              [stack_top] "r" (kernel_uarg->uspace_stack +
    6969              kernel_uarg->uspace_stack_size),
    7070              [rflags] "r" (rflags),
  • kernel/arch/arm32/include/arch/mm/as.h

    r9259d20 r3e828ea  
    3838
    3939#define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH  0
     40#define KERNEL_SEPARATE_PTL0_ARCH           0
    4041
    4142#define KERNEL_ADDRESS_SPACE_START_ARCH  UINT32_C(0x80000000)
  • kernel/arch/arm32/src/debug/stacktrace.c

    r9259d20 r3e828ea  
    6868bool uspace_frame_pointer_prev(stack_trace_context_t *ctx, uintptr_t *prev)
    6969{
    70         return !copy_from_uspace((void *) prev,
    71             (uint32_t *) ctx->fp + FRAME_OFFSET_FP_PREV, sizeof(*prev));
     70        return !copy_from_uspace(prev,
     71            ctx->fp + sizeof(uintptr_t) * FRAME_OFFSET_FP_PREV, sizeof(*prev));
    7272}
    7373
    7474bool uspace_return_address_get(stack_trace_context_t *ctx, uintptr_t *ra)
    7575{
    76         return !copy_from_uspace((void *) ra,
    77             (uint32_t *) ctx->fp + FRAME_OFFSET_RA, sizeof(*ra));
     76        return !copy_from_uspace(ra,
     77            ctx->fp + sizeof(uintptr_t) * FRAME_OFFSET_RA, sizeof(*ra));
    7878}
    7979
  • kernel/arch/arm32/src/userspace.c

    r9259d20 r3e828ea  
    7171
    7272        /* set first parameter */
    73         ustate.r0 = (uintptr_t) kernel_uarg->uspace_uarg;
     73        ustate.r0 = kernel_uarg->uspace_uarg;
    7474
    7575        /* %r1 is defined to hold pcb_ptr - set it to 0 */
     
    9393
    9494        /* set user stack */
    95         ustate.sp = ((uint32_t) kernel_uarg->uspace_stack) +
     95        ustate.sp = kernel_uarg->uspace_stack +
    9696            kernel_uarg->uspace_stack_size;
    9797
    9898        /* set where uspace execution starts */
    99         ustate.pc = (uintptr_t) kernel_uarg->uspace_entry;
     99        ustate.pc = kernel_uarg->uspace_entry;
    100100
    101101        /* status register in user mode */
  • kernel/arch/arm64/include/arch/context_struct.h

    r9259d20 r3e828ea  
    11/*
    2  * Copyright (c) 2018 Jaroslav Jindrak
    3  * All rights reserved.
     2 * Copyright (c) 2015 Petr Pavlu
     3 * All rights preserved.
    44 *
    55 * Redistribution and use in source and binary forms, with or without
     
    2727 */
    2828
    29 #ifndef LIBCPP_BITS_RESULT_OF
    30 #define LIBCPP_BITS_RESULT_OF
     29#ifndef KERN_ARCH_CONTEXT_STRUCT_H_
     30#define KERN_ARCH_CONTEXT_STRUCT_H_
    3131
    32 /**
    33  * TODO: We have two implementations and I can't remember which
    34  *       one is the correnct one, investigate!
     32#define CONTEXT_OFFSET_SP   0x00
     33#define CONTEXT_OFFSET_PC   0x08
     34#define CONTEXT_OFFSET_X19  0x10
     35#define CONTEXT_OFFSET_X20  0x18
     36#define CONTEXT_OFFSET_X21  0x20
     37#define CONTEXT_OFFSET_X22  0x28
     38#define CONTEXT_OFFSET_X23  0x30
     39#define CONTEXT_OFFSET_X24  0x38
     40#define CONTEXT_OFFSET_X25  0x40
     41#define CONTEXT_OFFSET_X26  0x48
     42#define CONTEXT_OFFSET_X27  0x50
     43#define CONTEXT_OFFSET_X28  0x58
     44#define CONTEXT_OFFSET_X29  0x60
     45#define CONTEXT_OFFSET_IPL  0x68
     46#define CONTEXT_SIZE        0x70
     47
     48#ifndef __ASSEMBLER__
     49
     50#include <typedefs.h>
     51
     52/*
     53 * Thread context containing registers that must be preserved across function
     54 * calls.
    3555 */
    36 #include <__bits/invoke.hpp>
    37 
    38 namespace std
    39 {
    40     /**
    41      * Note: This doesn't work, C++14 standard allows for F
    42      *       to be any complete type, our implementation
    43      *       currently works like the C++11 version where
    44      *       F has to be callable.
    45      * TODO: Fix this.
    46      */
    47 
    48     template<class>
    49     struct result_of;
    50 
    51     template<class F, class... Args>
    52     class result_of<F(Args...)>: aux::type_is<
    53         decltype(aux::invoke(declval<F>(), declval<ArgTypes>()...))
    54     >
    55     { /* DUMMY BODY */ };
    56 
    57     template<class T>
    58     using result_of_t = typename result_of<T>::type;
    59 }
     56typedef struct context {
     57        uint64_t sp;
     58        uint64_t pc;
     59        uint64_t x19;
     60        uint64_t x20;
     61        uint64_t x21;
     62        uint64_t x22;
     63        uint64_t x23;
     64        uint64_t x24;
     65        uint64_t x25;
     66        uint64_t x26;
     67        uint64_t x27;
     68        uint64_t x28;
     69        uint64_t x29;
     70        ipl_t ipl;
     71} context_t;
    6072
    6173#endif
     74#endif
  • kernel/arch/arm64/include/arch/types.h

    r9259d20 r3e828ea  
    11/*
    2  * Copyright (c) 2012 Petr Koupy
     2 * Copyright (c) 2015 Petr Pavlu
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup draw
     29/** @addtogroup kernel_arm64
    3030 * @{
    3131 */
    32 /**
    33  * @file
     32/** @file
    3433 */
    3534
    36 #ifndef DRAW_CURSOR_EMBEDDED_H_
    37 #define DRAW_CURSOR_EMBEDDED_H_
     35#ifndef KERN_arm64_TYPES_H_
     36#define KERN_arm64_TYPES_H_
    3837
    39 #include "../cursor.h"
     38#include <_bits/all.h>
    4039
    41 extern cursor_decoder_t cd_embedded;
     40typedef struct {
     41} fncptr_t;
    4242
    4343#endif
  • kernel/arch/ia32/include/arch/interrupt.h

    r9259d20 r3e828ea  
    6363/* NS16550 at COM1 */
    6464#define IRQ_NS16550   4
    65 #define IRQ_PIC_SPUR 7
     65#define IRQ_PIC0_SPUR 7
    6666#define IRQ_MOUSE     12
     67#define IRQ_PIC1_SPUR 15
    6768
    6869/* This one must have four least significant bits set to ones */
     
    8182#define VECTOR_XM                 (IVT_EXCBASE + EXC_XM)
    8283#define VECTOR_CLK                (IVT_IRQBASE + IRQ_CLK)
    83 #define VECTOR_PIC_SPUR           (IVT_IRQBASE + IRQ_PIC_SPUR)
     84#define VECTOR_PIC0_SPUR          (IVT_IRQBASE + IRQ_PIC0_SPUR)
     85#define VECTOR_PIC1_SPUR          (IVT_IRQBASE + IRQ_PIC1_SPUR)
    8486#define VECTOR_SYSCALL            IVT_FREEBASE
    8587#define VECTOR_TLB_SHOOTDOWN_IPI  (IVT_FREEBASE + 1)
    8688#define VECTOR_DEBUG_IPI          (IVT_FREEBASE + 2)
    8789
    88 extern void (*disable_irqs_function)(uint16_t);
    89 extern void (*enable_irqs_function)(uint16_t);
    90 extern void (*eoi_function)(void);
    91 extern const char *irqs_info;
    92 
    9390extern void interrupt_init(void);
    94 extern void trap_virtual_enable_irqs(uint16_t);
    95 extern void trap_virtual_disable_irqs(uint16_t);
    9691
    9792#endif
  • kernel/arch/ia32/include/arch/mm/as.h

    r9259d20 r3e828ea  
    3737
    3838#define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH  0
     39#define KERNEL_SEPARATE_PTL0_ARCH           0
    3940
    4041#define KERNEL_ADDRESS_SPACE_START_ARCH  UINT32_C(0x80000000)
  • kernel/arch/ia32/include/arch/mm/page.h

    r9259d20 r3e828ea  
    3838#include <arch/mm/frame.h>
    3939#include <stdbool.h>
    40 #include <trace.h>
    4140
    4241#define PAGE_WIDTH  FRAME_WIDTH
     
    147146#include <arch/interrupt.h>
    148147#include <stddef.h>
     148#include <trace.h>
    149149
    150150/* Page fault error codes. */
  • kernel/arch/ia32/include/arch/smp/apic.h

    r9259d20 r3e828ea  
    4343#include <cpu.h>
    4444#include <stdint.h>
     45#include <genarch/pic/pic_ops.h>
    4546
    4647#define FIXED  (0 << 0)
     
    347348} io_apic_id_t;
    348349
     350extern pic_ops_t apic_pic_ops;
     351
    349352extern volatile uint32_t *l_apic;
    350353extern volatile uint32_t *io_apic;
     
    356359
    357360extern void l_apic_init(void);
    358 extern void l_apic_eoi(void);
     361extern void l_apic_eoi(unsigned int);
    359362extern int l_apic_send_custom_ipi(uint8_t, uint8_t);
    360363extern int l_apic_broadcast_custom_ipi(uint8_t);
  • kernel/arch/ia32/src/debug/stacktrace.c

    r9259d20 r3e828ea  
    6767bool uspace_frame_pointer_prev(stack_trace_context_t *ctx, uintptr_t *prev)
    6868{
    69         return !copy_from_uspace((void *) prev,
    70             (uint32_t *) ctx->fp + FRAME_OFFSET_FP_PREV, sizeof(*prev));
     69        return !copy_from_uspace(prev,
     70            ctx->fp + sizeof(uintptr_t) * FRAME_OFFSET_FP_PREV, sizeof(*prev));
    7171}
    7272
    7373bool uspace_return_address_get(stack_trace_context_t *ctx, uintptr_t *ra)
    7474{
    75         return !copy_from_uspace((void *) ra,
    76             (uint32_t *) ctx->fp + FRAME_OFFSET_RA, sizeof(*ra));
     75        return !copy_from_uspace(ra,
     76            ctx->fp + sizeof(uintptr_t) * FRAME_OFFSET_RA, sizeof(*ra));
    7777}
    7878
  • kernel/arch/ia32/src/drivers/i8254.c

    r9259d20 r3e828ea  
    9696{
    9797        pio_write_8(CLK_PORT4, 0x36);
    98         pic_disable_irqs(1 << IRQ_CLK);
     98        i8259_disable_irqs(1 << IRQ_CLK);
    9999        pio_write_8(CLK_PORT1, (CLK_CONST / HZ) & 0xf);
    100100        pio_write_8(CLK_PORT1, (CLK_CONST / HZ) >> 8);
    101         pic_enable_irqs(1 << IRQ_CLK);
     101        i8259_enable_irqs(1 << IRQ_CLK);
    102102}
    103103
     
    143143        o2 |= pio_read_8(CLK_PORT1) << 8;
    144144
     145        uint32_t delta = (t1 - t2) - (o1 - o2);
     146        if (!delta)
     147                delta = 1;
     148
    145149        CPU->delay_loop_const =
    146             ((MAGIC_NUMBER * LOOPS) / 1000) / ((t1 - t2) - (o1 - o2)) +
    147             (((MAGIC_NUMBER * LOOPS) / 1000) % ((t1 - t2) - (o1 - o2)) ? 1 : 0);
     150            ((MAGIC_NUMBER * LOOPS) / 1000) / delta +
     151            (((MAGIC_NUMBER * LOOPS) / 1000) % delta ? 1 : 0);
    148152
    149153        uint64_t clk1 = get_cycle();
  • kernel/arch/ia32/src/ia32.c

    r9259d20 r3e828ea  
    5858#include <genarch/multiboot/multiboot.h>
    5959#include <genarch/multiboot/multiboot2.h>
     60#include <genarch/pic/pic_ops.h>
    6061#include <arch/pm.h>
    6162#include <arch/vreg.h>
     
    110111                /* PIC */
    111112                i8259_init((i8259_t *) I8259_PIC0_BASE,
    112                     (i8259_t *) I8259_PIC1_BASE, IRQ_PIC1, IVT_IRQBASE,
    113                     IVT_IRQBASE + 8);
    114 
    115                 /*
    116                  * Set the enable/disable IRQs handlers.
    117                  * Set the End-of-Interrupt handler.
    118                  */
    119                 enable_irqs_function = pic_enable_irqs;
    120                 disable_irqs_function = pic_disable_irqs;
    121                 eoi_function = pic_eoi;
    122                 irqs_info = "i8259";
     113                    (i8259_t *) I8259_PIC1_BASE, IVT_IRQBASE);
     114
     115                /* Set PIC operations. */
     116                pic_ops = &i8259_pic_ops;
    123117        }
    124118}
     
    195189                        indev_t *kbrd = kbrd_wire(kbrd_instance, sink);
    196190                        i8042_wire(i8042_instance, kbrd);
    197                         trap_virtual_enable_irqs(1 << IRQ_KBD);
    198                         trap_virtual_enable_irqs(1 << IRQ_MOUSE);
     191                        pic_ops->enable_irqs(1 << IRQ_KBD);
     192                        pic_ops->enable_irqs(1 << IRQ_MOUSE);
    199193                }
    200194        }
     
    221215                        indev_t *srln = srln_wire(srln_instance, sink);
    222216                        ns16550_wire(ns16550_instance, srln);
    223                         trap_virtual_enable_irqs(1 << IRQ_NS16550);
     217                        pic_ops->enable_irqs(1 << IRQ_NS16550);
    224218                }
    225219#endif
     
    232226#endif
    233227
    234         if (irqs_info != NULL)
    235                 sysinfo_set_item_val(irqs_info, NULL, true);
     228        sysinfo_set_item_val(pic_ops->get_name(), NULL, true);
    236229}
    237230
  • kernel/arch/ia32/src/interrupt.c

    r9259d20 r3e828ea  
    4040#include <panic.h>
    4141#include <genarch/drivers/i8259/i8259.h>
     42#include <genarch/pic/pic_ops.h>
    4243#include <halt.h>
    4344#include <cpu.h>
     
    6162 */
    6263
    63 void (*disable_irqs_function)(uint16_t irqmask) = NULL;
    64 void (*enable_irqs_function)(uint16_t irqmask) = NULL;
    65 void (*eoi_function)(void) = NULL;
    66 const char *irqs_info = NULL;
     64pic_ops_t *pic_ops = NULL;
    6765
    6866void istate_decode(istate_t *istate)
     
    8886            istate_from_uspace(istate) ? istate->esp :
    8987            (uint32_t) &istate->esp);
    90 }
    91 
    92 static void trap_virtual_eoi(void)
    93 {
    94         if (eoi_function)
    95                 eoi_function();
    96         else
    97                 panic("No eoi_function.");
    98 
    9988}
    10089
     
    179168    istate_t *istate __attribute__((unused)))
    180169{
    181         trap_virtual_eoi();
     170        pic_ops->eoi(0);
    182171        tlb_shootdown_ipi_recv();
    183172}
     
    192181        bool ack = false;
    193182        assert(inum < IRQ_COUNT);
    194         assert((inum != IRQ_PIC_SPUR) && (inum != IRQ_PIC1));
     183        assert(inum != IRQ_PIC1);
    195184
    196185        irq_t *irq = irq_dispatch_and_lock(inum);
     
    202191                if (irq->preack) {
    203192                        /* Send EOI before processing the interrupt */
    204                         trap_virtual_eoi();
     193                        pic_ops->eoi(inum);
    205194                        ack = true;
    206195                }
     
    208197                irq_spinlock_unlock(&irq->lock, false);
    209198        } else {
    210                 /*
    211                  * Spurious interrupt.
    212                  */
    213199#ifdef CONFIG_DEBUG
    214                 printf("cpu%u: spurious interrupt (inum=%u)\n", CPU->id, inum);
     200                log(LF_ARCH, LVL_DEBUG, "cpu%u: unhandled IRQ %u", CPU->id,
     201                    inum);
    215202#endif
    216203        }
    217204
    218205        if (!ack)
    219                 trap_virtual_eoi();
     206                pic_ops->eoi(inum);
     207}
     208
     209static void pic_spurious(unsigned int n, istate_t *istate)
     210{
     211        unsigned int inum = n - IVT_IRQBASE;
     212        if (!pic_ops->is_spurious(inum)) {
     213                /* This is actually not a spurious IRQ, so proceed as usual. */
     214                irq_interrupt(n, istate);
     215                return;
     216        }
     217        pic_ops->handle_spurious(n);
     218#ifdef CONFIG_DEBUG
     219        log(LF_ARCH, LVL_DEBUG, "cpu%u: PIC spurious interrupt %u", CPU->id,
     220            inum);
     221#endif
    220222}
    221223
     
    228230
    229231        for (i = 0; i < IRQ_COUNT; i++) {
    230                 if ((i != IRQ_PIC_SPUR) && (i != IRQ_PIC1))
     232                if ((i != IRQ_PIC0_SPUR) && (i != IRQ_PIC1_SPUR) &&
     233                    (i != IRQ_PIC1))
    231234                        exc_register(IVT_IRQBASE + i, "irq", true,
    232235                            (iroutine_t) irq_interrupt);
     
    239242        exc_register(VECTOR_GP, "gp_fault", true, (iroutine_t) gp_fault);
    240243        exc_register(VECTOR_XM, "simd_fp", true, (iroutine_t) simd_fp_exception);
     244        exc_register(VECTOR_PIC0_SPUR, "pic0_spurious", true,
     245            (iroutine_t) pic_spurious);
     246        exc_register(VECTOR_PIC1_SPUR, "pic1_spurious", true,
     247            (iroutine_t) pic_spurious);
    241248
    242249#ifdef CONFIG_SMP
     
    246253}
    247254
    248 void trap_virtual_enable_irqs(uint16_t irqmask)
    249 {
    250         if (enable_irqs_function)
    251                 enable_irqs_function(irqmask);
    252         else
    253                 panic("No enable_irqs_function.");
    254 }
    255 
    256 void trap_virtual_disable_irqs(uint16_t irqmask)
    257 {
    258         if (disable_irqs_function)
    259                 disable_irqs_function(irqmask);
    260         else
    261                 panic("No disable_irqs_function.");
    262 }
    263 
    264255/** @}
    265256 */
  • kernel/arch/ia32/src/smp/apic.c

    r9259d20 r3e828ea  
    4747#include <arch.h>
    4848#include <ddi/irq.h>
     49#include <genarch/pic/pic_ops.h>
    4950
    5051#ifdef CONFIG_SMP
     
    6364 */
    6465
     66static const char *apic_get_name(void);
     67static bool l_apic_is_spurious(unsigned int);
     68static void l_apic_handle_spurious(unsigned int);
     69
     70pic_ops_t apic_pic_ops = {
     71        .get_name = apic_get_name,
     72        .enable_irqs = io_apic_enable_irqs,
     73        .disable_irqs = io_apic_disable_irqs,
     74        .eoi = l_apic_eoi,
     75        .is_spurious = l_apic_is_spurious,
     76        .handle_spurious = l_apic_handle_spurious,
     77};
     78
    6579/*
    6680 * These variables either stay configured as initilalized, or are changed by
     
    125139#endif /* LAPIC_VERBOSE */
    126140
     141const char *apic_get_name(void)
     142{
     143        return "apic";
     144}
     145
     146bool l_apic_is_spurious(unsigned int n)
     147{
     148        return n == VECTOR_APIC_SPUR;
     149}
     150
     151void l_apic_handle_spurious(unsigned int n)
     152{
     153}
     154
    127155/** APIC spurious interrupt handler.
    128156 *
     
    134162    istate_t *istate __attribute__((unused)))
    135163{
    136 #ifdef CONFIG_DEBUG
    137         log(LF_ARCH, LVL_DEBUG, "cpu%u: APIC spurious interrupt", CPU->id);
    138 #endif
    139164}
    140165
     
    175200            (iroutine_t) apic_spurious);
    176201
    177         enable_irqs_function = io_apic_enable_irqs;
    178         disable_irqs_function = io_apic_disable_irqs;
    179         eoi_function = l_apic_eoi;
    180         irqs_info = "apic";
     202        pic_ops = &apic_pic_ops;
    181203
    182204        /*
     
    508530
    509531/** Local APIC End of Interrupt. */
    510 void l_apic_eoi(void)
     532void l_apic_eoi(unsigned int ignored)
    511533{
    512534        l_apic[EOI] = 0;
  • kernel/arch/ia32/src/smp/smp.c

    r9259d20 r3e828ea  
    130130        pio_write_8((ioport8_t *) 0x71, 0xa);
    131131
    132         pic_disable_irqs(0xffff);
     132        i8259_disable_irqs(0xffff);
    133133        apic_init();
    134134
  • kernel/arch/ia32/src/userspace.c

    r9259d20 r3e828ea  
    7070            : [eflags_mask] "i" (~EFLAGS_NT),
    7171              [udata_des] "i" (GDT_SELECTOR(UDATA_DES) | PL_USER),
    72               [stack_top] "r" ((uint8_t *) kernel_uarg->uspace_stack +
     72              [stack_top] "r" (kernel_uarg->uspace_stack +
    7373              kernel_uarg->uspace_stack_size),
    7474              [eflags] "r" ((eflags & ~(EFLAGS_NT)) | EFLAGS_IF),
  • kernel/arch/ia64/include/arch/interrupt.h

    r9259d20 r3e828ea  
    9292extern void disabled_fp_register(unsigned int, istate_t *);
    9393
    94 extern void trap_virtual_enable_irqs(uint16_t);
    95 
    9694void exception_init(void);
    9795#endif
  • kernel/arch/ia64/include/arch/istate.h

    r9259d20 r3e828ea  
    7171_NO_TRACE static inline int istate_from_uspace(istate_t *istate)
    7272{
    73         return (istate->cr_iip) < 0xe000000000000000ULL;
     73        return istate->cr_ipsr.cpl == PSR_CPL_USER;
    7474}
    7575
  • kernel/arch/ia64/include/arch/mm/as.h

    r9259d20 r3e828ea  
    3737
    3838#define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH  0
     39#define KERNEL_SEPARATE_PTL0_ARCH           0
    3940
    4041#define KERNEL_ADDRESS_SPACE_START_ARCH  UINT64_C(0xe000000000000000)
  • kernel/arch/ia64/include/arch/mm/page.h

    r9259d20 r3e828ea  
    3838
    3939#include <arch/mm/frame.h>
     40#include <arch/register.h>
    4041
    4142#ifndef __ASSEMBLER__
     
    7677
    7778/** Privilege Levels. Only the most and the least privileged ones are ever used. */
    78 #define PL_KERNEL  0x00
    79 #define PL_USER    0x03
     79#define PL_KERNEL  PSR_CPL_KERNEL
     80#define PL_USER    PSR_CPL_USER
    8081
    8182/* Access Rigths. Only certain combinations are used by the kernel. */
  • kernel/arch/ia64/include/arch/register.h

    r9259d20 r3e828ea  
    5757#define PSR_RT_MASK   (1 << 27)
    5858#define PSR_IT_MASK   (1 << 36)
     59
     60#define PSR_CPL_USER   3
     61#define PSR_CPL_KERNEL 0
    5962
    6063#define PSR_CPL_SHIFT         32
  • kernel/arch/ia64/src/ia64.c

    r9259d20 r3e828ea  
    244244         * uspace_stack_size / 2 bytes.
    245245         */
    246         switch_to_userspace((uintptr_t) kernel_uarg->uspace_entry,
    247             ((uintptr_t) kernel_uarg->uspace_stack) +
     246        switch_to_userspace(kernel_uarg->uspace_entry,
     247            kernel_uarg->uspace_stack +
    248248            kernel_uarg->uspace_stack_size / 2 -
    249249            ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT),
    250             ((uintptr_t) kernel_uarg->uspace_stack) +
     250            kernel_uarg->uspace_stack +
    251251            kernel_uarg->uspace_stack_size / 2,
    252             (uintptr_t) kernel_uarg->uspace_uarg, psr.value, rsc.value);
     252            kernel_uarg->uspace_uarg, psr.value, rsc.value);
    253253
    254254        while (true)
  • kernel/arch/ia64/src/interrupt.c

    r9259d20 r3e828ea  
    301301}
    302302
    303 void trap_virtual_enable_irqs(uint16_t irqmask)
    304 {
    305 }
    306 
    307303void exception_init(void)
    308304{
  • kernel/arch/ia64/src/mm/tlb.c

    r9259d20 r3e828ea  
    464464}
    465465
    466 static bool is_kernel_fault(uintptr_t va)
     466static bool is_kernel_fault(istate_t *istate, uintptr_t va)
    467467{
    468468        region_register_t rr;
     469
     470        if (istate_from_uspace(istate))
     471                return false;
    469472
    470473        rr.word = rr_read(VA2VRN(va));
     
    484487        pte_t t;
    485488
     489        assert(istate_from_uspace(istate));
     490
    486491        va = istate->cr_ifa; /* faulting address */
    487 
    488         assert(!is_kernel_fault(va));
    489492
    490493        bool found = page_mapping_find(AS, va, true, &t);
     
    587590        as_t *as = AS;
    588591
    589         if (is_kernel_fault(va)) {
     592        if (is_kernel_fault(istate, va)) {
    590593                if (va < end_of_identity) {
    591594                        /*
     
    648651        va = istate->cr_ifa;  /* faulting address */
    649652
    650         if (is_kernel_fault(va))
     653        if (is_kernel_fault(istate, va))
    651654                as = AS_KERNEL;
    652655
     
    680683        pte_t t;
    681684
     685        assert(istate_from_uspace(istate));
     686
    682687        va = istate->cr_ifa;  /* faulting address */
    683 
    684         assert(!is_kernel_fault(va));
    685688
    686689        bool found = page_mapping_find(AS, va, true, &t);
     
    716719        va = istate->cr_ifa;  /* faulting address */
    717720
    718         if (is_kernel_fault(va))
     721        if (is_kernel_fault(istate, va))
    719722                as = AS_KERNEL;
    720723
     
    752755        pte_t t;
    753756
     757        assert(istate_from_uspace(istate));
     758
    754759        va = istate->cr_ifa;  /* faulting address */
    755 
    756         assert(!is_kernel_fault(va));
    757760
    758761        /*
     
    779782        pte_t t;
    780783
     784        assert(istate_from_uspace(istate));
     785
    781786        va = istate->cr_ifa;  /* faulting address */
    782 
    783         assert(!is_kernel_fault(va));
    784787
    785788        bool found = page_mapping_find(AS, va, true, &t);
  • kernel/arch/mips32/include/arch/arch.h

    r9259d20 r3e828ea  
    4242#define CPUMAP_MAX_RECORDS         32
    4343#define BOOTINFO_TASK_NAME_BUFLEN  32
     44#define BOOTINFO_BOOTARGS_BUFLEN   256
    4445
    4546extern size_t cpu_count;
     
    6667        uint32_t cpumap;
    6768        taskmap_t taskmap;
     69        char bootargs[BOOTINFO_BOOTARGS_BUFLEN];
    6870} bootinfo_t;
    6971
  • kernel/arch/mips32/include/arch/exception.h

    r9259d20 r3e828ea  
    5757#define EXC_VCED   31
    5858
     59#define INT_SW0    0
     60#define INT_SW1    1
     61#define INT_HW0    2
     62#define INT_HW1    3
     63#define INT_HW2    4
     64#define INT_HW3    5
     65#define INT_HW4    6
     66#define INT_TIMER  7
     67
     68#define MIPS_INTERRUPTS    8
     69#define HW_INTERRUPTS      (MIPS_INTERRUPTS - 3)
     70
     71typedef void (*int_handler_t)(unsigned int);
     72extern int_handler_t int_handler[];
     73
    5974extern void exception(istate_t *istate);
    6075extern void tlb_refill_entry(void);
  • kernel/arch/mips32/include/arch/mach/malta/malta.h

    r9259d20 r3e828ea  
    3939#include <arch/machine_func.h>
    4040#include <arch/mm/page.h>
     41#include <typedefs.h>
    4142
    42 #define MALTA_PCI_BASE          PA2KSEG1(0x18000000UL)
     43#define MALTA_PCI_PHYSBASE      0x18000000UL
     44
     45#define MALTA_PCI_BASE          PA2KSEG1(MALTA_PCI_PHYSBASE)
    4346#define MALTA_GT64120_BASE      PA2KSEG1(0x1be00000UL)
    4447
     
    4649#define PIC1_BASE               (MALTA_PCI_BASE + 0xa0)
    4750
    48 #define TTY_BASE                (MALTA_PCI_BASE + 0x3f8)
    49 #define TTY_CPU_INT             2
     51#define ISA_IRQ_COUNT           16
     52
     53#define TTY_BASE                (MALTA_PCI_PHYSBASE + 0x3f8)
    5054#define TTY_ISA_IRQ             4
    5155
    52 #define GT64120_PCI0_INTACK     (MALTA_GT64120_BASE + 0xc34)
     56#define GT64120_PCI0_INTACK     ((ioport32_t *) (MALTA_GT64120_BASE + 0xc34))
    5357
    5458extern struct mips32_machine_ops malta_machine_ops;
  • kernel/arch/mips32/include/arch/machine_func.h

    r9259d20 r3e828ea  
    4343
    4444#include <typedefs.h>
     45#include <stdbool.h>
    4546
    4647struct mips32_machine_ops {
  • kernel/arch/mips32/include/arch/mm/as.h

    r9259d20 r3e828ea  
    3737
    3838#define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH  0
     39#define KERNEL_SEPARATE_PTL0_ARCH           0
    3940
    4041#define KERNEL_ADDRESS_SPACE_START_ARCH  UINT32_C(0x80000000)
  • kernel/arch/mips32/meson.build

    r9259d20 r3e828ea  
    11#
    22# Copyright (c) 2005 Martin Decky
    3 # Copyright (c) 2007 Jakub Jermar
    43# All rights reserved.
    54#
     
    2827#
    2928
    30 USPACE_PREFIX = ../..
    31 ROOT_PATH = $(USPACE_PREFIX)/..
    32 CONFIG_MAKEFILE = $(ROOT_PATH)/Makefile.config
     29arch_src += files(
     30        'src/start.S',
     31        'src/context.S',
     32        'src/mips32.c',
     33        'src/asm.S',
     34        'src/exception.c',
     35        'src/interrupt.c',
     36        'src/cache.c',
     37        'src/debugger.c',
     38        'src/cpu/cpu.c',
     39        'src/debug/stacktrace.c',
     40        'src/debug/stacktrace_asm.S',
     41        'src/mm/km.c',
     42        'src/mm/frame.c',
     43        'src/mm/page.c',
     44        'src/mm/tlb.c',
     45        'src/mm/as.c',
     46        'src/fpu_context.c',
     47        'src/smc.c',
     48        'src/smp/smp.c',
     49        'src/machine_func.c',
     50)
    3351
    34 include $(CONFIG_MAKEFILE)
     52if MACHINE == 'lmalta' or MACHINE == 'bmalta'
     53        arch_src += files('src/mach/malta/malta.c')
    3554
    36 ifeq ($(UARCH),ia64)
    37         # IA64 has a peculiar linker script with a fixed data segment address.
    38         # Because the loader is a separate nonrelocatable binary in the same
    39         # address space as the application, we provide a modified copy of
    40         # the default linker script to work around that.
    41         EXTRA_LDFLAGS = -T elf64_ia64_loader.x
    42 else
    43         # On all other architectures, we can simply move the text segment.
    44         EXTRA_LDFLAGS = -Wl,-Ttext-segment=0x70000000
     55elif MACHINE == 'msim'
     56        arch_src += files(
     57                'src/mach/msim/msim.c',
     58                'src/mach/msim/dorder.c',
     59        )
     60
    4561endif
    4662
    47 BINARY = loader
    48 STATIC_ONLY = y
    4963
    50 GENERIC_SOURCES = \
    51         main.c
     64_check_headers = [
     65        'include/arch/istate_struct.h',
     66        'include/arch/context_struct.h',
     67        'include/arch/fpu_context_struct.h',
     68]
    5269
    53 SOURCES = \
    54         $(GENERIC_SOURCES) \
    55         $(ARCH_SOURCES)
    56 
    57 include $(USPACE_PREFIX)/Makefile.common
     70foreach h : _check_headers
     71        arch_src += [ autocheck.process(h) ]
     72endforeach
  • kernel/arch/mips32/src/exception.c

    r9259d20 r3e828ea  
    4747#include <symtab.h>
    4848#include <log.h>
     49#include <arch/machine_func.h>
    4950
    5051static const char *exctable[] = {
     
    174175
    175176        unsigned int i;
    176         for (i = 0; i < 8; i++) {
     177        for (i = 0; i < MIPS_INTERRUPTS; i++) {
    177178
    178179                /*
     
    183184                 */
    184185                if (im & ip & (1 << i)) {
    185                         irq_t *irq = irq_dispatch_and_lock(i);
    186                         if (irq) {
    187                                 /*
    188                                  * The IRQ handler was found.
    189                                  */
    190                                 irq->handler(irq);
    191                                 if (irq->cir)
    192                                         irq->cir(irq->cir_arg, i);
    193                                 irq_spinlock_unlock(&irq->lock, false);
    194                         } else {
     186                        if (int_handler[i])
     187                                int_handler[i](i);
     188                        else {
    195189                                /*
    196190                                 * Spurious interrupt.
  • kernel/arch/mips32/src/interrupt.c

    r9259d20 r3e828ea  
    4141#include <ipc/sysipc.h>
    4242
    43 #define IRQ_COUNT   8
    44 #define TIMER_IRQ   7
    45 
    46 function virtual_timer_fnc = NULL;
    47 static irq_t timer_irq;
    48 
    4943// TODO: This is SMP unsafe!!!
    5044
     
    5246static unsigned long nextcount;
    5347static unsigned long lastcount;
     48
     49/** Table of interrupt handlers. */
     50int_handler_t int_handler[MIPS_INTERRUPTS] = { };
    5451
    5552/** Disable interrupts.
     
    113110}
    114111
    115 static irq_ownership_t timer_claim(irq_t *irq)
    116 {
    117         return IRQ_ACCEPT;
    118 }
    119 
    120 static void timer_irq_handler(irq_t *irq)
     112static void timer_interrupt_handler(unsigned int intr)
    121113{
    122114        if (cp0_count_read() < lastcount)
     
    135127        cp0_compare_write(nextcount);
    136128
    137         /*
    138          * We are holding a lock which prevents preemption.
    139          * Release the lock, call clock() and reacquire the lock again.
    140          */
    141         irq_spinlock_unlock(&irq->lock, false);
    142129        clock();
    143         irq_spinlock_lock(&irq->lock, false);
    144 
    145         if (virtual_timer_fnc != NULL)
    146                 virtual_timer_fnc();
    147130}
    148131
     
    150133void interrupt_init(void)
    151134{
    152         irq_init(IRQ_COUNT, IRQ_COUNT);
    153 
    154         irq_initialize(&timer_irq);
    155         timer_irq.inr = TIMER_IRQ;
    156         timer_irq.claim = timer_claim;
    157         timer_irq.handler = timer_irq_handler;
    158         irq_register(&timer_irq);
     135        int_handler[INT_TIMER] = timer_interrupt_handler;
    159136
    160137        timer_start();
    161         cp0_unmask_int(TIMER_IRQ);
     138        cp0_unmask_int(INT_TIMER);
    162139}
    163140
  • kernel/arch/mips32/src/mach/malta/malta.c

    r9259d20 r3e828ea  
    4242#include <genarch/srln/srln.h>
    4343#include <arch/interrupt.h>
     44#include <stdbool.h>
     45#include <byteorder.h>
     46#include <sysinfo/sysinfo.h>
     47#include <log.h>
    4448
    4549static void malta_init(void);
     
    6872#endif
    6973
    70 #ifdef CONFIG_NS16550
    71 static void tty_clear_interrupt(void *arg, inr_t inr)
     74static void malta_isa_irq_handler(unsigned int i)
    7275{
    73         (void) pio_read_8((ioport8_t *) GT64120_PCI0_INTACK);
    74         pic_eoi();
     76        uint8_t isa_irq = host2uint32_t_le(pio_read_32(GT64120_PCI0_INTACK));
     77        if (i8259_is_spurious(isa_irq)) {
     78                i8259_handle_spurious(isa_irq);
     79#ifdef CONFIG_DEBUG
     80                log(LF_ARCH, LVL_DEBUG, "cpu%u: PIC spurious interrupt %u",
     81                    CPU->id, isa_irq);
     82                return;
     83#endif
     84        }
     85        irq_t *irq = irq_dispatch_and_lock(isa_irq);
     86        if (irq) {
     87                irq->handler(irq);
     88                irq_spinlock_unlock(&irq->lock, false);
     89        } else {
     90#ifdef CONFIG_DEBUG
     91                log(LF_ARCH, LVL_DEBUG, "cpu%u: unhandled IRQ (irq=%u)",
     92                    CPU->id, isa_irq);
     93#endif
     94        }
     95        i8259_eoi(isa_irq);
    7596}
    76 #endif
    7797
    7898void malta_init(void)
    7999{
    80         i8259_init((i8259_t *) PIC0_BASE, (i8259_t *) PIC1_BASE, 2, 0, 8);
     100        irq_init(ISA_IRQ_COUNT, ISA_IRQ_COUNT);
     101
     102        i8259_init((i8259_t *) PIC0_BASE, (i8259_t *) PIC1_BASE, 0);
     103        sysinfo_set_item_val("i8259", NULL, true);
     104
     105        int_handler[INT_HW0] = malta_isa_irq_handler;
     106        cp0_unmask_int(INT_HW0);
    81107
    82108#if (defined(CONFIG_NS16550) || defined(CONFIG_NS16550_OUT))
     
    86112        outdev_t **tty_out_ptr = NULL;
    87113#endif
    88         tty_instance = ns16550_init((ioport8_t *) TTY_BASE, 0, TTY_CPU_INT,
    89             tty_clear_interrupt, NULL, tty_out_ptr);
     114        tty_instance = ns16550_init((ioport8_t *) TTY_BASE, 0, TTY_ISA_IRQ,
     115            NULL, NULL, tty_out_ptr);
    90116#endif
    91117}
     
    120146                        indev_t *srln = srln_wire(srln_instance, sink);
    121147                        ns16550_wire(tty_instance, srln);
    122                         pic_enable_irqs(1 << TTY_ISA_IRQ);
    123                         cp0_unmask_int(TTY_CPU_INT);
     148                        i8259_enable_irqs(1 << TTY_ISA_IRQ);
    124149                }
    125150        }
  • kernel/arch/mips32/src/mach/msim/msim.c

    r9259d20 r3e828ea  
    4141#include <genarch/drivers/dsrln/dsrlnout.h>
    4242#include <genarch/srln/srln.h>
     43#include <stdbool.h>
    4344
    4445static void msim_init(void);
     
    6061};
    6162
     63static void msim_irq_handler(unsigned int i)
     64{
     65        irq_t *irq = irq_dispatch_and_lock(i);
     66        if (irq) {
     67                irq->handler(irq);
     68                irq_spinlock_unlock(&irq->lock, false);
     69        } else {
     70#ifdef CONFIG_DEBUG
     71                log(LF_ARCH, LVL_DEBUG, "cpu%u: spurious IRQ (irq=%u)",
     72                    CPU->id, i);
     73#endif
     74        }
     75}
     76
    6277void msim_init(void)
    6378{
     79        irq_init(HW_INTERRUPTS, HW_INTERRUPTS);
     80
     81        int_handler[INT_HW0] = msim_irq_handler;
     82        int_handler[INT_HW1] = msim_irq_handler;
     83        int_handler[INT_HW2] = msim_irq_handler;
     84        int_handler[INT_HW3] = msim_irq_handler;
     85        int_handler[INT_HW4] = msim_irq_handler;
     86
    6487        dorder_init();
    6588        cp0_unmask_int(MSIM_DDISK_IRQ);
  • kernel/arch/mips32/src/mips32.c

    r9259d20 r3e828ea  
    7171arch_ops_t *arch_ops = &mips32_ops;
    7272
    73 /*
    74  * Why the linker moves the variable 64K away in assembler
    75  * when not in .text section?
    76  */
    77 
    7873/* Stack pointer saved when entering user mode */
    79 uintptr_t supervisor_sp __attribute__((section(".text")));
     74// FIXME: This won't work with SMP unless thread creation is globally serialized.
     75uintptr_t supervisor_sp;
    8076
    8177size_t cpu_count = 0;
     
    107103#endif
    108104
     105        str_cpy(bargs, CONFIG_BOOT_ARGUMENTS_BUFLEN, bootinfo->bootargs);
     106
    109107        /* Initialize machine_ops pointer. */
    110108        machine_ops_init();
     
    169167        cp0_status_write(cp0_status_read() | (cp0_status_exl_exception_bit |
    170168            cp0_status_um_bit | cp0_status_ie_enabled_bit));
    171         cp0_epc_write((uintptr_t) kernel_uarg->uspace_entry);
    172         userspace_asm(((uintptr_t) kernel_uarg->uspace_stack +
    173             kernel_uarg->uspace_stack_size),
    174             (uintptr_t) kernel_uarg->uspace_uarg,
    175             (uintptr_t) kernel_uarg->uspace_entry);
     169        cp0_epc_write(kernel_uarg->uspace_entry);
     170        userspace_asm(kernel_uarg->uspace_stack +
     171            kernel_uarg->uspace_stack_size,
     172            kernel_uarg->uspace_uarg,
     173            kernel_uarg->uspace_entry);
    176174
    177175        while (true)
  • kernel/arch/ppc32/include/arch/mm/as.h

    r9259d20 r3e828ea  
    3939
    4040#define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH  0
     41#define KERNEL_SEPARATE_PTL0_ARCH           0
    4142
    4243#define KERNEL_ADDRESS_SPACE_START_ARCH  UINT32_C(0x80000000)
  • kernel/arch/ppc32/include/arch/mm/page.h

    r9259d20 r3e828ea  
    3737
    3838#include <arch/mm/frame.h>
    39 #include <trace.h>
    4039
    4140#define PAGE_WIDTH  FRAME_WIDTH
     
    150149#include <mm/mm.h>
    151150#include <arch/interrupt.h>
     151#include <trace.h>
    152152
    153153/** Page Table Entry. */
  • kernel/arch/ppc32/meson.build

    r9259d20 r3e828ea  
    2727#
    2828
    29 # TODO: We need to implement DWARF unwinding and get rid of this flag.
    30 COMMON_CFLAGS += -fno-omit-frame-pointer -Wl,-z,max-page-size=0x1000
     29arch_src += files(
     30        'src/context.S',
     31        'src/debug/stacktrace.c',
     32        'src/debug/stacktrace_asm.S',
     33        'src/fpu_context.S',
     34        'src/boot/boot.S',
     35        'src/ppc32.c',
     36        'src/dummy.S',
     37        'src/exception.S',
     38        'src/interrupt.c',
     39        'src/asm.S',
     40        'src/cpu/cpu.c',
     41        'src/proc/scheduler.c',
     42        'src/smc.c',
     43        'src/mm/km.c',
     44        'src/mm/as.c',
     45        'src/mm/frame.c',
     46        'src/mm/page.c',
     47        'src/mm/pht.c',
     48        'src/mm/tlb.c',
     49        'src/drivers/pic.c',
     50)
    3151
    32 # XXX: This architecture requires unoptimized TLS pointer access,
    33 #      as with the GCC option `-mno-tls-direct-seg-refs`.
    34 #      The `amd64-helenos` target defaults to this behavior.
    3552
    36 LDFLAGS += -Wl,--gc-sections
     53_check_headers = [
     54        'include/arch/istate_struct.h',
     55        'include/arch/context_struct.h',
     56        'include/arch/fpu_context_struct.h',
     57]
    3758
    38 ENDIANESS = LE
    39 
    40 BFD_NAME = elf64-x86-64
    41 BFD_ARCH = i386:x86-64
     59foreach h : _check_headers
     60        arch_src += [ autocheck.process(h) ]
     61endforeach
  • kernel/arch/ppc32/src/debug/stacktrace.c

    r9259d20 r3e828ea  
    6767bool uspace_frame_pointer_prev(stack_trace_context_t *ctx, uintptr_t *prev)
    6868{
    69         return !copy_from_uspace((void *) prev,
    70             (uint32_t *) ctx->fp + FRAME_OFFSET_FP_PREV, sizeof(*prev));
     69        return !copy_from_uspace(prev,
     70            ctx->fp + sizeof(uintptr_t) * FRAME_OFFSET_FP_PREV, sizeof(*prev));
    7171}
    7272
    7373bool uspace_return_address_get(stack_trace_context_t *ctx, uintptr_t *ra)
    7474{
    75         return !copy_from_uspace((void *) ra,
    76             (uint32_t *) ctx->fp + FRAME_OFFSET_RA, sizeof(*ra));
     75        return !copy_from_uspace(ra,
     76            ctx->fp + sizeof(uintptr_t) * FRAME_OFFSET_RA, sizeof(*ra));
    7777}
    7878
  • kernel/arch/ppc32/src/drivers/pic.c

    r9259d20 r3e828ea  
    3737#include <byteorder.h>
    3838#include <bitops.h>
     39#include <typedefs.h>
    3940
    40 static volatile uint32_t *pic = NULL;
     41static ioport32_t *pic = NULL;
    4142
    4243void pic_init(uintptr_t base, size_t size, cir_t *cir, void **cir_arg)
     
    5051void pic_enable_interrupt(inr_t intnum)
    5152{
    52         if (pic) {
    53                 if (intnum < 32)
    54                         pic[PIC_MASK_LOW] = pic[PIC_MASK_LOW] | (1 << intnum);
    55                 else
    56                         pic[PIC_MASK_HIGH] = pic[PIC_MASK_HIGH] | (1 << (intnum - 32));
     53        if (!pic)
     54                return;
     55
     56        if (intnum < 32) {
     57                pio_write_32(&pic[PIC_MASK_LOW],
     58                    pio_read_32(&pic[PIC_MASK_LOW]) | (1 << intnum));
     59        } else {
     60                pio_write_32(&pic[PIC_MASK_HIGH],
     61                    pio_read_32(&pic[PIC_MASK_HIGH]) | (1 << (intnum - 32)));
    5762        }
    58 
    5963}
    6064
    6165void pic_disable_interrupt(inr_t intnum)
    6266{
    63         if (pic) {
    64                 if (intnum < 32)
    65                         pic[PIC_MASK_LOW] = pic[PIC_MASK_LOW] & (~(1 << intnum));
    66                 else
    67                         pic[PIC_MASK_HIGH] = pic[PIC_MASK_HIGH] & (~(1 << (intnum - 32)));
     67        if (!pic)
     68                return;
     69
     70        if (intnum < 32) {
     71                pio_write_32(&pic[PIC_MASK_LOW],
     72                    pio_read_32(&pic[PIC_MASK_LOW]) & (~(1 << intnum)));
     73        } else {
     74                pio_write_32(&pic[PIC_MASK_HIGH],
     75                    pio_read_32(&pic[PIC_MASK_HIGH]) & (~(1 << (intnum - 32))));
    6876        }
    6977}
     
    7179void pic_ack_interrupt(void *arg, inr_t intnum)
    7280{
    73         if (pic) {
    74                 if (intnum < 32)
    75                         pic[PIC_ACK_LOW] = 1 << intnum;
    76                 else
    77                         pic[PIC_ACK_HIGH] = 1 << (intnum - 32);
     81        if (!pic)
     82                return;
     83
     84        if (intnum < 32) {
     85                pio_write_32(&pic[PIC_ACK_LOW], 1 << intnum);
     86        } else {
     87                pio_write_32(&pic[PIC_ACK_HIGH], 1 << (intnum - 32));
    7888        }
    7989}
     
    8797                uint32_t pending;
    8898
    89                 pending = pic[PIC_PENDING_LOW];
     99                pending = pio_read_32(&pic[PIC_PENDING_LOW]);
    90100                if (pending != 0)
    91101                        return fnzb32(pending);
    92102
    93                 pending = pic[PIC_PENDING_HIGH];
     103                pending = pio_read_32(&pic[PIC_PENDING_HIGH]);
    94104                if (pending != 0)
    95105                        return fnzb32(pending) + 32;
  • kernel/arch/ppc32/src/interrupt.c

    r9259d20 r3e828ea  
    141141                            " (inum=%" PRIu8 ")", CPU->id, inum);
    142142#endif
     143                        pic_ack_interrupt(NULL, inum);
     144                        break;
    143145                }
    144146        }
  • kernel/arch/ppc32/src/ppc32.c

    r9259d20 r3e828ea  
    292292void userspace(uspace_arg_t *kernel_uarg)
    293293{
    294         userspace_asm((uintptr_t) kernel_uarg->uspace_uarg,
    295             (uintptr_t) kernel_uarg->uspace_stack +
     294        userspace_asm(kernel_uarg->uspace_uarg,
     295            kernel_uarg->uspace_stack +
    296296            kernel_uarg->uspace_stack_size - SP_DELTA,
    297             (uintptr_t) kernel_uarg->uspace_entry);
     297            kernel_uarg->uspace_entry);
    298298
    299299        unreachable();
  • kernel/arch/riscv64/_link.ld.in

    r9259d20 r3e828ea  
    1616        kernel_load_address = PA2KA(BOOT_OFFSET);
    1717
    18         .image (PA2KA(BOOT_OFFSET) + SIZEOF_HEADERS) : AT (SIZEOF_HEADERS) {
     18        .image (PA2KA(BOOT_OFFSET) + SIZEOF_HEADERS) : AT (BOOT_OFFSET + SIZEOF_HEADERS) {
    1919                ktext_start = .;
    2020                *(K_TEXT_START);
  • kernel/arch/riscv64/include/arch/mm/as.h

    r9259d20 r3e828ea  
    4040
    4141#define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH  0
     42#define KERNEL_SEPARATE_PTL0_ARCH           0
    4243
    4344#define KERNEL_ADDRESS_SPACE_START_ARCH  UINT64_C(0xffff800000000000)
  • kernel/arch/riscv64/meson.build

    r9259d20 r3e828ea  
    2727#
    2828
    29 BFD_NAME = elf64-littleriscv
    30 BFD_OUTPUT = $(BFD_NAME)
    31 BFD_ARCH = riscv
     29arch_src += files(
     30        'src/boot/boot.S',
     31        'src/asm.S',
     32        'src/context.S',
     33        'src/debug/stacktrace.c',
     34        'src/drivers/ucb.c',
     35        'src/proc/scheduler.c',
     36        'src/proc/task.c',
     37        'src/proc/thread.c',
     38        'src/riscv64.c',
     39        'src/userspace.c',
     40        'src/smc.c',
     41        'src/cpu/cpu.c',
     42        'src/mm/km.c',
     43        'src/mm/as.c',
     44        'src/mm/frame.c',
     45        'src/mm/page.c',
     46        'src/mm/tlb.c',
     47)
    3248
    33 BITS = 64
    34 ENDIANESS = LE
    35 EXTRA_CFLAGS = -mcmodel=medany
    3649
    37 SOURCES = \
    38         arch/$(BARCH)/src/asm.S \
    39         arch/$(BARCH)/src/main.c \
    40         arch/$(BARCH)/src/ucb.c \
    41         arch/$(BARCH)/src/putchar.c \
    42         $(COMPS).o \
    43         generic/src/memstr.c \
    44         generic/src/printf_core.c \
    45         generic/src/vprintf.c \
    46         generic/src/printf.c \
    47         generic/src/str.c \
    48         generic/src/version.c \
    49         generic/src/inflate.c \
    50         generic/src/gzip.c \
    51         generic/src/tar.c \
    52         generic/src/kernel.c \
    53         generic/src/payload.c
     50_check_headers = [
     51        'include/arch/istate_struct.h',
     52        'include/arch/context_struct.h',
     53]
     54
     55foreach h : _check_headers
     56        arch_src += [ autocheck.process(h) ]
     57endforeach
  • kernel/arch/riscv64/src/riscv64.c

    r9259d20 r3e828ea  
    143143}
    144144
    145 uintptr_t memcpy_from_uspace(void *dst, const void *uspace_src, size_t size)
     145uintptr_t memcpy_from_uspace(void *dst, uspace_addr_t uspace_src, size_t size)
    146146{
    147147        return 0;
    148148}
    149149
    150 uintptr_t memcpy_to_uspace(void *uspace_dst, const void *src, size_t size)
     150uintptr_t memcpy_to_uspace(uspace_addr_t uspace_dst, const void *src, size_t size)
    151151{
    152152        return 0;
  • kernel/arch/sparc64/include/arch/drivers/tty.h

    r9259d20 r3e828ea  
    11/*
    2  * Copyright (c) 2014 Martin Sucha
     2 * Copyright (c) 2019 Jakub Jermar
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup draw
     29/** @addtogroup kernel_sparc64
    3030 * @{
    3131 */
    32 /**
    33  * @file
     32/** @file
    3433 */
    3534
    36 #ifndef DRAW_FONT_PBF_H_
    37 #define DRAW_FONT_PBF_H_
     35#ifndef KERN_sparc64_TTY_H_
     36#define KERN_sparc64_TTY_H_
    3837
    39 #include "../font.h"
     38#include <genarch/ofw/ofw_tree.h>
    4039
    41 extern errno_t pcf_font_create(font_t **, char *path, uint16_t points);
     40extern void tty_init(ofw_tree_node_t *node);
    4241
    4342#endif
  • kernel/arch/sparc64/include/arch/mm/sun4u/as.h

    r9259d20 r3e828ea  
    3939
    4040#define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH  1
     41#define KERNEL_SEPARATE_PTL0_ARCH           0
    4142
    4243#define KERNEL_ADDRESS_SPACE_START_ARCH  UINT64_C(0x0000000000000000)
  • kernel/arch/sparc64/include/arch/mm/sun4v/as.h

    r9259d20 r3e828ea  
    4141
    4242#define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH  1
     43#define KERNEL_SEPARATE_PTL0_ARCH           0
    4344
    4445#define KERNEL_ADDRESS_SPACE_START_ARCH  UINT64_C(0x0000000000000000)
  • kernel/arch/sparc64/meson.build

    r9259d20 r3e828ea  
    2727#
    2828
    29 COMMON_CFLAGS += -msoft-float -mno-abicalls -G 0 -fno-zero-initialized-in-bss -mabi=32
    30 AS_PROLOG = .module softfloat;
    31 
    32 BITS = 32
    33 
    34 ## Accepted MACHINEs
    35 #
    36 
    37 ifeq ($(MACHINE),msim)
    38         ENDIANESS = LE
    39         COMMON_CFLAGS += -march=r4000
    40 endif
    41 ifeq ($(MACHINE),bmalta)
    42         ENDIANESS = BE
    43         COMMON_CFLAGS += -D__BE__ -march=4kc
    44 endif
    45 ifeq ($(MACHINE),lmalta)
    46         ENDIANESS = LE
    47         COMMON_CFLAGS += -march=4kc
     29if PROCESSOR == 'us' or PROCESSOR == 'us3'
     30        USARCH = 'sun4u'
     31elif PROCESSOR == 'sun4v'
     32        USARCH = 'sun4v'
     33else
     34        error('Unknown PROCESSOR: ' + PROCESSOR)
    4835endif
    4936
    50 ARCH_SOURCES = \
    51         arch/$(KARCH)/src/start.S \
    52         arch/$(KARCH)/src/context.S \
    53         arch/$(KARCH)/src/mips32.c \
    54         arch/$(KARCH)/src/asm.S \
    55         arch/$(KARCH)/src/exception.c \
    56         arch/$(KARCH)/src/interrupt.c \
    57         arch/$(KARCH)/src/cache.c \
    58         arch/$(KARCH)/src/debugger.c \
    59         arch/$(KARCH)/src/cpu/cpu.c \
    60         arch/$(KARCH)/src/debug/stacktrace.c \
    61         arch/$(KARCH)/src/debug/stacktrace_asm.S \
    62         arch/$(KARCH)/src/mm/km.c \
    63         arch/$(KARCH)/src/mm/frame.c \
    64         arch/$(KARCH)/src/mm/page.c \
    65         arch/$(KARCH)/src/mm/tlb.c \
    66         arch/$(KARCH)/src/mm/as.c \
    67         arch/$(KARCH)/src/fpu_context.c \
    68         arch/$(KARCH)/src/smc.c \
    69         arch/$(KARCH)/src/smp/smp.c \
    70         arch/$(KARCH)/src/machine_func.c
     37arch_src += files(
     38        'src/sparc64.c',
     39        'src/cpu' / USARCH / 'cpu.c',
     40        'src/debug/stacktrace.c',
     41        'src/debug/stacktrace_asm.S',
     42        'src/asm.S',
     43        'src' / USARCH / 'asm.S',
     44        'src/console.c',
     45        'src/context.S',
     46        'src/fpu_context.c',
     47        'src/dummy.S',
     48        'src/mm' / USARCH / 'km.c',
     49        'src/mm' / USARCH / 'as.c',
     50        'src/mm' / USARCH / 'frame.c',
     51        'src/mm/page.c',
     52        'src/mm' / USARCH / 'tlb.c',
     53        'src' / USARCH / 'sparc64.c',
     54        'src' / USARCH / 'start.S',
     55        'src/proc' / USARCH / 'scheduler.c',
     56        'src/proc/thread.c',
     57        'src/smc.c',
     58        'src/trap' / USARCH / 'mmu.S',
     59        'src/trap' / USARCH / 'trap_table.S',
     60        'src/trap/trap.c',
     61        'src/trap/exception.c',
     62        'src/trap/interrupt.c',
     63        'src/drivers/tick.c',
     64        'src/drivers/kbd.c',
     65        'src/drivers/tty.c',
     66        'src/drivers/pci.c',
     67        'src/trap' / USARCH / 'interrupt.c',
     68)
    7169
    72 ifeq ($(MACHINE),$(filter lmalta bmalta,$(MACHINE)))
    73         ARCH_SOURCES += arch/$(KARCH)/src/mach/malta/malta.c
     70if USARCH == 'sun4v'
     71        arch_src += files(
     72                'src/drivers/niagara.c',
     73                'src/sun4v/md.c',
     74        )
    7475endif
    7576
    76 ifeq ($(MACHINE),msim)
    77         ARCH_SOURCES += \
    78                 arch/$(KARCH)/src/mach/msim/msim.c \
    79                 arch/$(KARCH)/src/mach/msim/dorder.c
     77if CONFIG_FB
     78        arch_src += files(
     79                'src/drivers/scr.c',
     80        )
    8081endif
    8182
    82 ARCH_AUTOCHECK_HEADERS = \
    83         arch/$(KARCH)/include/arch/istate_struct.h \
    84         arch/$(KARCH)/include/arch/context_struct.h \
    85         arch/$(KARCH)/include/arch/fpu_context_struct.h
     83if CONFIG_SMP
     84        arch_src += files(
     85                'src/smp' / USARCH / 'smp.c',
     86                'src/smp' / USARCH / 'ipi.c',
     87        )
     88endif
     89
     90if CONFIG_TSB
     91        arch_src += files(
     92                'src/mm' / USARCH / 'tsb.c',
     93        )
     94endif
     95
     96
     97_check_headers = [
     98        'include/arch/istate_struct.h',
     99        'include/arch/context_struct.h',
     100]
     101
     102foreach h : _check_headers
     103        arch_src += [ autocheck.process(h) ]
     104endforeach
  • kernel/arch/sparc64/src/console.c

    r9259d20 r3e828ea  
    3737#include <arch/drivers/scr.h>
    3838#include <arch/drivers/kbd.h>
     39#include <arch/drivers/tty.h>
    3940#include <genarch/srln/srln.h>
    4041#include <console/chardev.h>
     
    8485        kbd_init(keyboard);
    8586#endif
     87
     88#ifdef CONFIG_SUN_TTY
     89        ofw_tree_property_t *prop_tty = ofw_tree_getprop(aliases, "ttya");
     90        if (prop_tty && prop_tty->value) {
     91                ofw_tree_node_t *tty = ofw_tree_lookup(prop_tty->value);
     92                if (tty)
     93                        tty_init(tty);
     94        }
     95#endif
    8696}
    8797
  • kernel/arch/sparc64/src/drivers/kbd.c

    r9259d20 r3e828ea  
    3838#include <console/console.h>
    3939#include <ddi/irq.h>
    40 #include <mm/page.h>
    41 #include <arch/mm/page.h>
    42 #include <mm/km.h>
    4340#include <typedefs.h>
    4441#include <align.h>
     
    8885        }
    8986
    90         size_t size = ((ofw_ebus_reg_t *) prop->value)->size;
    91 
    9287        uintptr_t pa = 0; // Prevent -Werror=maybe-uninitialized
    9388        if (!ofw_ebus_apply_ranges(node->parent,
     
    109104        }
    110105
    111         ioport8_t *ns16550 = (ioport8_t *) km_map(pa, size,
    112             KM_NATURAL_ALIGNMENT, PAGE_WRITE | PAGE_NOT_CACHEABLE);
    113 
    114         ns16550_instance_t *ns16550_instance = ns16550_init(ns16550, 0, inr, cir,
    115             cir_arg, NULL);
     106        ns16550_instance_t *ns16550_instance = ns16550_init((ioport8_t *) pa, 0,
     107            inr, cir, cir_arg, NULL);
    116108        if (ns16550_instance) {
    117109                kbrd_instance_t *kbrd_instance = kbrd_init();
  • kernel/arch/sparc64/src/mm/sun4u/tlb.c

    r9259d20 r3e828ea  
    311311                t.a = true;
    312312                t.d = true;
    313                 dtlb_demap(TLB_DEMAP_PAGE, TLB_DEMAP_SECONDARY,
     313                dtlb_demap(TLB_DEMAP_PAGE,
     314                    (as == AS_KERNEL) ? TLB_DEMAP_PRIMARY : TLB_DEMAP_SECONDARY,
    314315                    page_16k + index * MMU_PAGE_SIZE);
    315316                dtlb_pte_copy(&t, index, false);
  • kernel/arch/sparc64/src/sun4u/sparc64.c

    r9259d20 r3e828ea  
    163163{
    164164        (void) interrupts_disable();
    165         switch_to_userspace((uintptr_t) kernel_uarg->uspace_entry,
    166             ((uintptr_t) kernel_uarg->uspace_stack) +
     165        switch_to_userspace(kernel_uarg->uspace_entry,
     166            kernel_uarg->uspace_stack +
    167167            kernel_uarg->uspace_stack_size -
    168168            (ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT) + STACK_BIAS),
    169             (uintptr_t) kernel_uarg->uspace_uarg);
     169            kernel_uarg->uspace_uarg);
    170170
    171171        /* Not reached */
  • kernel/arch/sparc64/src/sun4v/sparc64.c

    r9259d20 r3e828ea  
    161161{
    162162        (void) interrupts_disable();
    163         switch_to_userspace((uintptr_t) kernel_uarg->uspace_entry,
    164             ((uintptr_t) kernel_uarg->uspace_stack) +
     163        switch_to_userspace(kernel_uarg->uspace_entry,
     164            kernel_uarg->uspace_stack +
    165165            kernel_uarg->uspace_stack_size -
    166166            (ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT) + STACK_BIAS),
    167             (uintptr_t) kernel_uarg->uspace_uarg);
     167            kernel_uarg->uspace_uarg);
    168168
    169169        /* Not reached */
Note: See TracChangeset for help on using the changeset viewer.