Changeset bee37cf in mainline for kernel/arch


Ignore:
Timestamp:
2011-07-05T21:21:36Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5e2aa83, eb66f236
Parents:
3714e79 (diff), f7a55f9 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

Location:
kernel/arch
Files:
48 added
3 deleted
21 edited
3 moved

Legend:

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

    r3714e79 rbee37cf  
    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

    r3714e79 rbee37cf  
    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

    r3714e79 rbee37cf  
    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

    r3714e79 rbee37cf  
    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/src/drivers/ski.c

    r3714e79 rbee37cf  
    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/mips32/Makefile.inc

    r3714e79 rbee37cf  
    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

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

    r3714e79 rbee37cf  
    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

    r3714e79 rbee37cf  
    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

    r3714e79 rbee37cf  
    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

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

    r3714e79 rbee37cf  
    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

    r3714e79 rbee37cf  
    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

    r3714e79 rbee37cf  
    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

    r3714e79 rbee37cf  
    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

    r3714e79 rbee37cf  
    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/cpu.h

    r3714e79 rbee37cf  
    11/*
    2  * Copyright (c) 2010 Jiri Svoboda
     2 * Copyright (c) 2003-2004 Jakub Jermar
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup mouse
    30  * @brief
     29/** @addtogroup mips64
    3130 * @{
    3231 */
     
    3433 */
    3534
    36 #ifndef ADB_MOUSE_H_
    37 #define ADB_MOUSE_H_
     35#ifndef KERN_mips64_CPU_H_
     36#define KERN_mips64_CPU_H_
    3837
    39 #include <sys/types.h>
     38#include <typedefs.h>
     39#include <arch/asm.h>
    4040
    41 #define NAME       "adb_ms"
    42 #define NAMESPACE  "hid_in"
    43 
    44 extern void mouse_handle_data(uint16_t);
     41typedef struct {
     42        uint32_t imp_num;
     43        uint32_t rev_num;
     44} cpu_arch_t;
    4545
    4646#endif
    4747
    48 /**
    49  * @}
     48/** @}
    5049 */
  • kernel/arch/mips64/include/interrupt.h

    r3714e79 rbee37cf  
    11/*
    2  * Copyright (c) 2006 Jakub Jermar
     2 * Copyright (c) 2003-2004 Jakub Jermar
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup sparc64
     29/** @addtogroup mips64
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #ifndef KERN_sparc64_FHC_H_
    36 #define KERN_sparc64_FHC_H_
     35#ifndef KERN_mips64_INTERRUPT_H_
     36#define KERN_mips64_INTERRUPT_H_
    3737
    3838#include <typedefs.h>
    39 #include <genarch/ofw/ofw_tree.h>
     39#include <arch/exception.h>
    4040
    41 typedef struct {
    42         volatile uint32_t *uart_imap;
    43 } fhc_t;
     41#define IVT_ITEMS  32
     42#define IVT_FIRST  0
    4443
    45 extern fhc_t *central_fhc;
     44#define VECTOR_TLB_SHOOTDOWN_IPI  EXC_Int
    4645
    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);
     46extern function virtual_timer_fnc;
     47extern uint32_t count_hi;
     48
     49extern void interrupt_init(void);
    5050
    5151#endif
  • kernel/arch/mips64/include/types.h

    r3714e79 rbee37cf  
    11/*
    2  * Copyright (c) 2010 Jakub Jermar
     2 * Copyright (c) 2003-2004 Jakub Jermar
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup libc
     29/** @addtogroup mips64
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #ifndef LIBC_ASYNC_SESS_H_
    36 #define LIBC_ASYNC_SESS_H_
     35#ifndef KERN_mips64_TYPES_H_
     36#define KERN_mips64_TYPES_H_
    3737
    38 #include <adt/list.h>
     38typedef uint64_t size_t;
     39typedef int64_t ssize_t;
     40
     41typedef uint64_t uintptr_t;
     42typedef uint64_t pfn_t;
     43
     44typedef uint64_t ipl_t;
     45
     46typedef uint64_t sysarg_t;
     47typedef int64_t native_t;
     48typedef uint64_t atomic_count_t;
    3949
    4050typedef struct {
    41         int sess_phone;         /**< Phone for cloning off the connections. */
    42         sysarg_t connect_arg1;  /**< Argument for CONNECT_ME_TO. */
    43         link_t conn_head;       /**< List of open data connections. */
    44         link_t sess_link;       /**< Link in global list of open sessions. */
    45 } async_sess_t;
     51} fncptr_t;
    4652
    47 extern void async_session_create(async_sess_t *, int, sysarg_t);
    48 extern void async_session_destroy(async_sess_t *);
    49 extern int async_exchange_begin(async_sess_t *);
    50 extern void async_exchange_end(async_sess_t *, int);
     53#define INTN_C(c)   INT64_C(c)
     54#define UINTN_C(c)  UINT64_C(c)
     55
     56#define PRIdn  PRId64  /**< Format for native_t. */
     57#define PRIun  PRIu64  /**< Format for sysarg_t. */
     58#define PRIxn  PRIx64  /**< Format for hexadecimal sysarg_t. */
     59#define PRIua  PRIu64  /**< Format for atomic_count_t. */
    5160
    5261#endif
  • kernel/arch/sparc64/Makefile.inc

    r3714e79 rbee37cf  
    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

    r3714e79 rbee37cf  
    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

    r3714e79 rbee37cf  
    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

    r3714e79 rbee37cf  
    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/arch/sparc64/src/drivers/tick.c

    r3714e79 rbee37cf  
    4444#include <debug.h>
    4545
    46 #define TICK_RESTART_TIME       50      /* Worst case estimate. */
    47 
    4846/** Initialize tick and stick interrupt. */
    4947void tick_init(void)
     
    5149        /* initialize TICK interrupt */
    5250        tick_compare_reg_t compare;
     51        softint_reg_t clear;
    5352
    5453        interrupt_register(14, "tick_int", tick_interrupt);
     
    5958        tick_compare_write(compare.value);
    6059
     60        clear.value = 0;
     61        clear.tick_int = 1;
     62        clear_softint_write(clear.value);
     63
    6164#if defined (US3) || defined (SUN4V)
    6265        /* disable STICK interrupts and clear any pending ones */
    6366        tick_compare_reg_t stick_compare;
    64         softint_reg_t clear;
    6567
    6668        stick_compare.value = stick_compare_read();
Note: See TracChangeset for help on using the changeset viewer.