Changeset ae318d3 in mainline


Ignore:
Timestamp:
2009-02-16T18:50:48Z (16 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
06da55b
Parents:
17f168e
Message:

overhaul pareas: use one single physical area for the physical address space not belonging to physical memory

Files:
40 edited

Legend:

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

    r17f168e rae318d3  
    4545#ifndef __ASM__
    4646extern uintptr_t last_frame;
     47extern uintptr_t end_frame;
    4748extern void frame_arch_init(void);
    4849extern void physmem_print(void);
  • kernel/arch/amd64/src/mm/page.c

    r17f168e rae318d3  
    215215}
    216216
     217void hw_area(uintptr_t *physaddr, pfn_t *frames)
     218{
     219        *physaddr = end_frame;
     220        *frames = ADDR2PFN(0xfffffffffffff - end_frame);
     221}
     222
    217223/** @}
    218224 */
  • kernel/arch/arm32/include/mm/frame.h

    r17f168e rae318d3  
    5252
    5353extern uintptr_t last_frame;
     54extern uintptr_t end_frame;
    5455
    5556extern void frame_arch_init(void);
  • kernel/arch/arm32/src/mm/frame.c

    r17f168e rae318d3  
    4242/** Address of the last frame in the memory. */
    4343uintptr_t last_frame = 0;
     44uintptr_t end_frame = 0;
    4445
    4546/** Creates memory zones. */
     
    5051            BOOT_PAGE_TABLE_START_FRAME + BOOT_PAGE_TABLE_SIZE_IN_FRAMES, 0);
    5152        last_frame = machine_get_memory_size();
    52 
     53        end_frame = last_frame;
     54       
    5355        /* blacklist boot page table */
    5456        frame_mark_unavailable(BOOT_PAGE_TABLE_START_FRAME,
  • kernel/arch/arm32/src/mm/page.c

    r17f168e rae318d3  
    107107}
    108108
     109void hw_area(uintptr_t *physaddr, pfn_t *frames)
     110{
     111        *physaddr = end_frame;
     112        *frames = ADDR2PFN(0xffffffff - end_frame);
     113}
     114
    109115/** @}
    110116 */
  • kernel/arch/ia32/include/mm/frame.h

    r17f168e rae318d3  
    4545
    4646extern uintptr_t last_frame;
     47extern uintptr_t end_frame;
    4748
    4849extern void frame_arch_init(void);
  • kernel/arch/ia32/src/mm/frame.c

    r17f168e rae318d3  
    5151
    5252uintptr_t last_frame = 0;
     53uintptr_t end_frame = 0;
    5354
    5455static void init_e820_memory(pfn_t minconf)
     
    7475                                last_frame =
    7576                                    ALIGN_UP(e820table[i].base_address + e820table[i].size, FRAME_SIZE);
    76                 }                       
     77                }
    7778        }
     79       
     80        end_frame = last_frame;
    7881}
    7982
     
    114117        if (config.cpu_active == 1) {
    115118                minconf = 1;
     119               
    116120#ifdef CONFIG_SMP
    117121                minconf = max(minconf,
     
    120124#endif
    121125                init_e820_memory(minconf);
    122 
     126               
    123127                /* Reserve frame 0 (BIOS data) */
    124128                frame_mark_unavailable(0, 1);
  • kernel/arch/ia32/src/mm/page.c

    r17f168e rae318d3  
    9494}
    9595
     96void hw_area(uintptr_t *physaddr, pfn_t *frames)
     97{
     98        *physaddr = end_frame;
     99        *frames = ADDR2PFN(0xffffffff - end_frame);
     100}
     101
    96102void page_fault(int n __attribute__((unused)), istate_t *istate)
    97103{
     
    103109        if (istate->error_word & PFERR_CODE_RSVD)
    104110                panic("Reserved bit set in page directory.");
    105 
     111       
    106112        if (istate->error_word & PFERR_CODE_RW)
    107113                access = PF_ACCESS_WRITE;
  • kernel/arch/ia64/include/mm/frame.h

    r17f168e rae318d3  
    4545
    4646extern uintptr_t last_frame;
     47extern uintptr_t end_frame;
    4748
    4849extern void frame_arch_init(void);
  • kernel/arch/ia64/src/mm/frame.c

    r17f168e rae318d3  
    5252
    5353uintptr_t last_frame = 0;
     54uintptr_t end_frame = 0;
    5455
    5556void frame_arch_init(void)
  • kernel/arch/ia64/src/mm/page.c

    r17f168e rae318d3  
    275275}
    276276
     277void hw_area(uintptr_t *physaddr, pfn_t *frames)
     278{
     279        *physaddr = end_frame;
     280        *frames = ADDR2PFN(0x7fffffffffffffffUL - end_frame);
     281}
     282
    277283/** @}
    278284 */
  • kernel/arch/mips32/include/mm/frame.h

    r17f168e rae318d3  
    3636#define KERN_mips32_FRAME_H_
    3737
    38 #define FRAME_WIDTH             14      /* 16K */
    39 #define FRAME_SIZE              (1 << FRAME_WIDTH)
     38#define FRAME_WIDTH  14  /* 16K */
     39#define FRAME_SIZE   (1 << FRAME_WIDTH)
    4040
    4141#ifdef KERNEL
    4242#ifndef __ASM__
    4343
     44#include <typedefs.h>
     45
    4446extern void frame_arch_init(void);
    4547extern void physmem_print(void);
     48
     49extern uintptr_t end_frame;
    4650
    4751#endif /* __ASM__ */
  • kernel/arch/mips32/src/drivers/msim.c

    r17f168e rae318d3  
    4242#include <ddi/ddi.h>
    4343
    44 static parea_t msim_parea;
    4544static chardev_t console;
    4645static irq_t msim_irq;
     
    157156        sysinfo_set_item_val("kbd.address.virtual", NULL, MSIM_KBD_ADDRESS);
    158157       
    159         msim_parea.pbase = KA2PA(MSIM_VIDEORAM);
    160         msim_parea.vbase = MSIM_VIDEORAM;
    161         msim_parea.frames = 1;
    162         msim_parea.cacheable = false;
    163         ddi_parea_register(&msim_parea);
    164        
    165158        sysinfo_set_item_val("fb", NULL, true);
    166159        sysinfo_set_item_val("fb.kind", NULL, 3);
  • kernel/arch/mips32/src/mm/frame.c

    r17f168e rae318d3  
    6565static count_t phys_regions_count = 0;
    6666static phys_region_t phys_regions[MAX_REGIONS];
     67
     68uintptr_t end_frame = 0;
    6769
    6870
     
    237239        }
    238240       
    239         frame_add_region(start_frame, frame);
     241        end_frame = frame;
     242       
     243        frame_add_region(start_frame, end_frame);
    240244       
    241245        /* Blacklist interrupt vector frame */
  • kernel/arch/mips32/src/mm/page.c

    r17f168e rae318d3  
    2727 */
    2828
    29 /** @addtogroup mips32mm       
     29/** @addtogroup mips32mm
    3030 * @{
    3131 */
     
    3636#include <genarch/mm/page_pt.h>
    3737#include <mm/page.h>
     38#include <mm/frame.h>
    3839
    3940void page_arch_init(void)
     
    5152}
    5253
     54void hw_area(uintptr_t *physaddr, pfn_t *frames)
     55{
     56        *physaddr = end_frame;
     57        *frames = ADDR2PFN(0xffffffff - end_frame);
     58}
     59
    5360/** @}
    5461 */
  • kernel/arch/ppc32/include/mm/frame.h

    r17f168e rae318d3  
    4242#ifndef __ASM__
    4343
    44 #include <arch/types.h> 
     44#include <arch/types.h>
    4545
    4646extern uintptr_t last_frame;
     47extern uintptr_t end_frame;
    4748
    4849extern void frame_arch_init(void);
  • kernel/arch/ppc32/src/mm/frame.c

    r17f168e rae318d3  
    4141
    4242uintptr_t last_frame = 0;
     43uintptr_t end_frame = 0;
    4344
    4445void physmem_print(void)
     
    7576                        last_frame = ALIGN_UP(bootinfo.memmap.zones[i].start + bootinfo.memmap.zones[i].size, FRAME_SIZE);
    7677        }
    77 
     78       
     79        end_frame = last_frame;
     80       
    7881        /* First is exception vector, second is 'implementation specific',
    7982           third and fourth is reserved, other contain real mode code */
  • kernel/arch/ppc32/src/mm/page.c

    r17f168e rae318d3  
    6464}
    6565
     66void hw_area(uintptr_t *physaddr, pfn_t *frames)
     67{
     68        *physaddr = end_frame;
     69        *frames = ADDR2PFN(0xffffffff - end_frame);
     70}
     71
    6672/** @}
    6773 */
  • kernel/arch/sparc64/include/mm/frame.h

    r17f168e rae318d3  
    7474
    7575extern uintptr_t last_frame;
     76extern uintptr_t end_frame;
    7677extern void frame_arch_init(void);
    7778#define physmem_print()
  • kernel/arch/sparc64/src/drivers/sgcn.c

    r17f168e rae318d3  
    162162
    163163/**
    164  * Registers the physical area of the SRAM so that the userspace SGCN
    165  * driver can map it. Moreover, it sets some sysinfo values (SRAM address
    166  * and SRAM size).
    167  */
    168 static void register_sram_parea(uintptr_t sram_begin_physical)
    169 {
    170         static parea_t sram_parea;
    171         sram_parea.pbase = sram_begin_physical;
    172         sram_parea.vbase = (uintptr_t) sram_begin;
    173         sram_parea.frames = MAPPED_AREA_SIZE / FRAME_SIZE;
    174         sram_parea.cacheable = false;
    175         ddi_parea_register(&sram_parea);
    176        
     164 * Set some sysinfo values (SRAM address and SRAM size).
     165 */
     166static void register_sram(uintptr_t sram_begin_physical)
     167{
    177168        sysinfo_set_item_val("sram.area.size", NULL, MAPPED_AREA_SIZE);
    178169        sysinfo_set_item_val("sram.address.physical", NULL,
     
    212203        sram_begin = hw_map(sram_begin_physical, MAPPED_AREA_SIZE);
    213204       
    214         register_sram_parea(sram_begin_physical);
     205        register_sram(sram_begin_physical);
    215206}
    216207
  • kernel/arch/sparc64/src/mm/frame.c

    r17f168e rae318d3  
    4242
    4343uintptr_t last_frame = NULL;
     44uintptr_t end_frame = NULL;
    4445
    4546/** Create memory zones according to information stored in bootinfo.
     
    8182        }
    8283       
     84        end_frame = last_frame;
    8385}
    8486
  • kernel/arch/sparc64/src/mm/page.c

    r17f168e rae318d3  
    148148                    sizemap[order].pagesize_code, true, false);
    149149       
    150 #ifdef CONFIG_SMP       
     150#ifdef CONFIG_SMP
    151151                /*
    152152                 * Second, save the information about the mapping for APs.
     
    165165}
    166166
     167void hw_area(uintptr_t *physaddr, pfn_t *frames)
     168{
     169        *physaddr = end_frame;
     170        *frames = ADDR2PFN(0x7ffffffffff - end_frame);
     171}
     172
    167173/** @}
    168174 */
    169 
  • kernel/genarch/src/drivers/ega/ega.c

    r17f168e rae318d3  
    5454 * Simple and short. Function for displaying characters and "scrolling".
    5555 */
    56 
    57 static parea_t ega_parea;       /**< Physical memory area for EGA video RAM. */
    5856
    5957SPINLOCK_INITIALIZE(egalock);
     
    153151        stdout = &ega_console;
    154152       
    155         ega_parea.pbase = videoram_phys;
    156         ega_parea.vbase = (uintptr_t) videoram;
    157         ega_parea.frames = 1;
    158         ega_parea.cacheable = false;
    159         ddi_parea_register(&ega_parea);
    160        
    161153        sysinfo_set_item_val("fb", NULL, true);
    162154        sysinfo_set_item_val("fb.kind", NULL, 2);
  • kernel/genarch/src/fb/fb.c

    r17f168e rae318d3  
    5252
    5353SPINLOCK_INITIALIZE(fb_lock);
    54 
    55 /**< Physical memory area for fb. */
    56 static parea_t fb_parea;
    5754
    5855static uint8_t *fb_addr;
     
    520517        fb_addr = (uint8_t *) hw_map((uintptr_t) props->addr, fbsize);
    521518       
    522         fb_parea.pbase = (uintptr_t) props->addr + props->offset;
    523         fb_parea.vbase = (uintptr_t) fb_addr;
    524         fb_parea.frames = SIZE2FRAMES(fbsize);
    525         fb_parea.cacheable = false;
    526         ddi_parea_register(&fb_parea);
    527        
    528519        sysinfo_set_item_val("fb", NULL, true);
    529520        sysinfo_set_item_val("fb.kind", NULL, 1);
  • kernel/generic/include/ddi/ddi.h

    r17f168e rae318d3  
    3939#include <arch/types.h>
    4040#include <proc/task.h>
     41#include <adt/list.h>
    4142
    4243/** Structure representing contiguous physical memory area. */
    4344typedef struct {
    44         uintptr_t pbase;        /**< Physical base of the area. */
    45         uintptr_t vbase;        /**< Virtual base of the area. */
    46         count_t frames;         /**< Number of frames in the area. */
    47         bool cacheable;         /**< Cacheability. */
     45        uintptr_t pbase;    /**< Physical base of the area. */
     46        pfn_t frames;       /**< Number of frames in the area. */
     47       
     48        link_t link;        /**< Linked list link */
    4849} parea_t;
    4950
  • kernel/generic/include/mm/page.h

    r17f168e rae318d3  
    4343typedef struct {
    4444        void (* mapping_insert)(as_t *as, uintptr_t page, uintptr_t frame,
    45                 int flags);
     45            int flags);
    4646        void (* mapping_remove)(as_t *as, uintptr_t page);
    4747        pte_t *(* mapping_find)(as_t *as, uintptr_t page);
     
    6060extern void page_table_destroy(pte_t *page_table);
    6161extern void map_structure(uintptr_t s, size_t size);
     62
    6263extern uintptr_t hw_map(uintptr_t physaddr, size_t size);
     64extern void hw_area(uintptr_t *physaddr, pfn_t *frames);
    6365
    6466#endif
  • kernel/generic/src/adt/avl.c

    r17f168e rae318d3  
    4444 * Every node has a pointer to its parent which allows insertion of multiple
    4545 * identical keys into the tree.
    46  * 
     46 *
    4747 * Be careful when using this tree because of the base atribute which is added
    4848 * to every inserted node key. There is no rule in which order nodes with the
  • kernel/generic/src/console/cmd.c

    r17f168e rae318d3  
    530530        }
    531531       
    532         spinlock_unlock(&cmd_lock);     
     532        spinlock_unlock(&cmd_lock);
    533533
    534534        return 1;
  • kernel/generic/src/console/console.c

    r17f168e rae318d3  
    127127       
    128128        klog_parea.pbase = (uintptr_t) faddr;
    129         klog_parea.vbase = (uintptr_t) klog;
    130129        klog_parea.frames = SIZE2FRAMES(KLOG_SIZE);
    131         klog_parea.cacheable = true;
    132130        ddi_parea_register(&klog_parea);
    133131
  • kernel/generic/src/ddi/ddi.c

    r17f168e rae318d3  
    4848#include <synch/spinlock.h>
    4949#include <syscall/copy.h>
    50 #include <adt/btree.h>
     50#include <adt/list.h>
    5151#include <arch.h>
    5252#include <align.h>
     
    5656SPINLOCK_INITIALIZE(parea_lock);
    5757
    58 /** B+tree with enabled physical memory areas. */
    59 static btree_t parea_btree;
     58/** List with enabled physical memory areas. */
     59static LIST_INITIALIZE(parea_head);
     60
     61/** Physical memory area for devices. */
     62static parea_t dev_area;
    6063
    6164/** Initialize DDI. */
    6265void ddi_init(void)
    6366{
    64         btree_create(&parea_btree);
     67        hw_area(&dev_area.pbase, &dev_area.frames);
     68        ddi_parea_register(&dev_area);
    6569}
    6670
     
    7579{
    7680        ipl_t ipl;
    77 
     81       
    7882        ipl = interrupts_disable();
    7983        spinlock_lock(&parea_lock);
     
    8185        /*
    8286         * TODO: we should really check for overlaps here.
    83          * However, we should be safe because the kernel is pretty sane and
    84          * memory of different devices doesn't overlap.
    85          */
    86         btree_insert(&parea_btree, (btree_key_t) parea->pbase, parea, NULL);
    87 
     87         * However, we should be safe because the kernel is pretty sane.
     88         */
     89        link_initialize(&parea->link);
     90        list_append(&parea->link, &parea_head);
     91       
    8892        spinlock_unlock(&parea_lock);
    89         interrupts_restore(ipl);       
     93        interrupts_restore(ipl);
    9094}
    9195
     
    98102 *
    99103 * @return 0 on success, EPERM if the caller lacks capabilities to use this
    100  *      syscall, ENOENT if there is no task matching the specified ID or the
    101  *      physical address space is not enabled for mapping and ENOMEM if there
    102  *      was a problem in creating address space area.
    103  */
    104 static int ddi_physmem_map(uintptr_t pf, uintptr_t vp, count_t pages, int flags)
     104 *  syscall, ENOENT if there is no task matching the specified ID or the
     105 *  physical address space is not enabled for mapping and ENOMEM if there
     106 *  was a problem in creating address space area.
     107 */
     108static int ddi_physmem_map(uintptr_t pf, uintptr_t vp, pfn_t pages, int flags)
    105109{
    106110        ipl_t ipl;
    107111        cap_t caps;
    108112        mem_backend_data_t backend_data;
    109 
     113       
    110114        backend_data.base = pf;
    111115        backend_data.frames = pages;
     
    117121        if (!(caps & CAP_MEM_MANAGER))
    118122                return EPERM;
    119 
     123       
    120124        ipl = interrupts_disable();
    121 
     125       
    122126        /*
    123127         * Check if the physical memory area is enabled for mapping.
    124          * If the architecture supports virtually indexed caches, intercept
    125          * attempts to create an illegal address alias.
    126128         */
    127129        spinlock_lock(&parea_lock);
    128         parea_t *parea;
    129         btree_node_t *nodep;
    130         parea = (parea_t *) btree_search(&parea_btree, (btree_key_t) pf, &nodep);
    131         if (!parea || parea->frames < pages || ((flags & AS_AREA_CACHEABLE) &&
    132             !parea->cacheable) || (!(flags & AS_AREA_CACHEABLE) &&
    133             parea->cacheable)) {
     130       
     131        bool fnd = false;
     132        link_t *cur;
     133       
     134        for (cur = parea_head.next; cur != &parea_head; cur = cur->next) {
     135                parea_t *parea = list_get_instance(cur, parea_t, link);
     136                if ((parea->pbase <= pf) && (ADDR2PFN(pf - parea->pbase) + pages <= parea->frames)) {
     137                        fnd = true;
     138                        break;
     139                }
     140        }
     141       
     142        spinlock_unlock(&parea_lock);
     143       
     144        if (!fnd) {
    134145                /*
    135                  * This physical memory area cannot be mapped.
     146                 * Physical memory area cannot be mapped.
    136147                 */
    137                 spinlock_unlock(&parea_lock);
    138148                interrupts_restore(ipl);
    139149                return ENOENT;
    140150        }
    141         spinlock_unlock(&parea_lock);
    142 
     151       
    143152        spinlock_lock(&TASK->lock);
    144153       
     
    227236        return (unative_t) ddi_physmem_map(ALIGN_DOWN((uintptr_t) phys_base,
    228237            FRAME_SIZE), ALIGN_DOWN((uintptr_t) virt_base, PAGE_SIZE),
    229             (count_t) pages, (int) flags);
     238            (pfn_t) pages, (int) flags);
    230239}
    231240
     
    259268unative_t sys_preempt_control(int enable)
    260269{
    261         if (!cap_get(TASK) & CAP_PREEMPT_CONTROL)
    262                 return EPERM;
    263         if (enable)
    264                 preemption_enable();
    265         else
    266                 preemption_disable();
    267         return 0;
     270        if (!cap_get(TASK) & CAP_PREEMPT_CONTROL)
     271                return EPERM;
     272        if (enable)
     273                preemption_enable();
     274        else
     275                preemption_disable();
     276        return 0;
    268277}
    269278
  • kernel/generic/src/lib/rd.c

    r17f168e rae318d3  
    8989        rd_parea.pbase = ALIGN_DOWN((uintptr_t) KA2PA((void *) header + hsize),
    9090            FRAME_SIZE);
    91         rd_parea.vbase = (uintptr_t) ((void *) header + hsize);
    9291        rd_parea.frames = SIZE2FRAMES(dsize);
    93         rd_parea.cacheable = true;
    9492        ddi_parea_register(&rd_parea);
    9593
  • kernel/generic/src/proc/task.c

    r17f168e rae318d3  
    340340               
    341341                thr = list_get_instance(cur, thread_t, th_link);
    342                        
     342               
    343343                spinlock_lock(&thr->lock);
    344344                thr->interrupted = true;
  • kernel/generic/src/time/clock.c

    r17f168e rae318d3  
    8989
    9090        clock_parea.pbase = (uintptr_t) faddr;
    91         clock_parea.vbase = (uintptr_t) uptime;
    9291        clock_parea.frames = 1;
    93         clock_parea.cacheable = true;
    9492        ddi_parea_register(&clock_parea);
    9593
  • uspace/srv/fb/ega.c

    r17f168e rae318d3  
    374374        scr_height = sysinfo_value("fb.height");
    375375
    376         if(sysinfo_value("fb.blinking")) {
     376        if (sysinfo_value("fb.blinking")) {
    377377                ega_normal_color &= 0x77;
    378378                ega_inverted_color &= 0x77;
     
    386386        scr_addr = as_get_mappable_page(sz);
    387387
    388         physmem_map(ega_ph_addr, scr_addr, ALIGN_UP(sz, PAGE_SIZE) >>
    389             PAGE_WIDTH, AS_AREA_READ | AS_AREA_WRITE);
     388        if (physmem_map(ega_ph_addr, scr_addr, ALIGN_UP(sz, PAGE_SIZE) >>
     389            PAGE_WIDTH, AS_AREA_READ | AS_AREA_WRITE) != 0)
     390                return -1;
    390391
    391392        async_set_client_connection(ega_client_connection);
  • uspace/srv/fb/fb.c

    r17f168e rae318d3  
    16721672        void *fb_addr = as_get_mappable_page(fbsize);
    16731673       
    1674         physmem_map(fb_ph_addr + fb_offset, fb_addr,
    1675             ALIGN_UP(fbsize, PAGE_SIZE) >> PAGE_WIDTH, AS_AREA_READ | AS_AREA_WRITE);
     1674        if (physmem_map(fb_ph_addr + fb_offset, fb_addr,
     1675            ALIGN_UP(fbsize, PAGE_SIZE) >> PAGE_WIDTH, AS_AREA_READ | AS_AREA_WRITE) != 0)
     1676                return -1;
    16761677       
    16771678        if (screen_init(fb_addr, fb_width, fb_height, fb_scanline, fb_visual))
  • uspace/srv/fb/msim.c

    r17f168e rae318d3  
    6060        virt_addr = (char *) as_get_mappable_page(1);
    6161       
    62         physmem_map(phys_addr, virt_addr, 1, AS_AREA_READ | AS_AREA_WRITE);
     62        if (physmem_map(phys_addr, virt_addr, 1, AS_AREA_READ | AS_AREA_WRITE) != 0)
     63                return -1;
    6364       
    6465        serial_console_init(msim_putc, WIDTH, HEIGHT);
  • uspace/srv/fb/sgcn.c

    r17f168e rae318d3  
    122122int sgcn_init(void)
    123123{
    124         sram_virt_addr = (uintptr_t) as_get_mappable_page(
    125                 sysinfo_value("sram.area.size"));
    126         int result = physmem_map(
    127                 (void *) sysinfo_value("sram.address.physical"),
    128                 (void *) sram_virt_addr,
    129                 sysinfo_value("sram.area.size") / PAGE_SIZE,
    130                 AS_AREA_READ | AS_AREA_WRITE
    131                 );
    132         if (result != 0) {
    133                 printf("SGCN: uspace driver couldn't map physical memory: %d\n",
    134                         result);
    135         }
     124        sram_virt_addr = (uintptr_t) as_get_mappable_page(sysinfo_value("sram.area.size"));
     125       
     126        if (physmem_map((void *) sysinfo_value("sram.address.physical"),
     127            (void *) sram_virt_addr, sysinfo_value("sram.area.size") / PAGE_SIZE,
     128            AS_AREA_READ | AS_AREA_WRITE) != 0)
     129                return -1;
    136130       
    137131        serial_console_init(sgcn_putc, WIDTH, HEIGHT);
  • uspace/srv/kbd/arch/sparc64/src/sgcn.c

    r17f168e rae318d3  
    9898void sgcn_init(void)
    9999{
    100         sram_virt_addr = (uintptr_t) as_get_mappable_page(
    101                 sysinfo_value("sram.area.size"));
    102         int result = physmem_map(
    103                 (void *) sysinfo_value("sram.address.physical"),
    104                 (void *) sram_virt_addr,
    105                 sysinfo_value("sram.area.size") / PAGE_SIZE,
    106                 AS_AREA_READ | AS_AREA_WRITE
    107                 );
    108         if (result != 0) {
     100        sram_virt_addr = (uintptr_t) as_get_mappable_page(sysinfo_value("sram.area.size"));
     101        if (physmem_map((void *) sysinfo_value("sram.address.physical"),
     102            (void *) sram_virt_addr, sysinfo_value("sram.area.size") / PAGE_SIZE,
     103            AS_AREA_READ | AS_AREA_WRITE) != 0)
    109104                printf("SGCN: uspace driver could not map physical memory.");
    110         }
    111105       
    112106        sram_buffer_offset = sysinfo_value("sram.buffer.offset");
  • uspace/srv/ns/ns.c

    r17f168e rae318d3  
    109109}
    110110
    111 static void get_as_area(ipc_callid_t callid, ipc_call_t *call, char *name,
    112     void **addr)
     111static void get_as_area(ipc_callid_t callid, ipc_call_t *call, char *name, void **addr)
    113112{
    114113        void *ph_addr;
    115 
     114       
    116115        if (!*addr) {
    117116                ph_addr = (void *) sysinfo_value(name);
     
    121120                }
    122121                *addr = as_get_mappable_page(PAGE_SIZE);
    123                 physmem_map(ph_addr, *addr, 1,
    124                     AS_AREA_READ | AS_AREA_CACHEABLE);
     122                if (physmem_map(ph_addr, *addr, 1,
     123                    AS_AREA_READ | AS_AREA_CACHEABLE) != 0) {
     124                        ipc_answer_0(callid, ENOENT);
     125                        return;
     126                }
    125127        }
    126128        ipc_answer_2(callid, EOK, (ipcarg_t) *addr, AS_AREA_READ);
     
    151153                        switch (IPC_GET_ARG3(call)) {
    152154                        case SERVICE_MEM_REALTIME:
    153                                 get_as_area(callid, &call, "clock.faddr",
    154                                     &clockaddr);
     155                                get_as_area(callid, &call, "clock.faddr", &clockaddr);
    155156                                break;
    156157                        case SERVICE_MEM_KLOG:
    157                                 get_as_area(callid, &call, "klog.faddr",
    158                                     &klogaddr);
     158                                get_as_area(callid, &call, "klog.faddr", &klogaddr);
    159159                                break;
    160160                        default:
  • uspace/srv/rd/rd.c

    r17f168e rae318d3  
    258258        int retval = physmem_map(rd_ph_addr, rd_addr,
    259259            ALIGN_UP(rd_size, PAGE_SIZE) >> PAGE_WIDTH, flags);
    260 
     260       
    261261        if (retval < 0) {
    262262                printf(NAME ": Error mapping RAM disk\n");
Note: See TracChangeset for help on using the changeset viewer.