Changeset 86ffa27f in mainline for kernel


Ignore:
Timestamp:
2011-08-07T11:21:44Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
cc574511
Parents:
15f3c3f (diff), e8067c0 (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
Files:
49 added
6 deleted
46 edited
3 moved

Legend:

Unmodified
Added
Removed
  • kernel/arch/amd64/Makefile.inc

    r15f3c3f r86ffa27f  
    4141# is fixed.
    4242#
    43 # If GCC generates a code for tail call, instead of generating ..
     43# When GCC generates a code for tail call, instead of generating ..
    4444#
    4545#   jmp *fnc
     
    4848#
    4949#   jmp *$fnc
     50#
     51# See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48385 for reference.
    5052#
    5153
  • kernel/arch/arm32/src/mach/gta02/gta02.c

    r15f3c3f r86ffa27f  
    158158{
    159159#ifdef CONFIG_FB
    160         parea_t fb_parea;
    161 
    162160        fb_properties_t prop = {
    163161                .addr = GTA02_FB_BASE,
     
    170168
    171169        outdev_t *fb_dev = fb_init(&prop);
    172         if (fb_dev) {
     170        if (fb_dev)
    173171                stdout_wire(fb_dev);
    174                 fb_parea.pbase = GTA02_FB_BASE;
    175                 fb_parea.frames = 150;
    176                 fb_parea.unpriv = false;
    177                 ddi_parea_register(&fb_parea);
    178         }
    179172#endif
    180173
    181174        /* Initialize serial port of the debugging console. */
    182         s3c24xx_uart_io_t *scons_io;
    183 
    184         scons_io = (void *) hw_map(GTA02_SCONS_BASE, PAGE_SIZE);
    185         gta02_scons_dev = s3c24xx_uart_init(scons_io, S3C24XX_INT_UART2);
     175        gta02_scons_dev =
     176            s3c24xx_uart_init(GTA02_SCONS_BASE, S3C24XX_INT_UART2);
    186177
    187178        if (gta02_scons_dev) {
  • kernel/arch/arm32/src/mach/integratorcp/integratorcp.c

    r15f3c3f r86ffa27f  
    5353
    5454#define SDRAM_SIZE      (sdram[((*(uint32_t *)(ICP_CMCR+ICP_SDRAMCR_OFFSET) & ICP_SDRAM_MASK) >> 2)])
    55 static parea_t fb_parea;
    5655static icp_hw_map_t icp_hw_map;
    5756static irq_t icp_timer_irq;
     
    296295       
    297296        outdev_t *fbdev = fb_init(&prop);
    298         if (fbdev) {
     297        if (fbdev)
    299298                stdout_wire(fbdev);
    300                 fb_parea.pbase = ICP_FB;
    301                 fb_parea.frames = 300;
    302                 fb_parea.unpriv = false;
    303                 ddi_parea_register(&fb_parea);
    304         }
    305299#endif
    306300}
  • kernel/arch/ia32/src/boot/vesa_real.inc

    r15f3c3f r86ffa27f  
    154154        mov $e_vesa_init - vesa_init, %di
    155155        push %di
     156        /* Write the "VBE2" signature into the info structure in order
     157         * to get proper mode information. The presence of "VBE2"
     158         * indicates two things:
     159         *
     160         *  - VBE controller information structure is expected to be
     161         *    512 bytes long instead of 256 bytes.
     162         *  - The BIOS should report VBE 3.0 information (potentially
     163         *    including non-standard modes in the mode list).
     164         */
     165        movl $0x32454256, (%di)
    156166        int $0x10
    157167       
  • kernel/arch/ia64/include/bootinfo.h

    r15f3c3f r86ffa27f  
    3434#define MEMMAP_ITEMS 128
    3535
    36 #define EFI_MEMMAP_FREE_MEM 0
     36#define MEMMAP_FREE_MEM 0
    3737
    3838/** Size of buffer for storing task name in binit_task_t. */
     
    5454        unsigned long base;
    5555        unsigned long size;
    56 } efi_memmap_item_t;
     56} memmap_item_t;
    5757
    5858typedef struct {
    5959        binit_t taskmap;
    6060       
    61         efi_memmap_item_t memmap[MEMMAP_ITEMS];
     61        memmap_item_t memmap[MEMMAP_ITEMS];
    6262        unsigned int memmap_items;
    6363       
     
    6666        unsigned long freq_scale;
    6767        unsigned int wakeup_intno;
    68         int hello_configured;
    6968} bootinfo_t;
    7069
  • kernel/arch/ia64/src/drivers/ski.c

    r15f3c3f r86ffa27f  
    5757};
    5858
    59 static void ski_putchar(outdev_t *, const wchar_t, bool);
     59static void ski_putchar(outdev_t *, const wchar_t);
    6060
    6161static outdev_operations_t skidev_ops = {
     
    9999static void poll_keyboard(ski_instance_t *instance)
    100100{
    101         if (silent)
    102                 return;
    103        
    104101        int count = POLL_LIMIT;
    105102       
     
    121118       
    122119        while (true) {
    123                 if (!silent)
     120                // TODO FIXME:
     121                // This currently breaks the kernel console
     122                // before we get the override from uspace.
     123                if (console_override)
    124124                        poll_keyboard(instance);
    125125               
     
    182182 * @param dev    Character device.
    183183 * @param ch     Character to be printed.
    184  * @param silent Whether the output should be silenced.
    185  *
    186  */
    187 static void ski_putchar(outdev_t *dev, const wchar_t ch, bool silent)
    188 {
    189         if (!silent) {
     184 *
     185 */
     186static void ski_putchar(outdev_t *dev, const wchar_t ch)
     187{
     188        // TODO FIXME:
     189        // This currently breaks the kernel console
     190        // before we get the override from uspace.
     191        if (console_override) {
    190192                if (ascii_check(ch)) {
    191193                        if (ch == '\n')
     
    213215        if (!fb_exported) {
    214216                /*
    215                  * This is the necessary evil until the userspace driver is entirely
     217                 * This is the necessary evil until
     218                 * the userspace driver is entirely
    216219                 * self-sufficient.
    217220                 */
  • kernel/arch/ia64/src/ia64.c

    r15f3c3f r86ffa27f  
    151151        /* Set platform name. */
    152152#ifdef MACHINE_ski
    153         platform = "pc";
     153        platform = "ski";
    154154#endif
    155155#ifdef MACHINE_i460GX
  • kernel/arch/ia64/src/mm/frame.c

    r15f3c3f r86ffa27f  
    5858                unsigned int i;
    5959                for (i = 0; i < bootinfo->memmap_items; i++) {
    60                         if (bootinfo->memmap[i].type == EFI_MEMMAP_FREE_MEM) {
     60                        if (bootinfo->memmap[i].type == MEMMAP_FREE_MEM) {
    6161                                uint64_t base = bootinfo->memmap[i].base;
    6262                                uint64_t size = bootinfo->memmap[i].size;
  • kernel/arch/mips32/Makefile.inc

    r15f3c3f r86ffa27f  
    2929BFD_ARCH = mips
    3030BFD = binary
    31 GCC_CFLAGS += -mno-abicalls -G 0 -fno-zero-initialized-in-bss -mips3
     31GCC_CFLAGS += -mno-abicalls -G 0 -fno-zero-initialized-in-bss -mips3 -mabi=32
    3232
    3333BITS = 32
  • kernel/arch/mips32/include/cycle.h

    r15f3c3f r86ffa27f  
    2727 */
    2828
    29 /** @addtogroup mips2
     29/** @addtogroup mips32
    3030 * @{
    3131 */
  • kernel/arch/mips32/include/debug.h

    r15f3c3f r86ffa27f  
    3434
    3535#ifndef KERN_mips32_DEBUG_H_
    36 #define KERN_mips23_DEBUG_H_
     36#define KERN_mips32_DEBUG_H_
    3737
    3838/** Enter the simulator trace mode */
  • kernel/arch/mips32/include/mm/frame.h

    r15f3c3f r86ffa27f  
    4242#ifndef __ASM__
    4343
    44 #include <typedefs.h>
    45 
    4644extern void frame_arch_init(void);
    4745extern void physmem_print(void);
  • kernel/arch/mips32/include/stack.h

    r15f3c3f r86ffa27f  
    3939#define STACK_ALIGNMENT         8
    4040
    41 #define STACK_ARG0              0
    42 #define STACK_ARG1              4
    43 #define STACK_ARG2              8
    44 #define STACK_ARG3              12
    45 #define STACK_ARG4              16
    46 #define STACK_ARG5              20
    47 #define STACK_ARG6              24
    48 
    4941#endif
    5042
  • kernel/arch/mips32/src/cache.c

    r15f3c3f r86ffa27f  
    2727 */
    2828
    29 /** @addtogroup mips32 
     29/** @addtogroup mips32
    3030 * @{
    3131 */
  • kernel/arch/mips32/src/cpu/cpu.c

    r15f3c3f r86ffa27f  
    3737#include <arch.h>
    3838#include <arch/cp0.h>
    39 #include <print.h>     
     39#include <print.h>
    4040
    4141struct data_t {
  • kernel/arch/mips32/src/fpu_context.c

    r15f3c3f r86ffa27f  
    2727 */
    2828
    29 /** @addtogroup mips32 
     29/** @addtogroup mips32
    3030 * @{
    3131 */
     
    4040
    4141void fpu_disable(void)
    42 {       
     42{
    4343#ifdef CONFIG_FPU
    4444        cp0_status_write(cp0_status_read() & ~cp0_status_fpu_bit);
  • kernel/arch/mips32/src/mm/as.c

    r15f3c3f r86ffa27f  
    6161        /*
    6262         * Install ASID.
    63          */     
     63         */
    6464        hi.value = cp0_entry_hi_read();
    6565
    6666        hi.asid = as->asid;
    67         cp0_entry_hi_write(hi.value);   
     67        cp0_entry_hi_write(hi.value);
    6868}
    6969
  • kernel/arch/mips32/src/mm/tlb.c

    r15f3c3f r86ffa27f  
    7373                tlbwi();
    7474        }
    75                
     75       
    7676        /*
    7777         * The kernel is going to make use of some wired
     
    386386                        ASSERT(pte->w || access != PF_ACCESS_WRITE);
    387387                        return pte;
    388                         break;
    389388                case AS_PF_DEFER:
    390389                        *pfrc = AS_PF_DEFER;
    391390                        return NULL;
    392                         break;
    393391                case AS_PF_FAULT:
    394392                        *pfrc = AS_PF_FAULT;
    395393                        return NULL;
    396                         break;
    397394                default:
    398395                        panic("Unexpected rc (%d).", rc);
  • kernel/arch/mips32/src/start.S

    r15f3c3f r86ffa27f  
    222222       
    223223        /* move $k0 pointer to kernel stack */
    224         lui $k0, %hi(supervisor_sp)
    225         ori $k0, $k0, %lo(supervisor_sp)
     224        la $k0, supervisor_sp
    226225       
    227226        /* move $k0 (supervisor_sp) */
  • kernel/arch/mips64/include/arch.h

    r15f3c3f r86ffa27f  
    11/*
    2  * Copyright (c) 2006 Jakub Jermar
     2 * Copyright (c) 2005 Martin Decky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 #ifndef KERN_FHC_H_
    30 #define KERN_FHC_H_
     29/** @addtogroup mips64
     30 * @{
     31 */
     32/** @file
     33 */
    3134
    32 #include <genarch/ofw/ofw_tree.h>
    33 #include <typedefs.h>
    34 #include <ddi/irq.h>
     35#ifndef KERN_mips64_ARCH_H_
     36#define KERN_mips64_ARCH_H_
     37
    3538#include <typedefs.h>
    3639
    37 typedef struct {
    38         uint64_t addr;
    39         uint32_t size;
    40 } __attribute__ ((packed)) ofw_fhc_reg_t;
     40#define TASKMAP_MAX_RECORDS        32
     41#define CPUMAP_MAX_RECORDS         32
     42#define BOOTINFO_TASK_NAME_BUFLEN  32
     43
     44extern size_t cpu_count;
    4145
    4246typedef struct {
    43         uint64_t child_base;
    44         uint64_t parent_base;
    45         uint32_t size;
    46 } __attribute__ ((packed)) ofw_fhc_range_t;
     47        void *addr;
     48        size_t size;
     49        char name[BOOTINFO_TASK_NAME_BUFLEN];
     50} utask_t;
    4751
    4852typedef struct {
    49         uint64_t addr;
    50         uint32_t size;
    51 } __attribute__ ((packed)) ofw_central_reg_t;
     53        uint32_t cpumap;
     54        size_t cnt;
     55        utask_t tasks[TASKMAP_MAX_RECORDS];
     56} bootinfo_t;
    5257
    53 typedef struct {
    54         uint64_t child_base;
    55         uint64_t parent_base;
    56         uint32_t size;
    57 } __attribute__ ((packed)) ofw_central_range_t;
    58 
    59 extern bool ofw_fhc_apply_ranges(ofw_tree_node_t *, ofw_fhc_reg_t *,
    60     uintptr_t *);
    61 extern bool ofw_central_apply_ranges(ofw_tree_node_t *, ofw_central_reg_t *,
    62     uintptr_t *);
    63 
    64 extern bool ofw_fhc_map_interrupt(ofw_tree_node_t *, ofw_fhc_reg_t *,
    65     uint32_t, int *, cir_t *, void **);
     58extern void arch_pre_main(void *entry, bootinfo_t *bootinfo);
    6659
    6760#endif
     61
     62/** @}
     63 */
  • kernel/arch/mips64/include/faddr.h

    r15f3c3f r86ffa27f  
    11/*
    2  * Copyright (c) 2008 Pavel Rimsky
     2 * Copyright (c) 2005 Jakub Jermar
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @defgroup sgcnfb SGCN
    30  * @brief       userland driver of the Serengeti console output
     29/** @addtogroup mips64
    3130 * @{
    3231 */
    33  
    3432/** @file
    3533 */
    3634
    37 #ifndef FB_SGCN_H_
    38 #define FB_SGCN_H_
     35#ifndef KERN_mips64_FADDR_H_
     36#define KERN_mips64_FADDR_H_
    3937
    40 int sgcn_init(void);
     38#include <typedefs.h>
     39
     40#define FADDR(fptr)  ((uintptr_t) (fptr))
    4141
    4242#endif
    4343
    44 /**
    45  * @}
     44/** @}
    4645 */
  • kernel/arch/mips64/include/proc/task.h

    r15f3c3f r86ffa27f  
    2727 */
    2828
    29 /** @addtogroup sparc64
     29/** @addtogroup mips64proc
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #ifndef KERN_sparc64_FHC_H_
    36 #define KERN_sparc64_FHC_H_
    37 
    38 #include <typedefs.h>
    39 #include <genarch/ofw/ofw_tree.h>
     35#ifndef KERN_mips64_TASK_H_
     36#define KERN_mips64_TASK_H_
    4037
    4138typedef struct {
    42         volatile uint32_t *uart_imap;
    43 } fhc_t;
     39} task_arch_t;
    4440
    45 extern fhc_t *central_fhc;
    46 
    47 extern fhc_t *fhc_init(ofw_tree_node_t *);
    48 extern void fhc_enable_interrupt(fhc_t *, int);
    49 extern void fhc_clear_interrupt(void *, int);
     41#define task_create_arch(task)
     42#define task_destroy_arch(task)
    5043
    5144#endif
  • kernel/arch/sparc64/Makefile.inc

    r15f3c3f r86ffa27f  
    8484        arch/$(KARCH)/src/drivers/tick.c \
    8585        arch/$(KARCH)/src/drivers/kbd.c \
    86         arch/$(KARCH)/src/drivers/sgcn.c \
    8786        arch/$(KARCH)/src/drivers/pci.c \
    88         arch/$(KARCH)/src/drivers/fhc.c \
    8987        arch/$(KARCH)/src/trap/$(USARCH)/interrupt.c
    9088
  • kernel/arch/sparc64/src/console.c

    r15f3c3f r86ffa27f  
    3838#include <arch/drivers/scr.h>
    3939#include <arch/drivers/kbd.h>
    40 #include <arch/drivers/sgcn.h>
    4140#include <genarch/srln/srln.h>
    4241#include <console/chardev.h>
     
    8988}
    9089
    91 /** Initilize I/O on the Serengeti machine. */
    92 static void serengeti_init(void)
    93 {
    94 #ifdef CONFIG_SGCN_KBD
    95         sgcn_instance_t *sgcn_instance = sgcnin_init();
    96         if (sgcn_instance) {
    97                 srln_instance_t *srln_instance = srln_init();
    98                 if (srln_instance) {
    99                         indev_t *sink = stdin_wire();
    100                         indev_t *srln = srln_wire(srln_instance, sink);
    101                         sgcnin_wire(sgcn_instance, srln);
    102                 }
    103         }
    104 #endif
    105        
    106 #ifdef CONFIG_SGCN_PRN
    107         outdev_t *sgcndev = sgcnout_init();
    108         if (sgcndev)
    109                 stdout_wire(sgcndev);
    110 #endif
    111 }
    112 
    11390/**
    11491 * Initialize input/output. Auto-detects the type of machine
     
    127104        prop = ofw_tree_getprop(aliases, "def-cn");
    128105       
    129         if ((!prop) || (!prop->value) || (str_cmp(prop->value, "/sgcn") != 0)) {
     106        if ((!prop) || (!prop->value))
    130107                standard_console_init(aliases);
    131         } else {
    132                 serengeti_init();
    133         }
    134108}
    135109
  • kernel/arch/sparc64/src/drivers/kbd.c

    r15f3c3f r86ffa27f  
    3535#include <arch/drivers/kbd.h>
    3636#include <genarch/ofw/ofw_tree.h>
    37 #include <genarch/ofw/fhc.h>
    3837#include <genarch/ofw/ebus.h>
    3938#include <console/console.h>
     
    5150#endif
    5251
    53 #ifdef CONFIG_Z8530
    54 #include <genarch/drivers/z8530/z8530.h>
    55 #endif
    56 
    5752#ifdef CONFIG_NS16550
    5853#include <genarch/drivers/ns16550/ns16550.h>
     
    6055
    6156#ifdef CONFIG_SUN_KBD
    62 
    63 #ifdef CONFIG_Z8530
    64 
    65 static bool kbd_z8530_init(ofw_tree_node_t *node)
    66 {
    67         const char *name = ofw_tree_node_name(node);
    68        
    69         if (str_cmp(name, "zs") != 0)
    70                 return false;
    71        
    72         /*
    73          * Read 'interrupts' property.
    74          */
    75         ofw_tree_property_t *prop = ofw_tree_getprop(node, "interrupts");
    76         if ((!prop) || (!prop->value)) {
    77                 printf("z8530: Unable to find interrupts property\n");
    78                 return false;
    79         }
    80        
    81         uint32_t interrupts = *((uint32_t *) prop->value);
    82        
    83         /*
    84          * Read 'reg' property.
    85          */
    86         prop = ofw_tree_getprop(node, "reg");
    87         if ((!prop) || (!prop->value)) {
    88                 printf("z8530: Unable to find reg property\n");
    89                 return false;
    90         }
    91        
    92         size_t size = ((ofw_fhc_reg_t *) prop->value)->size;
    93        
    94         uintptr_t pa;
    95         if (!ofw_fhc_apply_ranges(node->parent,
    96             ((ofw_fhc_reg_t *) prop->value), &pa)) {
    97                 printf("z8530: Failed to determine address\n");
    98                 return false;
    99         }
    100        
    101         inr_t inr;
    102         cir_t cir;
    103         void *cir_arg;
    104         if (!ofw_fhc_map_interrupt(node->parent,
    105             ((ofw_fhc_reg_t *) prop->value), interrupts, &inr, &cir,
    106             &cir_arg)) {
    107                 printf("z8530: Failed to determine interrupt\n");
    108                 return false;
    109         }
    110        
    111         /*
    112          * We need to pass aligned address to hw_map().
    113          * However, the physical keyboard address can
    114          * be pretty much unaligned, depending on the
    115          * underlying controller.
    116          */
    117         uintptr_t aligned_addr = ALIGN_DOWN(pa, PAGE_SIZE);
    118         size_t offset = pa - aligned_addr;
    119        
    120         z8530_t *z8530 = (z8530_t *)
    121             (hw_map(aligned_addr, offset + size) + offset);
    122        
    123         z8530_instance_t *z8530_instance = z8530_init(z8530, inr, cir, cir_arg);
    124         if (z8530_instance) {
    125                 kbrd_instance_t *kbrd_instance = kbrd_init();
    126                 if (kbrd_instance) {
    127                         indev_t *sink = stdin_wire();
    128                         indev_t *kbrd = kbrd_wire(kbrd_instance, sink);
    129                         z8530_wire(z8530_instance, kbrd);
    130                 }
    131         }
    132        
    133         /*
    134          * This is the necessary evil until the userspace drivers are
    135          * entirely self-sufficient.
    136          */
    137         sysinfo_set_item_val("kbd", NULL, true);
    138         sysinfo_set_item_val("kbd.inr", NULL, inr);
    139         sysinfo_set_item_val("kbd.address.kernel", NULL,
    140             (uintptr_t) z8530);
    141         sysinfo_set_item_val("kbd.address.physical", NULL, pa);
    142         sysinfo_set_item_val("kbd.type.z8530", NULL, true);
    143        
    144         return true;
    145 }
    146 
    147 #endif /* CONFIG_Z8530 */
    14857
    14958#ifdef CONFIG_NS16550
     
    243152void kbd_init(ofw_tree_node_t *node)
    244153{
    245 #ifdef CONFIG_Z8530
    246         kbd_z8530_init(node);
    247 #endif
    248        
    249154#ifdef CONFIG_NS16550
    250155        kbd_ns16550_init(node);
  • kernel/arch/sparc64/src/drivers/niagara.c

    r15f3c3f r86ffa27f  
    3232/**
    3333 * @file
    34  * @brief       Niagara input/output driver based on hypervisor calls.
     34 * @brief Niagara input/output driver based on hypervisor calls.
    3535 */
    3636
     
    5252#include <genarch/srln/srln.h>
    5353
    54 /* polling interval in miliseconds */
     54/* Polling interval in miliseconds */
    5555#define POLL_INTERVAL  10000
    5656
    57 /* device instance */
     57/* Device instance */
    5858static niagara_instance_t *instance = NULL;
    5959
    60 static void niagara_putchar(outdev_t *, const wchar_t, bool);
    61 
    62 /** character device operations */
     60static void niagara_putchar(outdev_t *, const wchar_t);
     61
     62/** Character device operations */
    6363static outdev_operations_t niagara_ops = {
    6464        .write = niagara_putchar,
     
    6666};
    6767
    68 /*
     68/**
    6969 * The driver uses hypercalls to print characters to the console. Since the
    7070 * hypercall cannot be performed from the userspace, we do this:
    71  * The kernel "little brother" driver (which will be present no matter what the
    72  * DDI architecture is - as we need the kernel part for the kconsole)
     71 *
     72 * The kernel "little brother" driver (which will be present no matter what
     73 * the DDI architecture is -- as we need the kernel part for the kconsole)
    7374 * defines a shared buffer. Kernel walks through the buffer (in the same thread
    7475 * which is used for polling the keyboard) and prints any pending characters
    75  * to the console (using hypercalls). The userspace fb server maps this shared
    76  * buffer to its address space and output operation it does is performed using
    77  * the mapped buffer. The shared buffer definition follows.
    78  */
    79 #define OUTPUT_BUFFER_SIZE      ((PAGE_SIZE) - 2 * 8)
     76 * to the console (using hypercalls).
     77 *
     78 * The userspace fb server maps this shared buffer to its address space and
     79 * output operation it does is performed using the mapped buffer. The shared
     80 * buffer definition follows.
     81 */
     82#define OUTPUT_BUFFER_SIZE  ((PAGE_SIZE) - 2 * 8)
     83
    8084static volatile struct {
    8185        uint64_t read_ptr;
    8286        uint64_t write_ptr;
    8387        char data[OUTPUT_BUFFER_SIZE];
    84 }
    85         __attribute__ ((packed))
    86         __attribute__ ((aligned(PAGE_SIZE)))
    87         output_buffer;
     88} __attribute__ ((packed)) __attribute__ ((aligned(PAGE_SIZE))) output_buffer;
     89
     90static parea_t outbuf_parea;
    8891
    8992/**
    9093 * Analogous to the output_buffer, see the previous definition.
    9194 */
    92 #define INPUT_BUFFER_SIZE       ((PAGE_SIZE) - 2 * 8)
     95#define INPUT_BUFFER_SIZE  ((PAGE_SIZE) - 2 * 8)
     96
    9397static volatile struct {
    9498        uint64_t write_ptr;
    9599        uint64_t read_ptr;
    96100        char data[INPUT_BUFFER_SIZE];
    97 }
    98         __attribute__ ((packed))
    99         __attribute__ ((aligned(PAGE_SIZE)))
    100         input_buffer;
    101 
    102 
    103 /** Writes a single character to the standard output. */
     101} __attribute__ ((packed)) __attribute__ ((aligned(PAGE_SIZE))) input_buffer;
     102
     103static parea_t inbuf_parea;
     104
     105/** Write a single character to the standard output. */
    104106static inline void do_putchar(const char c) {
    105         /* repeat until the buffer is non-full */
    106         while (__hypercall_fast1(CONS_PUTCHAR, c) == HV_EWOULDBLOCK)
    107                 ;
    108 }
    109 
    110 /** Writes a single character to the standard output. */
    111 static void niagara_putchar(outdev_t *dev, const wchar_t ch, bool silent)
    112 {
    113         if (silent)
    114             return;
    115 
    116         do_putchar(ch);
    117         if (ch == '\n')
    118                 do_putchar('\r');
    119 }
    120 
    121 /**
    122  * Function regularly called by the keyboard polling thread. Asks the
    123  * hypervisor whether there is any unread character. If so, it picks it up
    124  * and sends it to the upper layers of HelenOS.
    125  *
    126  * Apart from that, it also checks whether the userspace output driver has
    127  * pushed any characters to the output buffer. If so, it prints them.
    128  */
    129 static void niagara_poll(niagara_instance_t *instance)
    130 {
    131         /* print any pending characters from the shared buffer to the console */
     107        /* Repeat until the buffer is non-full */
     108        while (__hypercall_fast1(CONS_PUTCHAR, c) == HV_EWOULDBLOCK);
     109}
     110
     111/** Write a single character to the standard output. */
     112static void niagara_putchar(outdev_t *dev, const wchar_t ch)
     113{
     114        if ((!outbuf_parea.mapped) || (console_override)) {
     115                do_putchar(ch);
     116                if (ch == '\n')
     117                        do_putchar('\r');
     118        }
     119}
     120
     121/** Poll keyboard and print pending characters.
     122 *
     123 * Ask the hypervisor whether there is any unread character. If so,
     124 * pick it up and send it to the indev layer.
     125 *
     126 * Check whether the userspace output driver has pushed any
     127 * characters to the output buffer and eventually print them.
     128 *
     129 */
     130static void niagara_poll(void)
     131{
     132        /*
     133         * Print any pending characters from the
     134         * shared buffer to the console.
     135         */
     136       
    132137        while (output_buffer.read_ptr != output_buffer.write_ptr) {
    133138                do_putchar(output_buffer.data[output_buffer.read_ptr]);
    134139                output_buffer.read_ptr =
    135                         ((output_buffer.read_ptr) + 1) % OUTPUT_BUFFER_SIZE;
    136         }
    137 
     140                    ((output_buffer.read_ptr) + 1) % OUTPUT_BUFFER_SIZE;
     141        }
     142       
     143        /*
     144         * Read character from keyboard.
     145         */
     146       
    138147        uint64_t c;
    139 
    140         /* read character from keyboard, send it to upper layers of HelenOS */
    141148        if (__hypercall_fast_ret1(0, 0, 0, 0, 0, CONS_GETCHAR, &c) == HV_EOK) {
    142                 if (!silent) {
    143                         /* kconsole active, send the character to kernel */
     149                if ((!inbuf_parea.mapped) || (console_override)) {
     150                        /*
     151                         * Kernel console is active, send
     152                         * the character to kernel.
     153                         */
    144154                        indev_push_character(instance->srlnin, c);
    145155                } else {
    146                         /* kconsole inactive, send the character to uspace driver */
     156                        /*
     157                         * Kernel console is inactive, send
     158                         * the character to uspace driver.
     159                         */
    147160                        input_buffer.data[input_buffer.write_ptr] = (char) c;
    148161                        input_buffer.write_ptr =
    149                                 ((input_buffer.write_ptr) + 1) % INPUT_BUFFER_SIZE;
     162                            ((input_buffer.write_ptr) + 1) % INPUT_BUFFER_SIZE;
    150163                }
    151164        }
    152165}
    153166
    154 /**
    155  * Polling thread function.
    156  */
    157 static void kniagarapoll(void *instance) {
     167/** Polling thread function.
     168 *
     169 */
     170static void kniagarapoll(void *arg) {
    158171        while (true) {
    159                 niagara_poll(instance);
     172                niagara_poll();
    160173                thread_usleep(POLL_INTERVAL);
    161174        }
    162175}
    163176
    164 /**
    165  * Initializes the input/output subsystem so that the Niagara standard
    166  * input/output is used.
     177/** Initialize the input/output subsystem
     178 *
    167179 */
    168180static void niagara_init(void)
     
    172184       
    173185        instance = malloc(sizeof(niagara_instance_t), FRAME_ATOMIC);
    174        
    175         if (instance) {
    176                 instance->thread = thread_create(kniagarapoll, instance, TASK, 0,
    177                         "kniagarapoll", true);
    178                
    179                 if (!instance->thread) {
    180                         free(instance);
    181                         instance = NULL;
    182                         return;
    183                 }
    184         }
    185 
     186        instance->thread = thread_create(kniagarapoll, NULL, TASK, 0,
     187            "kniagarapoll", true);
     188       
     189        if (!instance->thread) {
     190                free(instance);
     191                instance = NULL;
     192                return;
     193        }
     194       
    186195        instance->srlnin = NULL;
    187 
     196       
    188197        output_buffer.read_ptr = 0;
    189198        output_buffer.write_ptr = 0;
    190199        input_buffer.write_ptr = 0;
    191200        input_buffer.read_ptr = 0;
    192 
     201       
    193202        /*
    194203         * Set sysinfos and pareas so that the userspace counterpart of the
    195204         * niagara fb and kbd driver can communicate with kernel using shared
    196205         * buffers.
    197          */
    198 
     206         */
     207       
    199208        sysinfo_set_item_val("fb.kind", NULL, 5);
    200 
     209       
    201210        sysinfo_set_item_val("niagara.outbuf.address", NULL,
    202                 KA2PA(&output_buffer));
     211            KA2PA(&output_buffer));
    203212        sysinfo_set_item_val("niagara.outbuf.size", NULL,
    204                 PAGE_SIZE);
     213            PAGE_SIZE);
    205214        sysinfo_set_item_val("niagara.outbuf.datasize", NULL,
    206                 OUTPUT_BUFFER_SIZE);
    207 
     215            OUTPUT_BUFFER_SIZE);
     216       
    208217        sysinfo_set_item_val("niagara.inbuf.address", NULL,
    209                 KA2PA(&input_buffer));
     218            KA2PA(&input_buffer));
    210219        sysinfo_set_item_val("niagara.inbuf.size", NULL,
    211                 PAGE_SIZE);
     220            PAGE_SIZE);
    212221        sysinfo_set_item_val("niagara.inbuf.datasize", NULL,
    213                 INPUT_BUFFER_SIZE);
    214 
    215         static parea_t outbuf_parea;
     222           INPUT_BUFFER_SIZE);
     223       
    216224        outbuf_parea.pbase = (uintptr_t) (KA2PA(&output_buffer));
    217225        outbuf_parea.frames = 1;
    218226        outbuf_parea.unpriv = false;
     227        outbuf_parea.mapped = false;
    219228        ddi_parea_register(&outbuf_parea);
    220 
    221         static parea_t inbuf_parea;
     229       
    222230        inbuf_parea.pbase = (uintptr_t) (KA2PA(&input_buffer));
    223231        inbuf_parea.frames = 1;
    224232        inbuf_parea.unpriv = false;
     233        inbuf_parea.mapped = false;
    225234        ddi_parea_register(&inbuf_parea);
    226 
     235       
    227236        outdev_t *niagara_dev = malloc(sizeof(outdev_t), FRAME_ATOMIC);
    228237        outdev_initialize("niagara_dev", niagara_dev, &niagara_ops);
     
    230239}
    231240
    232 /**
    233  * A public function which initializes input from the Niagara console.
     241/** Initialize input from the Niagara console.
     242 *
    234243 */
    235244niagara_instance_t *niagarain_init(void)
    236245{
    237246        niagara_init();
    238 
     247       
    239248        if (instance) {
    240249                srln_instance_t *srln_instance = srln_init();
     
    242251                        indev_t *sink = stdin_wire();
    243252                        indev_t *srln = srln_wire(srln_instance, sink);
    244 
    245                         // wire std. input to niagara
     253                       
    246254                        instance->srlnin = srln;
    247255                        thread_ready(instance->thread);
    248256                }
    249257        }
     258       
    250259        return instance;
    251260}
  • kernel/genarch/Makefile.inc

    r15f3c3f r86ffa27f  
    100100endif
    101101
    102 ifeq ($(CONFIG_Z8530),y)
    103         GENARCH_SOURCES += \
    104                 genarch/src/drivers/z8530/z8530.c
    105 endif
    106 
    107102ifeq ($(CONFIG_VIA_CUDA),y)
    108103        GENARCH_SOURCES += \
     
    141136        GENARCH_SOURCES += \
    142137                genarch/src/ofw/ebus.c \
    143                 genarch/src/ofw/fhc.c \
    144138                genarch/src/ofw/pci.c  \
    145139                genarch/src/ofw/sbus.c \
  • kernel/genarch/include/drivers/s3c24xx_uart/s3c24xx_uart.h

    r15f3c3f r86ffa27f  
    3838#define KERN_S3C24XX_UART_H_
    3939
     40#include <ddi/ddi.h>
    4041#include <ddi/irq.h>
    4142#include <console/chardev.h>
     
    8384        indev_t *indev;
    8485        irq_t irq;
     86        parea_t parea;
    8587} s3c24xx_uart_t;
    8688
    87 extern outdev_t *s3c24xx_uart_init(s3c24xx_uart_io_t *, inr_t inr);
     89extern outdev_t *s3c24xx_uart_init(uintptr_t, inr_t inr);
    8890extern void s3c24xx_uart_input_wire(s3c24xx_uart_t *,
    8991    indev_t *);
  • kernel/genarch/src/drivers/dsrln/dsrlnout.c

    r15f3c3f r86ffa27f  
    4242#include <sysinfo/sysinfo.h>
    4343#include <str.h>
     44#include <ddi/ddi.h>
    4445
    4546typedef struct {
     47        parea_t parea;
    4648        ioport8_t *base;
    4749} dsrlnout_instance_t;
    4850
    49 static void dsrlnout_putchar(outdev_t *dev, const wchar_t ch, bool silent)
     51static void dsrlnout_putchar(outdev_t *dev, const wchar_t ch)
    5052{
    5153        dsrlnout_instance_t *instance = (dsrlnout_instance_t *) dev->data;
    5254       
    53         if (!silent) {
     55        if ((!instance->parea.mapped) || (console_override)) {
    5456                if (ascii_check(ch))
    5557                        pio_write_8(instance->base, ch);
     
    7072                return NULL;
    7173       
    72         dsrlnout_instance_t *instance = malloc(sizeof(dsrlnout_instance_t), FRAME_ATOMIC);
     74        dsrlnout_instance_t *instance = malloc(sizeof(dsrlnout_instance_t),
     75            FRAME_ATOMIC);
    7376        if (!instance) {
    7477                free(dsrlndev);
     
    8083       
    8184        instance->base = base;
     85        link_initialize(&instance->parea.link);
     86        instance->parea.pbase = KA2PA(base);
     87        instance->parea.frames = 1;
     88        instance->parea.unpriv = false;
     89        instance->parea.mapped = false;
     90        ddi_parea_register(&instance->parea);
    8291       
    8392        if (!fb_exported) {
    8493                /*
    85                  * This is the necessary evil until the userspace driver is entirely
     94                 * This is the necessary evil until
     95                 * the userspace driver is entirely
    8696                 * self-sufficient.
    8797                 */
  • kernel/genarch/src/drivers/ega/ega.c

    r15f3c3f r86ffa27f  
    6464        IRQ_SPINLOCK_DECLARE(lock);
    6565       
     66        parea_t parea;
     67       
    6668        uint32_t cursor;
    6769        uint8_t *addr;
     
    7072} ega_instance_t;
    7173
    72 static void ega_putchar(outdev_t *, wchar_t, bool);
     74static void ega_putchar(outdev_t *, wchar_t);
    7375static void ega_redraw(outdev_t *);
    7476
     
    437439 * This function takes care of scrolling.
    438440 */
    439 static void ega_check_cursor(ega_instance_t *instance, bool silent)
     441static void ega_check_cursor(ega_instance_t *instance)
    440442{
    441443        if (instance->cursor < EGA_SCREEN)
     
    448450            EGA_COLS, EMPTY_CHAR);
    449451       
    450         if (!silent) {
     452        if ((!instance->parea.mapped) || (console_override)) {
    451453                memmove((void *) instance->addr,
    452454                    (void *) (instance->addr + EGA_COLS * 2),
     
    459461}
    460462
    461 static void ega_show_cursor(ega_instance_t *instance, bool silent)
    462 {
    463         if (!silent) {
     463static void ega_show_cursor(ega_instance_t *instance)
     464{
     465        if ((!instance->parea.mapped) || (console_override)) {
    464466                pio_write_8(instance->base + EGA_INDEX_REG, 0x0a);
    465467                uint8_t stat = pio_read_8(instance->base + EGA_DATA_REG);
     
    469471}
    470472
    471 static void ega_move_cursor(ega_instance_t *instance, bool silent)
    472 {
    473         if (!silent) {
     473static void ega_move_cursor(ega_instance_t *instance)
     474{
     475        if ((!instance->parea.mapped) || (console_override)) {
    474476                pio_write_8(instance->base + EGA_INDEX_REG, 0x0e);
    475477                pio_write_8(instance->base + EGA_DATA_REG,
     
    481483}
    482484
    483 static void ega_sync_cursor(ega_instance_t *instance, bool silent)
    484 {
    485         if (!silent) {
     485static void ega_sync_cursor(ega_instance_t *instance)
     486{
     487        if ((!instance->parea.mapped) || (console_override)) {
    486488                pio_write_8(instance->base + EGA_INDEX_REG, 0x0e);
    487489                uint8_t hi = pio_read_8(instance->base + EGA_DATA_REG);
     
    503505            EGA_SCREEN - instance->cursor, EMPTY_CHAR);
    504506       
    505         if (!silent)
     507        if ((!instance->parea.mapped) || (console_override))
    506508                memsetw(instance->addr + instance->cursor * 2,
    507509                    EGA_SCREEN - instance->cursor, EMPTY_CHAR);
    508510       
    509         ega_check_cursor(instance, silent);
    510         ega_move_cursor(instance, silent);
    511         ega_show_cursor(instance, silent);
    512 }
    513 
    514 static void ega_display_char(ega_instance_t *instance, wchar_t ch, bool silent)
     511        ega_check_cursor(instance);
     512        ega_move_cursor(instance);
     513        ega_show_cursor(instance);
     514}
     515
     516static void ega_display_char(ega_instance_t *instance, wchar_t ch)
    515517{
    516518        uint16_t index = ega_oem_glyph(ch);
     
    529531        instance->backbuf[instance->cursor * 2 + 1] = style;
    530532       
    531         if (!silent) {
     533        if ((!instance->parea.mapped) || (console_override)) {
    532534                instance->addr[instance->cursor * 2] = glyph;
    533535                instance->addr[instance->cursor * 2 + 1] = style;
     
    535537}
    536538
    537 static void ega_putchar(outdev_t *dev, wchar_t ch, bool silent)
     539static void ega_putchar(outdev_t *dev, wchar_t ch)
    538540{
    539541        ega_instance_t *instance = (ega_instance_t *) dev->data;
     
    555557                break;
    556558        default:
    557                 ega_display_char(instance, ch, silent);
     559                ega_display_char(instance, ch);
    558560                instance->cursor++;
    559561                break;
    560562        }
    561         ega_check_cursor(instance, silent);
    562         ega_move_cursor(instance, silent);
     563        ega_check_cursor(instance);
     564        ega_move_cursor(instance);
    563565       
    564566        irq_spinlock_unlock(&instance->lock, true);
     
    572574       
    573575        memcpy(instance->addr, instance->backbuf, EGA_VRAM_SIZE);
    574         ega_move_cursor(instance, silent);
    575         ega_show_cursor(instance, silent);
     576        ega_move_cursor(instance);
     577        ega_show_cursor(instance);
    576578       
    577579        irq_spinlock_unlock(&instance->lock, true);
     
    612614        }
    613615       
     616        link_initialize(&instance->parea.link);
     617        instance->parea.pbase = addr;
     618        instance->parea.frames = SIZE2FRAMES(EGA_VRAM_SIZE);
     619        instance->parea.unpriv = false;
     620        instance->parea.mapped = false;
     621        ddi_parea_register(&instance->parea);
     622       
    614623        /* Synchronize the back buffer and cursor position. */
    615624        memcpy(instance->backbuf, instance->addr, EGA_VRAM_SIZE);
    616         ega_sync_cursor(instance, silent);
     625        ega_sync_cursor(instance);
    617626       
    618627        if (!fb_exported) {
    619628                /*
    620                  * This is the necessary evil until the userspace driver is entirely
    621                  * self-sufficient.
     629                 * We export the kernel framebuffer for uspace usage.
     630                 * This is used in the case the uspace framebuffer
     631                 * driver is not self-sufficient.
    622632                 */
    623633                sysinfo_set_item_val("fb", NULL, true);
  • kernel/genarch/src/drivers/s3c24xx_uart/s3c24xx_uart.c

    r15f3c3f r86ffa27f  
    4444#include <arch/asm.h>
    4545#include <mm/slab.h>
     46#include <mm/page.h>
    4647#include <sysinfo/sysinfo.h>
    4748#include <str.h>
     
    5960}
    6061
    61 static void s3c24xx_uart_putchar(outdev_t *dev, wchar_t ch, bool silent)
     62static void s3c24xx_uart_putchar(outdev_t *dev, wchar_t ch)
    6263{
    63         if (!silent) {
     64        s3c24xx_uart_t *uart =
     65            (s3c24xx_uart_t *) dev->data;
     66       
     67        if ((!uart->parea.mapped) || (console_override)) {
    6468                if (!ascii_check(ch)) {
    6569                        s3c24xx_uart_sendb(dev, U_SPECIAL);
    6670                } else {
    67                         if (ch == '\n')
     71                        if (ch == '\n')
    6872                                s3c24xx_uart_sendb(dev, (uint8_t) '\r');
    6973                        s3c24xx_uart_sendb(dev, (uint8_t) ch);
     
    9397};
    9498
    95 outdev_t *s3c24xx_uart_init(s3c24xx_uart_io_t *io, inr_t inr)
     99outdev_t *s3c24xx_uart_init(uintptr_t paddr, inr_t inr)
    96100{
    97101        outdev_t *uart_dev = malloc(sizeof(outdev_t), FRAME_ATOMIC);
     
    109113        uart_dev->data = uart;
    110114
    111         uart->io = io;
     115        uart->io = (s3c24xx_uart_io_t *) hw_map(paddr, PAGE_SIZE);
    112116        uart->indev = NULL;
    113117
     
    127131        pio_write_32(&uart->io->ucon,
    128132            pio_read_32(&uart->io->ucon) & ~UCON_RX_INT_LEVEL);
    129 
     133       
     134        link_initialize(&uart->parea.link);
     135        uart->parea.pbase = paddr;
     136        uart->parea.frames = 1;
     137        uart->parea.unpriv = false;
     138        uart->parea.mapped = false;
     139        ddi_parea_register(&uart->parea);
     140       
    130141        if (!fb_exported) {
    131142                /*
    132                  * This is the necessary evil until the userspace driver is entirely
     143                 * This is the necessary evil until
     144                 * the userspace driver is entirely
    133145                 * self-sufficient.
    134146                 */
    135147                sysinfo_set_item_val("fb", NULL, true);
    136148                sysinfo_set_item_val("fb.kind", NULL, 3);
    137                 sysinfo_set_item_val("fb.address.physical", NULL, KA2PA(io));
     149                sysinfo_set_item_val("fb.address.physical", NULL, paddr);
    138150
    139151                fb_exported = true;
  • kernel/genarch/src/fb/fb.c

    r15f3c3f r86ffa27f  
    8282        SPINLOCK_DECLARE(lock);
    8383       
     84        parea_t parea;
     85       
    8486        uint8_t *addr;
    8587        uint16_t *backbuf;
     
    109111} fb_instance_t;
    110112
    111 static void fb_putchar(outdev_t *dev, wchar_t ch, bool silent);
     113static void fb_putchar(outdev_t *dev, wchar_t ch);
    112114static void fb_redraw_internal(fb_instance_t *instance);
    113115static void fb_redraw(outdev_t *dev);
     
    215217 *
    216218 */
    217 static void logo_hide(fb_instance_t *instance, bool silent)
     219static void logo_hide(fb_instance_t *instance)
    218220{
    219221        instance->ylogo = 0;
     
    221223        instance->rowtrim = instance->rows;
    222224       
    223         if (!silent)
     225        if ((!instance->parea.mapped) || (console_override))
    224226                fb_redraw_internal(instance);
    225227}
     
    229231 */
    230232static void glyph_draw(fb_instance_t *instance, uint16_t glyph,
    231     unsigned int col, unsigned int row, bool silent, bool overlay)
     233    unsigned int col, unsigned int row, bool overlay)
    232234{
    233235        unsigned int x = COL2X(col);
     
    236238       
    237239        if (y >= instance->ytrim)
    238                 logo_hide(instance, silent);
     240                logo_hide(instance);
    239241       
    240242        if (!overlay)
    241243                instance->backbuf[BB_POS(instance, col, row)] = glyph;
    242244       
    243         if (!silent) {
     245        if ((!instance->parea.mapped) || (console_override)) {
    244246                for (yd = 0; yd < FONT_SCANLINES; yd++)
    245247                        memcpy(&instance->addr[FB_POS(instance, x, y + yd + instance->ylogo)],
     
    253255 *
    254256 */
    255 static void screen_scroll(fb_instance_t *instance, bool silent)
     257static void screen_scroll(fb_instance_t *instance)
    256258{
    257259        if (instance->ylogo > 0) {
    258                 logo_hide(instance, silent);
     260                logo_hide(instance);
    259261                return;
    260262        }
    261263       
    262         if (!silent) {
     264        if ((!instance->parea.mapped) || (console_override)) {
    263265                unsigned int row;
    264266               
     
    298300}
    299301
    300 static void cursor_put(fb_instance_t *instance, bool silent)
     302static void cursor_put(fb_instance_t *instance)
    301303{
    302304        unsigned int col = instance->position % instance->cols;
    303305        unsigned int row = instance->position / instance->cols;
    304306       
    305         glyph_draw(instance, fb_font_glyph(U_CURSOR), col, row, silent, true);
    306 }
    307 
    308 static void cursor_remove(fb_instance_t *instance, bool silent)
     307        glyph_draw(instance, fb_font_glyph(U_CURSOR), col, row, true);
     308}
     309
     310static void cursor_remove(fb_instance_t *instance)
    309311{
    310312        unsigned int col = instance->position % instance->cols;
     
    312314       
    313315        glyph_draw(instance, instance->backbuf[BB_POS(instance, col, row)],
    314             col, row, silent, true);
     316            col, row, true);
    315317}
    316318
     
    362364 *
    363365 */
    364 static void fb_putchar(outdev_t *dev, wchar_t ch, bool silent)
     366static void fb_putchar(outdev_t *dev, wchar_t ch)
    365367{
    366368        fb_instance_t *instance = (fb_instance_t *) dev->data;
     
    369371        switch (ch) {
    370372        case '\n':
    371                 cursor_remove(instance, silent);
     373                cursor_remove(instance);
    372374                instance->position += instance->cols;
    373375                instance->position -= instance->position % instance->cols;
    374376                break;
    375377        case '\r':
    376                 cursor_remove(instance, silent);
     378                cursor_remove(instance);
    377379                instance->position -= instance->position % instance->cols;
    378380                break;
    379381        case '\b':
    380                 cursor_remove(instance, silent);
     382                cursor_remove(instance);
    381383                if (instance->position % instance->cols)
    382384                        instance->position--;
    383385                break;
    384386        case '\t':
    385                 cursor_remove(instance, silent);
     387                cursor_remove(instance);
    386388                do {
    387389                        glyph_draw(instance, fb_font_glyph(' '),
    388390                            instance->position % instance->cols,
    389                             instance->position / instance->cols, silent, false);
     391                            instance->position / instance->cols, false);
    390392                        instance->position++;
    391393                } while ((instance->position % 8)
     
    395397                glyph_draw(instance, fb_font_glyph(ch),
    396398                    instance->position % instance->cols,
    397                     instance->position / instance->cols, silent, false);
     399                    instance->position / instance->cols, false);
    398400                instance->position++;
    399401        }
     
    401403        if (instance->position >= instance->cols * instance->rows) {
    402404                instance->position -= instance->cols;
    403                 screen_scroll(instance, silent);
    404         }
    405        
    406         cursor_put(instance, silent);
     405                screen_scroll(instance);
     406        }
     407       
     408        cursor_put(instance);
    407409       
    408410        spinlock_unlock(&instance->lock);
     
    555557       
    556558        spinlock_initialize(&instance->lock, "*fb.instance.lock");
     559       
    557560        instance->rgb_conv = rgb_conv;
    558561        instance->pixelbytes = pixelbytes;
     
    623626        glyphs_render(instance);
    624627       
     628        link_initialize(&instance->parea.link);
     629        instance->parea.pbase = props->addr;
     630        instance->parea.frames = SIZE2FRAMES(fbsize);
     631        instance->parea.unpriv = false;
     632        instance->parea.mapped = false;
     633        ddi_parea_register(&instance->parea);
     634       
    625635        if (!fb_exported) {
    626636                /*
    627                  * This is the necessary evil until the userspace driver is entirely
    628                  * self-sufficient.
     637                 * We export the kernel framebuffer for uspace usage.
     638                 * This is used in the case the uspace framebuffer
     639                 * driver is not self-sufficient.
    629640                 */
    630641                sysinfo_set_item_val("fb", NULL, true);
  • kernel/generic/include/console/chardev.h

    r15f3c3f r86ffa27f  
    7373typedef struct {
    7474        /** Write character to output. */
    75         void (* write)(struct outdev *, wchar_t, bool);
     75        void (* write)(struct outdev *, wchar_t);
    7676       
    7777        /** Redraw any previously cached characters. */
  • kernel/generic/include/console/console.h

    r15f3c3f r86ffa27f  
    7272extern void release_console(void);
    7373
    74 extern sysarg_t sys_debug_enable_console(void);
    75 extern sysarg_t sys_debug_disable_console(void);
     74extern sysarg_t sys_debug_activate_console(void);
    7675
    7776#endif /* KERN_CONSOLE_H_ */
  • kernel/generic/include/ddi/ddi.h

    r15f3c3f r86ffa27f  
    4848        pfn_t frames;     /**< Number of frames in the area. */
    4949        bool unpriv;      /**< Allow mapping by unprivileged tasks. */
     50        bool mapped;      /**< Indicate whether the area is actually
     51                               mapped. */
    5052} parea_t;
    5153
  • kernel/generic/include/lib/elf.h

    r15f3c3f r86ffa27f  
    106106#define ELFDATA2LSB  1  /* Least significant byte first (little endian) */
    107107#define ELFDATA2MSB  2  /* Most signigicant byte first (big endian) */
    108 
    109 /**
    110  * ELF error return codes
    111  */
    112 #define EE_OK             0  /* No error */
    113 #define EE_INVALID        1  /* Invalid ELF image */
    114 #define EE_MEMORY         2  /* Cannot allocate address space */
    115 #define EE_INCOMPATIBLE   3  /* ELF image is not compatible with current architecture */
    116 #define EE_UNSUPPORTED    4  /* Non-supported ELF (e.g. dynamic ELFs) */
    117 #define EE_LOADER         5  /* The image is actually a program loader */
    118 #define EE_IRRECOVERABLE  6
    119108
    120109/**
     
    149138#define SHF_MASKPROC   0xf0000000
    150139
     140/** Macros for decomposing elf_symbol.st_info into binging and type */
     141#define ELF_ST_BIND(i)     ((i) >> 4)
     142#define ELF_ST_TYPE(i)     ((i) & 0x0f)
     143#define ELF_ST_INFO(b, t)  (((b) << 4) + ((t) & 0x0f))
     144
    151145/**
    152146 * Symbol binding
     
    195189 * ELF object file specifications. They are the only types used
    196190 * in ELF header.
    197  *
    198191 */
    199192typedef uint64_t elf_xword;
     
    207200 *
    208201 * These types are specific for 32-bit format.
    209  *
    210202 */
    211203typedef uint32_t elf32_addr;
     
    216208 *
    217209 * These types are specific for 64-bit format.
    218  *
    219210 */
    220211typedef uint64_t elf64_addr;
     
    332323};
    333324
     325/*
     326 * ELF note segment entry
     327 */
     328struct elf32_note {
     329        elf_word namesz;
     330        elf_word descsz;
     331        elf_word type;
     332};
     333
     334/*
     335 * NOTE: namesz, descsz and type should be 64-bits wide (elf_xword)
     336 * per the 64-bit ELF spec. The Linux kernel however screws up and
     337 * defines them as Elf64_Word, which is 32-bits wide(!). We are trying
     338 * to make our core files compatible with Linux GDB target so we copy
     339 * the blunder here.
     340 */
     341struct elf64_note {
     342        elf_word namesz;
     343        elf_word descsz;
     344        elf_word type;
     345};
     346
    334347#ifdef __32_BITS__
    335348typedef struct elf32_header elf_header_t;
     
    337350typedef struct elf32_section_header elf_section_header_t;
    338351typedef struct elf32_symbol elf_symbol_t;
     352typedef struct elf32_note elf_note_t;
    339353#endif
    340354
     
    344358typedef struct elf64_section_header elf_section_header_t;
    345359typedef struct elf64_symbol elf_symbol_t;
     360typedef struct elf64_note elf_note_t;
    346361#endif
    347 
    348 extern const char *elf_error(unsigned int rc);
    349362
    350363/** Interpreter string used to recognize the program loader */
  • kernel/generic/include/mm/as.h

    r15f3c3f r86ffa27f  
    6565#include <arch/mm/as.h>
    6666#include <arch/mm/asid.h>
     67#include <arch/istate.h>
    6768#include <typedefs.h>
    6869#include <synch/spinlock.h>
     
    306307extern mem_backend_t phys_backend;
    307308
    308 /**
    309  * This flags is passed when running the loader, otherwise elf_load()
    310  * would return with a EE_LOADER error code.
    311  *
    312  */
    313 #define ELD_F_NONE    0
    314 #define ELD_F_LOADER  1
    315 
    316 extern unsigned int elf_load(elf_header_t *, as_t *, unsigned int);
    317 
    318309/* Address space area related syscalls. */
    319310extern sysarg_t sys_as_area_create(uintptr_t, size_t, unsigned int);
  • kernel/generic/include/panic.h

    r15f3c3f r86ffa27f  
    6060struct istate;
    6161
    62 extern bool silent;
     62extern bool console_override;
    6363
    6464extern void panic_common(panic_category_t, struct istate *, int,
  • kernel/generic/include/syscall/syscall.h

    r15f3c3f r86ffa27f  
    9494        SYS_SYSINFO_GET_DATA,
    9595       
    96         SYS_DEBUG_ENABLE_CONSOLE,
    97         SYS_DEBUG_DISABLE_CONSOLE,
     96        SYS_DEBUG_ACTIVATE_CONSOLE,
    9897       
    9998        SYSCALL_END
  • kernel/generic/src/console/console.c

    r15f3c3f r86ffa27f  
    8787};
    8888
    89 static void stdout_write(outdev_t *, wchar_t, bool);
     89static void stdout_write(outdev_t *, wchar_t);
    9090static void stdout_redraw(outdev_t *);
    9191
     
    9595};
    9696
    97 /** Silence output */
    98 bool silent = false;
     97/** Override kernel console lockout */
     98bool console_override = false;
    9999
    100100/** Standard input and output character devices */
     
    122122}
    123123
    124 static void stdout_write(outdev_t *dev, wchar_t ch, bool silent)
     124static void stdout_write(outdev_t *dev, wchar_t ch)
    125125{
    126126        list_foreach(dev->list, cur) {
    127127                outdev_t *sink = list_get_instance(cur, outdev_t, link);
    128128                if ((sink) && (sink->op->write))
    129                         sink->op->write(sink, ch, silent);
     129                        sink->op->write(sink, ch);
    130130        }
    131131}
     
    156156        klog_parea.frames = SIZE2FRAMES(sizeof(klog));
    157157        klog_parea.unpriv = false;
     158        klog_parea.mapped = false;
    158159        ddi_parea_register(&klog_parea);
    159160       
     
    167168void grab_console(void)
    168169{
    169         bool prev = silent;
    170        
    171         silent = false;
     170        bool prev = console_override;
     171       
     172        console_override = true;
    172173        if ((stdout) && (stdout->op->redraw))
    173174                stdout->op->redraw(stdout);
    174175       
    175         if ((stdin) && (prev)) {
     176        if ((stdin) && (!prev)) {
    176177                /*
    177178                 * Force the console to print the prompt.
     
    183184void release_console(void)
    184185{
    185         // FIXME arch_release_console
    186         silent = true;
    187 }
    188 
    189 /** Tell kernel to get keyboard/console access again */
    190 sysarg_t sys_debug_enable_console(void)
     186        console_override = false;
     187}
     188
     189/** Activate kernel console override */
     190sysarg_t sys_debug_activate_console(void)
    191191{
    192192#ifdef CONFIG_KCONSOLE
     
    196196        return false;
    197197#endif
    198 }
    199 
    200 /** Tell kernel to relinquish keyboard/console access */
    201 sysarg_t sys_debug_disable_console(void)
    202 {
    203         release_console();
    204         return true;
    205198}
    206199
     
    289282                         */
    290283                        spinlock_unlock(&klog_lock);
    291                         stdout->op->write(stdout, tmp, silent);
     284                        stdout->op->write(stdout, tmp);
    292285                        spinlock_lock(&klog_lock);
    293286                }
     
    317310                 * it should be no longer buffered.
    318311                 */
    319                 stdout->op->write(stdout, ch, silent);
     312                stdout->op->write(stdout, ch);
    320313        } else {
    321314                /*
  • kernel/generic/src/ddi/ddi.c

    r15f3c3f r86ffa27f  
    122122        backend_data.frames = pages;
    123123       
    124         /* Find the zone of the physical memory */
     124        /*
     125         * Check if the memory region is explicitly enabled
     126         * for mapping by any parea structure.
     127         */
     128       
     129        mutex_lock(&parea_lock);
     130        btree_node_t *nodep;
     131        parea_t *parea = (parea_t *) btree_search(&parea_btree,
     132            (btree_key_t) pf, &nodep);
     133       
     134        if ((parea != NULL) && (parea->frames >= pages)) {
     135                if ((!priv) && (!parea->unpriv)) {
     136                        mutex_unlock(&parea_lock);
     137                        return EPERM;
     138                }
     139               
     140                goto map;
     141        }
     142       
     143        parea = NULL;
     144        mutex_unlock(&parea_lock);
     145       
     146        /*
     147         * Check if the memory region is part of physical
     148         * memory generally enabled for mapping.
     149         */
     150       
    125151        irq_spinlock_lock(&zones.lock, true);
    126152        size_t znum = find_zone(ADDR2PFN(pf), pages, 0);
     
    153179        }
    154180       
    155         if (zone_flags_available(zones.info[znum].flags)) {
    156                 /*
    157                  * Frames are part of physical memory, check
    158                  * if the memory region is enabled for mapping.
    159                  */
    160                 irq_spinlock_unlock(&zones.lock, true);
    161                
    162                 mutex_lock(&parea_lock);
    163                 btree_node_t *nodep;
    164                 parea_t *parea = (parea_t *) btree_search(&parea_btree,
    165                     (btree_key_t) pf, &nodep);
    166                
    167                 if ((!parea) || (parea->frames < pages)) {
    168                         mutex_unlock(&parea_lock);
    169                         return ENOENT;
    170                 }
    171                
    172                 if (!priv) {
    173                         if (!parea->unpriv) {
    174                                 mutex_unlock(&parea_lock);
    175                                 return EPERM;
    176                         }
    177                 }
    178                
    179                 mutex_unlock(&parea_lock);
    180                 goto map;
    181         }
    182        
    183181        irq_spinlock_unlock(&zones.lock, true);
    184182        return ENOENT;
     
    188186            AS_AREA_ATTR_NONE, &phys_backend, &backend_data)) {
    189187                /*
    190                  * The address space area could not have been created.
     188                 * The address space area was not created.
    191189                 * We report it using ENOMEM.
    192190                 */
     191               
     192                if (parea != NULL)
     193                        mutex_unlock(&parea_lock);
     194               
    193195                return ENOMEM;
    194196        }
     
    197199         * Mapping is created on-demand during page fault.
    198200         */
    199         return 0;
     201       
     202        if (parea != NULL) {
     203                parea->mapped = true;
     204                mutex_unlock(&parea_lock);
     205        }
     206       
     207        return EOK;
    200208}
    201209
  • kernel/generic/src/ddi/irq.c

    r15f3c3f r86ffa27f  
    275275{
    276276        /*
    277          * If the kernel console is silenced,
    278          * then try first the uspace handlers,
    279          * eventually fall back to kernel handlers.
     277         * If the kernel console override is on,
     278         * then try first the kernel handlers
     279         * and eventually fall back to uspace
     280         * handlers.
    280281         *
    281          * If the kernel console is active,
    282          * then do it the other way around.
     282         * In the usual case the uspace handlers
     283         * have precedence.
    283284         */
    284         if (silent) {
    285                 irq_t *irq = irq_dispatch_and_lock_uspace(inr);
     285       
     286        if (console_override) {
     287                irq_t *irq = irq_dispatch_and_lock_kernel(inr);
    286288                if (irq)
    287289                        return irq;
    288290               
    289                 return irq_dispatch_and_lock_kernel(inr);
    290         }
    291        
    292         irq_t *irq = irq_dispatch_and_lock_kernel(inr);
     291                return irq_dispatch_and_lock_uspace(inr);
     292        }
     293       
     294        irq_t *irq = irq_dispatch_and_lock_uspace(inr);
    293295        if (irq)
    294296                return irq;
    295297       
    296         return irq_dispatch_and_lock_uspace(inr);
     298        return irq_dispatch_and_lock_kernel(inr);
    297299}
    298300
  • kernel/generic/src/debug/panic.c

    r15f3c3f r86ffa27f  
    4848    uintptr_t address, const char *fmt, ...)
    4949{
    50         va_list args;
    51        
    52         silent = false;
     50        console_override = true;
    5351       
    5452        printf("\n%s Kernel panic ", BANNER_LEFT);
     
    5755        printf("due to ");
    5856       
     57        va_list args;
    5958        va_start(args, fmt);
    6059        if (cat == PANIC_ASSERT) {
  • kernel/generic/src/lib/elf.c

    r15f3c3f r86ffa27f  
    4747#include <macros.h>
    4848#include <arch.h>
     49
     50#include <lib/elf_load.h>
    4951
    5052static const char *error_codes[] = {
  • kernel/generic/src/lib/rd.c

    r15f3c3f r86ffa27f  
    9191        rd_parea.frames = SIZE2FRAMES(dsize);
    9292        rd_parea.unpriv = false;
     93        rd_parea.mapped = false;
    9394        ddi_parea_register(&rd_parea);
    9495
  • kernel/generic/src/mm/as.c

    r15f3c3f r86ffa27f  
    12841284 * thing which is forbidden in this context is locking the address space.
    12851285 *
    1286  * When this function is enetered, no spinlocks may be held.
     1286 * When this function is entered, no spinlocks may be held.
    12871287 *
    12881288 * @param old Old address space or NULL.
  • kernel/generic/src/proc/program.c

    r15f3c3f r86ffa27f  
    4848#include <ipc/ipcrsc.h>
    4949#include <security/cap.h>
    50 #include <lib/elf.h>
     50#include <lib/elf_load.h>
    5151#include <errno.h>
    5252#include <print.h>
  • kernel/generic/src/syscall/syscall.c

    r15f3c3f r86ffa27f  
    186186        (syshandler_t) sys_sysinfo_get_data,
    187187       
    188         /* Debug calls */
    189         (syshandler_t) sys_debug_enable_console,
    190         (syshandler_t) sys_debug_disable_console
     188        /* Kernel console syscalls. */
     189        (syshandler_t) sys_debug_activate_console
    191190};
    192191
  • kernel/generic/src/time/clock.c

    r15f3c3f r86ffa27f  
    9494        clock_parea.frames = 1;
    9595        clock_parea.unpriv = true;
     96        clock_parea.mapped = false;
    9697        ddi_parea_register(&clock_parea);
    9798       
Note: See TracChangeset for help on using the changeset viewer.