Changeset 86ffa27f in mainline for kernel/generic


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/generic
Files:
1 added
17 edited

Legend:

Unmodified
Added
Removed
  • 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.