Changeset f8ddd17 in mainline


Ignore:
Timestamp:
2006-12-09T20:20:50Z (18 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b82a13c
Parents:
9ab9c2ec
Message:

Rework support for virtually indexed cache.
Instead of repeatedly flushing the data cache, which was a huge overkill, refuse to create an illegal address alias
in the kernel (again) and allocate appropriate page color in userspace instead. Extend the detection also to
SYS_PHYSMEM_MAP syscall.

Add support for tracking physical memory areas mappable by SYS_PHYSMEM_MAP.

Lots of coding style changes.

Files:
1 added
36 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/ia32/src/drivers/ega.c

    r9ab9c2ec rf8ddd17  
    4747#include <console/console.h>
    4848#include <sysinfo/sysinfo.h>
     49#include <ddi/ddi.h>
    4950
    5051/*
     
    5253 * Simple and short. Function for displaying characters and "scrolling".
    5354 */
     55
     56static parea_t ega_parea;       /**< Physical memory area for EGA video RAM. */
    5457
    5558SPINLOCK_INITIALIZE(egalock);
     
    8083        stdout = &ega_console;
    8184       
     85        ega_parea.pbase = VIDEORAM;
     86        ega_parea.vbase = (uintptr_t) videoram;
     87        ega_parea.frames = 1;
     88        ega_parea.cacheable = false;
     89        ddi_parea_register(&ega_parea);
     90
    8291        sysinfo_set_item_val("fb", NULL, true);
    8392        sysinfo_set_item_val("fb.kind", NULL, 2);
     
    8594        sysinfo_set_item_val("fb.height", NULL, ROWS);
    8695        sysinfo_set_item_val("fb.address.physical", NULL, VIDEORAM);
     96        sysinfo_set_item_val("fb.address.color", NULL, PAGE_COLOR((uintptr_t)
     97                videoram));
    8798       
    8899#ifndef CONFIG_FB
  • kernel/arch/sparc64/include/interrupt.h

    r9ab9c2ec rf8ddd17  
    4848
    4949enum {
    50         IPI_TLB_SHOOTDOWN = VECTOR_TLB_SHOOTDOWN_IPI,
    51         IPI_DCACHE_SHOOTDOWN
     50        IPI_TLB_SHOOTDOWN = VECTOR_TLB_SHOOTDOWN_IPI
    5251};             
    5352
  • kernel/arch/sparc64/include/mm/cache.h

    r9ab9c2ec rf8ddd17  
    3636#define KERN_sparc64_CACHE_H_
    3737
    38 #ifdef CONFIG_SMP
    39 extern void dcache_shootdown_start(void);
    40 extern void dcache_shootdown_finalize(void);
    41 extern void dcache_shootdown_ipi_recv(void);
    42 #else /* CONFIG_SMP */
    43 #define dcache_shootdown_start();
    44 #define dcache_shootdown_finalize();
    45 #define dcache_shootdown_ipi_recv();
    46 #endif /* CONFIG_SMP */
    47 
    4838extern void dcache_flush(void);
    4939
  • kernel/arch/sparc64/src/mm/as.c

    r9ab9c2ec rf8ddd17  
    4949#include <macros.h>
    5050#endif /* CONFIG_TSB */
    51 
    52 #ifdef CONFIG_VIRT_IDX_DCACHE
    53 #include <arch/mm/cache.h>
    54 #endif /* CONFIG_VIRT_IDX_DCACHE */
    5551
    5652/** Architecture dependent address space init. */
     
    163159        dtsb_base_write(tsb_base.value);
    164160#endif
    165 #ifdef CONFIG_VIRT_IDX_DCACHE
    166         if (as->dcache_flush_on_install) {
    167                 /*
    168                  * Some mappings in this address space are illegal address
    169                  * aliases. Upon their creation, the dcache_flush_on_install
    170                  * flag was set.
    171                  *
    172                  * We are now obliged to flush the D-cache in order to guarantee
    173                  * that there will be at most one cache line for each address
    174                  * alias.
    175                  *
    176                  * This flush performs a cleanup after another address space in
    177                  * which the alias might have existed.
    178                  */
    179                 dcache_flush();
    180         }
    181 #endif /* CONFIG_VIRT_IDX_DCACHE */
    182161}
    183162
     
    214193        }
    215194#endif
    216 #ifdef CONFIG_VIRT_IDX_DCACHE
    217         if (as->dcache_flush_on_deinstall) {
    218                 /*
    219                  * Some mappings in this address space are illegal address
    220                  * aliases. Upon their creation, the dcache_flush_on_deinstall
    221                  * flag was set.
    222                  *
    223                  * We are now obliged to flush the D-cache in order to guarantee
    224                  * that there will be at most one cache line for each address
    225                  * alias.
    226                  *
    227                  * This flush performs a cleanup after this address space. It is
    228                  * necessary because other address spaces that contain the same
    229                  * alias are not necessarily aware of the need to carry out the
    230                  * cache flush. The only address spaces that are aware of it are
    231                  * those that created the illegal alias.
    232                  */
    233                 dcache_flush();
    234         }
    235 #endif /* CONFIG_VIRT_IDX_DCACHE */
    236195}
    237196
  • kernel/arch/sparc64/src/mm/cache.c

    r9ab9c2ec rf8ddd17  
    3232/**
    3333 * @file
    34  * @brief       D-cache shootdown algorithm.
    3534 */
    3635
    3736#include <arch/mm/cache.h>
    3837
    39 #ifdef CONFIG_SMP
    40 
    41 #include <smp/ipi.h>
    42 #include <arch/interrupt.h>
    43 #include <synch/spinlock.h>
    44 #include <arch.h>
    45 #include <debug.h>
    46 
    47 /**
    48  * This spinlock is used by the processors to synchronize during the D-cache
    49  * shootdown.
    50  */
    51 SPINLOCK_INITIALIZE(dcachelock);
    52 
    53 /** Initialize the D-cache shootdown sequence.
    54  *
    55  * Start the shootdown sequence by sending out an IPI and wait until all
    56  * processors spin on the dcachelock spinlock.
    57  */
    58 void dcache_shootdown_start(void)
    59 {
    60         int i;
    61 
    62         CPU->arch.dcache_active = 0;
    63         spinlock_lock(&dcachelock);
    64 
    65         ipi_broadcast(IPI_DCACHE_SHOOTDOWN);   
    66 
    67 busy_wait:
    68         for (i = 0; i < config.cpu_count; i++)
    69                 if (cpus[i].arch.dcache_active)
    70                         goto busy_wait;
    71 }
    72 
    73 /** Finish the D-cache shootdown sequence. */
    74 void dcache_shootdown_finalize(void)
    75 {
    76         spinlock_unlock(&dcachelock);
    77         CPU->arch.dcache_active = 1;
    78 }
    79 
    80 /** Process the D-cache shootdown IPI. */
    81 void dcache_shootdown_ipi_recv(void)
    82 {
    83         ASSERT(CPU);
    84 
    85         CPU->arch.dcache_active = 0;
    86         spinlock_lock(&dcachelock);
    87         spinlock_unlock(&dcachelock);
    88        
    89         dcache_flush();
    90 
    91         CPU->arch.dcache_active = 1;
    92 }
    93 
    94 #endif /* CONFIG_SMP */
    95 
    9638/** @}
    9739 */
  • kernel/arch/sparc64/src/mm/page.c

    r9ab9c2ec rf8ddd17  
    7474                for (i = 0; i < bsp_locked_dtlb_entries; i++) {
    7575                        dtlb_insert_mapping(bsp_locked_dtlb_entry[i].virt_page,
    76                                 bsp_locked_dtlb_entry[i].phys_page, bsp_locked_dtlb_entry[i].pagesize_code,
    77                                 true, false);
     76                                bsp_locked_dtlb_entry[i].phys_page,
     77                                bsp_locked_dtlb_entry[i].pagesize_code, true,
     78                                false);
    7879                }
    7980#endif 
     
    152153                 * Second, save the information about the mapping for APs.
    153154                 */
    154                 bsp_locked_dtlb_entry[bsp_locked_dtlb_entries].virt_page = virtaddr + i*sizemap[order].increment;
    155                 bsp_locked_dtlb_entry[bsp_locked_dtlb_entries].phys_page = physaddr + i*sizemap[order].increment;
    156                 bsp_locked_dtlb_entry[bsp_locked_dtlb_entries].pagesize_code = sizemap[order].pagesize_code;
     155                bsp_locked_dtlb_entry[bsp_locked_dtlb_entries].virt_page =
     156                        virtaddr + i*sizemap[order].increment;
     157                bsp_locked_dtlb_entry[bsp_locked_dtlb_entries].phys_page =
     158                        physaddr + i*sizemap[order].increment;
     159                bsp_locked_dtlb_entry[bsp_locked_dtlb_entries].pagesize_code =
     160                        sizemap[order].pagesize_code;
    157161                bsp_locked_dtlb_entries++;
    158162#endif
  • kernel/arch/sparc64/src/smp/ipi.c

    r9ab9c2ec rf8ddd17  
    3939#include <config.h>
    4040#include <mm/tlb.h>
    41 #include <arch/mm/cache.h>
    4241#include <arch/interrupt.h>
    4342#include <arch/trap/interrupt.h>
     
    122121                func = tlb_shootdown_ipi_recv;
    123122                break;
    124         case IPI_DCACHE_SHOOTDOWN:
    125                 func = dcache_shootdown_ipi_recv;
    126                 break;
    127123        default:
    128124                panic("Unknown IPI (%d).\n", ipi);
  • kernel/arch/sparc64/src/trap/interrupt.c

    r9ab9c2ec rf8ddd17  
    4545#include <arch.h>
    4646#include <mm/tlb.h>
    47 #include <arch/mm/cache.h>
    4847#include <config.h>
    4948#include <synch/spinlock.h>
     
    9291                if (data0 == (uintptr_t) tlb_shootdown_ipi_recv) {
    9392                        tlb_shootdown_ipi_recv();
    94                 } else if (data0 == (uintptr_t) dcache_shootdown_ipi_recv) {
    95                         dcache_shootdown_ipi_recv();
    9693                }
    9794#endif
  • kernel/genarch/src/fb/fb.c

    r9ab9c2ec rf8ddd17  
    4646#include <bitops.h>
    4747#include <print.h>
     48#include <ddi/ddi.h>
    4849
    4950#include "helenos.xbm"
     51
     52static parea_t fb_parea;                /**< Physical memory area for fb. */
    5053
    5154SPINLOCK_INITIALIZE(fb_lock);
     
    435438        columns = x / COL_WIDTH;
    436439
     440        fb_parea.pbase = (uintptr_t) addr;
     441        fb_parea.vbase = (uintptr_t) fbaddress;
     442        fb_parea.frames = SIZE2FRAMES(fbsize);
     443        fb_parea.cacheable = false;
     444        ddi_parea_register(&fb_parea);
     445
    437446        sysinfo_set_item_val("fb", NULL, true);
    438447        sysinfo_set_item_val("fb.kind", NULL, 1);
     
    442451        sysinfo_set_item_val("fb.visual", NULL, visual);
    443452        sysinfo_set_item_val("fb.address.physical", NULL, addr);
     453        sysinfo_set_item_val("fb.address.color", NULL, PAGE_COLOR((uintptr_t)
     454                fbaddress));
    444455        sysinfo_set_item_val("fb.invert-colors", NULL, invert_colors);
    445456
  • kernel/generic/include/ddi/ddi.h

    r9ab9c2ec rf8ddd17  
    4040#include <typedefs.h>
    4141
    42 unative_t sys_physmem_map(unative_t phys_base, unative_t virt_base, unative_t pages,
    43                          unative_t flags);
     42/** Structure representing contiguous physical memory area. */
     43typedef 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. */
     48} parea_t;
     49
     50extern void ddi_init(void);
     51extern void ddi_parea_register(parea_t *parea);
     52
     53extern unative_t sys_physmem_map(unative_t phys_base, unative_t virt_base,
     54        unative_t pages, unative_t flags);
    4455extern unative_t sys_iospace_enable(ddi_ioarg_t *uspace_io_arg);
    4556extern unative_t sys_preempt_control(int enable);
  • kernel/generic/include/mm/as.h

    r9ab9c2ec rf8ddd17  
    9595        asid_t asid;
    9696       
    97 #ifdef CONFIG_VIRT_IDX_DCACHE
    98         bool dcache_flush_on_install;
    99         bool dcache_flush_on_deinstall;
    100 #endif /* CONFIG_VIRT_IDX_DCACHE */
    101 
    10297        /** Architecture specific content. */
    10398        as_arch_t arch;
     
    166161        /** Data to be used by the backend. */
    167162        mem_backend_data_t backend_data;
    168 
    169         /**
    170          * Virtual color of the original address space area that was at the beginning
    171          * of the share chain.
    172          */
    173         int orig_color;
    174163};
    175164
  • kernel/generic/include/mm/page.h

    r9ab9c2ec rf8ddd17  
    7171 * Macro for computing page color.
    7272 */
    73 #define PAGE_COLOR(va)          (((va) >> PAGE_WIDTH) & ((1 << PAGE_COLOR_BITS) - 1))
     73#define PAGE_COLOR(va)  (((va) >> PAGE_WIDTH) & ((1 << PAGE_COLOR_BITS) - 1))
    7474
    7575/** Page fault access type. */
     
    8383/** Operations to manipulate page mappings. */
    8484struct page_mapping_operations {
    85         void (* mapping_insert)(as_t *as, uintptr_t page, uintptr_t frame, int flags);
     85        void (* mapping_insert)(as_t *as, uintptr_t page, uintptr_t frame, int
     86                flags);
    8687        void (* mapping_remove)(as_t *as, uintptr_t page);
    8788        pte_t *(* mapping_find)(as_t *as, uintptr_t page);
     
    9495extern void page_table_lock(as_t *as, bool lock);
    9596extern void page_table_unlock(as_t *as, bool unlock);
    96 extern void page_mapping_insert(as_t *as, uintptr_t page, uintptr_t frame, int flags);
     97extern void page_mapping_insert(as_t *as, uintptr_t page, uintptr_t frame, int
     98        flags);
    9799extern void page_mapping_remove(as_t *as, uintptr_t page);
    98100extern pte_t *page_mapping_find(as_t *as, uintptr_t page);
  • kernel/generic/src/console/klog.c

    r9ab9c2ec rf8ddd17  
    3939#include <ddi/device.h>
    4040#include <ddi/irq.h>
     41#include <ddi/ddi.h>
    4142#include <ipc/irq.h>
    4243
     44/** Physical memory area used for klog. */
     45static parea_t klog_parea;
     46       
    4347/*
    4448 * For now, we use 0 as INR.
    45  * However, on some architectures 0 is the clock interrupt (e.g. amd64 and ia32).
    46  * It is therefore desirable to have architecture specific definition of KLOG_VIRT_INR
    47  * in the future.
     49 * However, on some architectures 0 is the clock interrupt (e.g. amd64 and
     50 * ia32). It is therefore desirable to have architecture specific definition of
     51 * KLOG_VIRT_INR in the future.
    4852 */
    4953#define KLOG_VIRT_INR   0
     
    7680        if (!faddr)
    7781                panic("Cannot allocate page for klog");
    78         klog = (char *)PA2KA(faddr);
     82        klog = (char *) PA2KA(faddr);
    7983       
    8084        devno_t devno = device_assign_devno();
    8185       
    82         sysinfo_set_item_val("klog.faddr", NULL, (unative_t)faddr);
     86        klog_parea.pbase = (uintptr_t) faddr;
     87        klog_parea.vbase = (uintptr_t) klog;
     88        klog_parea.frames = 1 << KLOG_ORDER;
     89        klog_parea.cacheable = true;
     90        ddi_parea_register(&klog_parea);
     91
     92        sysinfo_set_item_val("klog.faddr", NULL, (unative_t) faddr);
     93        sysinfo_set_item_val("klog.fcolor", NULL, (unative_t)
     94                PAGE_COLOR((uintptr_t) klog));
    8395        sysinfo_set_item_val("klog.pages", NULL, 1 << KLOG_ORDER);
    8496        sysinfo_set_item_val("klog.devno", NULL, devno);
  • kernel/generic/src/ddi/ddi.c

    r9ab9c2ec rf8ddd17  
    4848#include <synch/spinlock.h>
    4949#include <syscall/copy.h>
     50#include <adt/btree.h>
    5051#include <arch.h>
    5152#include <align.h>
    5253#include <errno.h>
    5354
     55/** This lock protects the parea_btree. */
     56SPINLOCK_INITIALIZE(parea_lock);
     57
     58/** B+tree with enabled physical memory areas. */
     59static btree_t parea_btree;
     60
     61/** Initialize DDI. */
     62void ddi_init(void)
     63{
     64        btree_create(&parea_btree);
     65}
     66
     67/** Enable piece of physical memory for mapping by physmem_map().
     68 *
     69 * @param parea Pointer to physical area structure.
     70 *
     71 * @todo This function doesn't check for overlaps. It depends on the kernel to
     72 * create disjunct physical memory areas.
     73 */
     74void ddi_parea_register(parea_t *parea)
     75{
     76        ipl_t ipl;
     77
     78        ipl = interrupts_disable();
     79        spinlock_lock(&parea_lock);
     80       
     81        /*
     82         * 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
     88        spinlock_unlock(&parea_lock);
     89        interrupts_restore(ipl);       
     90}
     91
    5492/** Map piece of physical memory into virtual address space of current task.
    5593 *
    56  * @param pf Physical frame address of the starting frame.
    57  * @param vp Virtual page address of the starting page.
     94 * @param pf Physical address of the starting frame.
     95 * @param vp Virtual address of the starting page.
    5896 * @param pages Number of pages to map.
    5997 * @param flags Address space area flags for the mapping.
    6098 *
    61  * @return 0 on success, EPERM if the caller lacks capabilities to use this syscall,
    62  *         ENOENT if there is no task matching the specified ID and ENOMEM if
    63  *         there was a problem in creating address space area.
     99 * @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. ENOTSUP is returned when
     103 *      an attempt to create an illegal address alias is detected.
    64104 */
    65105static int ddi_physmem_map(uintptr_t pf, uintptr_t vp, count_t pages, int flags)
     
    80120
    81121        ipl = interrupts_disable();
     122
     123        /*
     124         * Check if the physical memory area is enabled for mapping.
     125         * If the architecture supports virtually indexed caches, intercept
     126         * attempts to create an illegal address alias.
     127         */
     128        spinlock_lock(&parea_lock);
     129        parea_t *parea;
     130        btree_node_t *nodep;
     131        parea = btree_search(&parea_btree, (btree_key_t) pf, &nodep);
     132        if (!parea || parea->frames < pages || ((flags & AS_AREA_CACHEABLE) &&
     133                !parea->cacheable) || (!(flags & AS_AREA_CACHEABLE) &&
     134                parea->cacheable)) {
     135                /*
     136                 * This physical memory area cannot be mapped.
     137                 */
     138                spinlock_unlock(&parea_lock);
     139                interrupts_restore(ipl);
     140                return ENOENT;
     141        }
     142
     143#ifdef CONFIG_VIRT_IDX_DCACHE
     144        if (PAGE_COLOR(parea->vbase) != PAGE_COLOR(vp)) {
     145                /*
     146                 * Refuse to create an illegal address alias.
     147                 */
     148                spinlock_unlock(&parea_lock);
     149                interrupts_restore(ipl);
     150                return ENOTSUP;
     151        }
     152#endif /* CONFIG_VIRT_IDX_DCACHE */
     153
     154        spinlock_unlock(&parea_lock);
     155
    82156        spinlock_lock(&TASK->lock);
    83157       
     
    108182 * @param size Size of the enabled I/O space..
    109183 *
    110  * @return 0 on success, EPERM if the caller lacks capabilities to use this syscall,
    111  *        ENOENT if there is no task matching the specified ID.
     184 * @return 0 on success, EPERM if the caller lacks capabilities to use this
     185 *      syscall, ENOENT if there is no task matching the specified ID.
    112186 */
    113187static int ddi_iospace_enable(task_id_t id, uintptr_t ioaddr, size_t size)
     
    161235 * @return 0 on success, otherwise it returns error code found in errno.h
    162236 */
    163 unative_t sys_physmem_map(unative_t phys_base, unative_t virt_base, unative_t pages,
    164                         unative_t flags)
    165 {
    166         return (unative_t) ddi_physmem_map(ALIGN_DOWN((uintptr_t) phys_base, FRAME_SIZE),
    167                                           ALIGN_DOWN((uintptr_t) virt_base, PAGE_SIZE), (count_t) pages,
    168                                           (int) flags);
     237unative_t sys_physmem_map(unative_t phys_base, unative_t virt_base, unative_t
     238        pages, unative_t flags)
     239{
     240        return (unative_t) ddi_physmem_map(ALIGN_DOWN((uintptr_t) phys_base,
     241                FRAME_SIZE), ALIGN_DOWN((uintptr_t) virt_base, PAGE_SIZE),
     242                (count_t) pages, (int) flags);
    169243}
    170244
     
    184258                return (unative_t) rc;
    185259               
    186         return (unative_t) ddi_iospace_enable((task_id_t) arg.task_id, (uintptr_t) arg.ioaddr, (size_t) arg.size);
     260        return (unative_t) ddi_iospace_enable((task_id_t) arg.task_id,
     261                (uintptr_t) arg.ioaddr, (size_t) arg.size);
    187262}
    188263
    189264/** Disable or enable preemption.
    190265 *
    191  * @param enable If non-zero, the preemption counter will be decremented, leading to potential
    192  *               enabling of preemption. Otherwise the preemption counter will be incremented,
    193  *              preventing preemption from occurring.
     266 * @param enable If non-zero, the preemption counter will be decremented,
     267 *      leading to potential enabling of preemption. Otherwise the preemption
     268 *      counter will be incremented, preventing preemption from occurring.
    194269 *
    195270 * @return Zero on success or EPERM if callers capabilities are not sufficient.
  • kernel/generic/src/lib/rd.c

    r9ab9c2ec rf8ddd17  
    4242#include <mm/frame.h>
    4343#include <sysinfo/sysinfo.h>
     44#include <ddi/ddi.h>
     45
     46static parea_t rd_parea;                /**< Physical memory area for rd. */
    4447
    4548int init_rd(rd_header * header, size_t size)
    4649{
    4750        /* Identify RAM disk */
    48         if ((header->magic[0] != RD_MAG0) || (header->magic[1] != RD_MAG1) || (header->magic[2] != RD_MAG2) || (header->magic[3] != RD_MAG3))
     51        if ((header->magic[0] != RD_MAG0) || (header->magic[1] != RD_MAG1) ||
     52                (header->magic[2] != RD_MAG2) || (header->magic[3] != RD_MAG3))
    4953                return RE_INVALID;
    5054       
     
    7781                dsize = size - hsize;
    7882       
     83        rd_parea.pbase = KA2PA((void *) header + hsize);
     84        rd_parea.vbase = (uintptr_t) ((void *) header + hsize);
     85        rd_parea.frames = SIZE2FRAMES(dsize);
     86        rd_parea.cacheable = true;
     87        ddi_parea_register(&rd_parea);
     88
    7989        sysinfo_set_item_val("rd", NULL, true);
    8090        sysinfo_set_item_val("rd.size", NULL, dsize);
    81         sysinfo_set_item_val("rd.address.physical", NULL, (unative_t) KA2PA((void *) header + hsize));
     91        sysinfo_set_item_val("rd.address.physical", NULL, (unative_t)
     92                KA2PA((void *) header + hsize));
     93        sysinfo_set_item_val("rd.address.color", NULL, (unative_t)
     94                PAGE_COLOR((uintptr_t) header + hsize));
    8295
    8396        return RE_OK;
  • kernel/generic/src/main/main.c

    r9ab9c2ec rf8ddd17  
    8181#include <console/klog.h>
    8282#include <smp/smp.h>
     83#include <ddi/ddi.h>
    8384
    8485/** Global configuration structure. */
     
    103104 * appropriate sizes and addresses.
    104105 */
    105 uintptr_t hardcoded_load_address = 0;   /**< Virtual address of where the kernel is loaded. */
    106 size_t hardcoded_ktext_size = 0;        /**< Size of the kernel code in bytes. */
    107 size_t hardcoded_kdata_size = 0;        /**< Size of the kernel data in bytes. */
    108 
    109 uintptr_t stack_safe = 0;               /**< Lowest safe stack virtual address */
     106uintptr_t hardcoded_load_address = 0;   /**< Virtual address of where the kernel
     107                                          *  is loaded. */
     108size_t hardcoded_ktext_size = 0;        /**< Size of the kernel code in bytes.
     109                                          */
     110size_t hardcoded_kdata_size = 0;        /**< Size of the kernel data in bytes.
     111                                         */
     112uintptr_t stack_safe = 0;               /**< Lowest safe stack virtual address.
     113                                          */
    110114
    111115void main_bsp(void);
     
    142146        config.memory_size = get_memory_size();
    143147       
    144         config.kernel_size = ALIGN_UP(hardcoded_ktext_size + hardcoded_kdata_size, PAGE_SIZE);
     148        config.kernel_size = ALIGN_UP(hardcoded_ktext_size +
     149                hardcoded_kdata_size, PAGE_SIZE);
    145150        config.stack_size = CONFIG_STACK_SIZE;
    146151       
     
    151156        count_t i;
    152157        for (i = 0; i < init.cnt; i++) {
    153                 if (PA_overlaps(config.stack_base, config.stack_size, init.tasks[i].addr, init.tasks[i].size))
    154                         config.stack_base = ALIGN_UP(init.tasks[i].addr + init.tasks[i].size, config.stack_size);
     158                if (PA_overlaps(config.stack_base, config.stack_size,
     159                        init.tasks[i].addr, init.tasks[i].size))
     160                        config.stack_base = ALIGN_UP(init.tasks[i].addr +
     161                                init.tasks[i].size, config.stack_size);
    155162        }
    156163
    157164        /* Avoid placing stack on top of boot allocations. */
    158165        if (ballocs.size) {
    159                 if (PA_overlaps(config.stack_base, config.stack_size, ballocs.base, ballocs.size))
    160                         config.stack_base = ALIGN_UP(ballocs.base + ballocs.size, PAGE_SIZE);
     166                if (PA_overlaps(config.stack_base, config.stack_size,
     167                        ballocs.base, ballocs.size))
     168                        config.stack_base = ALIGN_UP(ballocs.base +
     169                                ballocs.size, PAGE_SIZE);
    161170        }
    162171       
     
    165174       
    166175        context_save(&ctx);
    167         context_set(&ctx, FADDR(main_bsp_separated_stack), config.stack_base, THREAD_STACK_SIZE);
     176        context_set(&ctx, FADDR(main_bsp_separated_stack), config.stack_base,
     177                THREAD_STACK_SIZE);
    168178        context_restore(&ctx);
    169179        /* not reached */
     
    201211         */     
    202212        arch_pre_mm_init();
    203         frame_init();           /* Initialize at least 1 memory segment big enough for slab to work */
     213        frame_init();           
     214        /* Initialize at least 1 memory segment big enough for slab to work. */
    204215        slab_cache_init();
    205216        btree_init();
     
    207218        page_init();
    208219        tlb_init();
     220        ddi_init();
    209221        arch_post_mm_init();
    210222
    211223        version_print();
    212         printf("kernel: %.*p hardcoded_ktext_size=%zdK, hardcoded_kdata_size=%zdK\n", sizeof(uintptr_t) * 2, config.base, hardcoded_ktext_size >> 10, hardcoded_kdata_size >> 10);
    213         printf("stack:  %.*p size=%zdK\n", sizeof(uintptr_t) * 2, config.stack_base, config.stack_size >> 10);
     224        printf("kernel: %.*p hardcoded_ktext_size=%zdK, "
     225                "hardcoded_kdata_size=%zdK\n", sizeof(uintptr_t) * 2,
     226                config.base, hardcoded_ktext_size >> 10, hardcoded_kdata_size >>
     227                10);
     228        printf("stack:  %.*p size=%zdK\n", sizeof(uintptr_t) * 2,
     229                config.stack_base, config.stack_size >> 10);
    214230
    215231        arch_pre_smp_init();
    216232        smp_init();
    217        
    218         slab_enable_cpucache(); /* Slab must be initialized AFTER we know the number of processors */
     233        /* Slab must be initialized after we know the number of processors. */
     234        slab_enable_cpucache();
    219235
    220236        printf("config.memory_size=%zdM\n", config.memory_size >> 20);
     
    233249        if (init.cnt > 0) {
    234250                for (i = 0; i < init.cnt; i++)
    235                         printf("init[%zd].addr=%.*p, init[%zd].size=%zd\n", i, sizeof(uintptr_t) * 2, init.tasks[i].addr, i, init.tasks[i].size);
     251                        printf("init[%zd].addr=%.*p, init[%zd].size=%zd\n", i,
     252                                sizeof(uintptr_t) * 2, init.tasks[i].addr, i,
     253                                init.tasks[i].size);
    236254        } else
    237255                printf("No init binaries found\n");
     
    305323         * switch to this cpu's private stack prior to waking kmp up.
    306324         */
    307         context_set(&CPU->saved_context, FADDR(main_ap_separated_stack), (uintptr_t) CPU->stack, CPU_STACK_SIZE);
     325        context_set(&CPU->saved_context, FADDR(main_ap_separated_stack),
     326                (uintptr_t) CPU->stack, CPU_STACK_SIZE);
    308327        context_restore(&CPU->saved_context);
    309328        /* not reached */
  • kernel/generic/src/mm/as.c

    r9ab9c2ec rf8ddd17  
    167167        as->page_table = page_table_create(flags);
    168168
    169 #ifdef CONFIG_VIRT_IDX_DCACHE
    170         as->dcache_flush_on_install = false;
    171         as->dcache_flush_on_deinstall = false;
    172 #endif  /* CONFIG_VIRT_IDX_DCACHE */
    173 
    174169        return as;
    175170}
     
    278273        else
    279274                memsetb((uintptr_t) &a->backend_data, sizeof(a->backend_data), 0);
    280 
    281 #ifdef CONFIG_VIRT_IDX_DCACHE
    282         /*
    283          * When the area is being created with the AS_AREA_ATTR_PARTIAL flag, the
    284          * orig_color is probably wrong until the flag is reset. In other words, it is
    285          * initialized with the color of the area being created and not with the color
    286          * of the original address space area at the beginning of the share chain. Of
    287          * course, the correct color is set by as_area_share() before the flag is
    288          * reset.
    289          */
    290         a->orig_color = PAGE_COLOR(base);
    291 #endif /* CONFIG_VIRT_IDX_DCACHE */
    292275
    293276        btree_create(&a->used_space);
     
    576559 * or ENOMEM if there was a problem in allocating destination address space
    577560 * area. ENOTSUP is returned if the address space area backend does not support
    578  * sharing.
     561 * sharing or if the kernel detects an attempt to create an illegal address
     562 * alias.
    579563 */
    580564int as_area_share(as_t *src_as, uintptr_t src_base, size_t acc_size,
     
    584568        int src_flags;
    585569        size_t src_size;
    586         int src_orig_color;
    587570        as_area_t *src_area, *dst_area;
    588571        share_info_t *sh_info;
     
    601584                return ENOENT;
    602585        }
    603        
    604586
    605587        if (!src_area->backend || !src_area->backend->share) {
     
    618600        src_backend = src_area->backend;
    619601        src_backend_data = src_area->backend_data;
    620         src_orig_color = src_area->orig_color;
    621602
    622603        /* Share the cacheable flag from the original mapping */
     
    630611                return EPERM;
    631612        }
     613
     614#ifdef CONFIG_VIRT_IDX_DCACHE
     615        if (!(dst_flags_mask & AS_AREA_EXEC)) {
     616                if (PAGE_COLOR(src_area->base) != PAGE_COLOR(dst_base)) {
     617                        /*
     618                         * Refuse to create an illegal address alias.
     619                         */
     620                        mutex_unlock(&src_area->lock);
     621                        mutex_unlock(&src_as->lock);
     622                        interrupts_restore(ipl);
     623                        return ENOTSUP;
     624                }
     625        }
     626#endif /* CONFIG_VIRT_IDX_DCACHE */
    632627
    633628        /*
     
    683678        dst_area->attributes &= ~AS_AREA_ATTR_PARTIAL;
    684679        dst_area->sh_info = sh_info;
    685         dst_area->orig_color = src_orig_color;
    686 #ifdef CONFIG_VIRT_IDX_DCACHE
    687         if (src_orig_color != PAGE_COLOR(dst_base)) {
    688                 /*
    689                  * We have just detected an attempt to create an invalid address
    690                  * alias. We allow this and set a special flag that tells the
    691                  * architecture specific code to flush the D-cache when the
    692                  * offending address space is installed and deinstalled
    693                  * (cleanup).
    694                  *
    695                  * In order for the flags to take effect immediately, we also
    696                  * perform a global D-cache shootdown.
    697                  */
    698                 dcache_shootdown_start();
    699                 dst_as->dcache_flush_on_install = true;
    700                 dst_as->dcache_flush_on_deinstall = true;
    701                 dcache_flush();
    702                 dcache_shootdown_finalize();
    703         }
    704 #endif /* CONFIG_VIRT_IDX_DCACHE */
    705680        mutex_unlock(&dst_area->lock);
    706681        mutex_unlock(&dst_as->lock);   
  • kernel/generic/src/sysinfo/sysinfo.c

    r9ab9c2ec rf8ddd17  
    231231               
    232232                switch (root->val_type) {
    233                         case SYSINFO_VAL_UNDEFINED:
    234                                 val = 0;
    235                                 vtype = "UND";
    236                                 break;
    237                         case SYSINFO_VAL_VAL:
    238                                 val = root->val.val;
    239                                 vtype = "VAL";
    240                                 break;
    241                         case SYSINFO_VAL_FUNCTION:
    242                                 val = ((sysinfo_val_fn_t) (root->val.fn)) (root);
    243                                 vtype = "FUN";
    244                                 break;
     233                case SYSINFO_VAL_UNDEFINED:
     234                        val = 0;
     235                        vtype = "UND";
     236                        break;
     237                case SYSINFO_VAL_VAL:
     238                        val = root->val.val;
     239                        vtype = "VAL";
     240                        break;
     241                case SYSINFO_VAL_FUNCTION:
     242                        val = ((sysinfo_val_fn_t) (root->val.fn)) (root);
     243                        vtype = "FUN";
     244                        break;
    245245                }
    246246               
    247                 printf("%s    %s val:%d(%x) sub:%s\n", root->name, vtype, val, val, (root->subinfo_type == SYSINFO_SUBINFO_NONE) ? "NON" : ((root->subinfo_type == SYSINFO_SUBINFO_TABLE) ? "TAB" : "FUN"));
     247                printf("%s    %s val:%d(%x) sub:%s\n", root->name, vtype, val,
     248                        val, (root->subinfo_type == SYSINFO_SUBINFO_NONE) ?
     249                        "NON" : ((root->subinfo_type == SYSINFO_SUBINFO_TABLE) ?
     250                        "TAB" : "FUN"));
    248251               
    249252                if (root->subinfo_type == SYSINFO_SUBINFO_TABLE)
  • kernel/generic/src/time/clock.c

    r9ab9c2ec rf8ddd17  
    5555#include <sysinfo/sysinfo.h>
    5656#include <arch/barrier.h>
     57#include <mm/frame.h>
     58#include <ddi/ddi.h>
     59
     60/** Physical memory area of the real time clock. */
     61static parea_t clock_parea;
    5762
    5863/* Pointers to public variables with time */
     
    7378 * information about realtime data. We allocate 1 page with these
    7479 * data and update it periodically.
    75  *
    76  *
    7780 */
    7881void clock_counter_init(void)
     
    8083        void *faddr;
    8184
    82         faddr = frame_alloc(0, FRAME_ATOMIC);
     85        faddr = frame_alloc(ONE_FRAME, FRAME_ATOMIC);
    8386        if (!faddr)
    8487                panic("Cannot allocate page for clock");
    8588       
    86         public_time = (struct ptime *)PA2KA(faddr);
     89        public_time = (struct ptime *) PA2KA(faddr);
    8790
    8891        /* TODO: We would need some arch dependent settings here */
     
    9194        public_time->useconds = 0;
    9295
    93         sysinfo_set_item_val("clock.faddr", NULL, (unative_t)faddr);
     96        clock_parea.pbase = (uintptr_t) faddr;
     97        clock_parea.vbase = (uintptr_t) public_time;
     98        clock_parea.frames = 1;
     99        clock_parea.cacheable = true;
     100        ddi_parea_register(&clock_parea);
     101
     102        /*
     103         * Prepare information for the userspace so that it can successfully
     104         * physmem_map() the clock_parea.
     105         */
     106        sysinfo_set_item_val("clock.cacheable", NULL, (unative_t) true);
     107        sysinfo_set_item_val("clock.fcolor", NULL, (unative_t)
     108                PAGE_COLOR(clock_parea.vbase));
     109        sysinfo_set_item_val("clock.faddr", NULL, (unative_t) faddr);
    94110}
    95111
  • uspace/fb/ega.c

    r9ab9c2ec rf8ddd17  
    3535 */
    3636
    37 
    3837#include <stdlib.h>
    3938#include <unistd.h>
     
    6362saved_screen saved_screens[MAX_SAVED_SCREENS];
    6463
    65 
    6664#define EGA_IO_ADDRESS 0x3d4
    6765#define EGA_IO_SIZE 2
     
    127125        int i;
    128126        if (rows > 0) {
    129                 memcpy (scr_addr,((char *)scr_addr) + rows * scr_width * 2, scr_width * scr_height * 2 - rows * scr_width * 2);
     127                memcpy (scr_addr,((char *)scr_addr) + rows * scr_width * 2,
     128                        scr_width * scr_height * 2 - rows * scr_width * 2);
    130129                for (i = 0; i < rows * scr_width ; i ++)
    131                         (((short *)scr_addr) + scr_width * scr_height - rows * scr_width) [i] = ((style << 8) + ' ');
     130                        (((short *)scr_addr) + scr_width * scr_height - rows *
     131                                scr_width) [i] = ((style << 8) + ' ');
    132132        } else if (rows < 0) {
    133 
    134                 memcpy (((char *)scr_addr) - rows * scr_width * 2 ,scr_addr ,scr_width * scr_height * 2 + rows * scr_width * 2);
     133                memcpy (((char *)scr_addr) - rows * scr_width * 2, scr_addr,
     134                        scr_width * scr_height * 2 + rows * scr_width * 2);
    135135                for (i = 0; i < - rows * scr_width ; i++)
    136136                        ((short *)scr_addr) [i] = ((style << 8 ) + ' ');
     
    309309        scr_width=sysinfo_value("fb.width");
    310310        scr_height=sysinfo_value("fb.height");
    311         iospace_enable(task_get_id(),(void *)EGA_IO_ADDRESS,2);
    312 
    313         sz = scr_width*scr_height*2;
    314         scr_addr = as_get_mappable_page(sz);
    315 
    316         physmem_map(ega_ph_addr, scr_addr, ALIGN_UP(sz, PAGE_SIZE) >> PAGE_WIDTH,
    317                     AS_AREA_READ | AS_AREA_WRITE);
     311        iospace_enable(task_get_id(), (void *) EGA_IO_ADDRESS, 2);
     312
     313        sz = scr_width * scr_height * 2;
     314        scr_addr = as_get_mappable_page(sz, (int)
     315                sysinfo_value("fb.address.color"));
     316
     317        physmem_map(ega_ph_addr, scr_addr, ALIGN_UP(sz, PAGE_SIZE) >>
     318                PAGE_WIDTH, AS_AREA_READ | AS_AREA_WRITE);
    318319
    319320        async_set_client_connection(ega_client_connection);
  • uspace/fb/fb.c

    r9ab9c2ec rf8ddd17  
    705705                /* We accept one area for data interchange */
    706706                if (IPC_GET_ARG1(*call) == shm_id) {
    707                         void *dest = as_get_mappable_page(IPC_GET_ARG2(*call));
     707                        void *dest = as_get_mappable_page(IPC_GET_ARG2(*call),
     708                                PAGE_COLOR(IPC_GET_ARG1(*call)));
    708709                        shm_size = IPC_GET_ARG2(*call);
    709                         if (!ipc_answer_fast(callid, 0, (sysarg_t)dest, 0))
     710                        if (!ipc_answer_fast(callid, 0, (sysarg_t) dest, 0))
    710711                                shm = dest;
    711712                        else
     
    717718                } else {
    718719                        intersize = IPC_GET_ARG2(*call);
    719                         receive_comm_area(callid,call,(void *)&interbuffer);
     720                        receive_comm_area(callid, call, (void *) &interbuffer);
    720721                }
    721722                return 1;
     
    12831284
    12841285        asz = fb_scanline * fb_height;
    1285         fb_addr = as_get_mappable_page(asz);
     1286        fb_addr = as_get_mappable_page(asz, (int) sysinfo_value("fb.address.color"));
    12861287       
    12871288        physmem_map(fb_ph_addr, fb_addr, ALIGN_UP(asz, PAGE_SIZE) >> PAGE_WIDTH,
    12881289                    AS_AREA_READ | AS_AREA_WRITE);
    12891290
    1290         if (screen_init(fb_addr, fb_width, fb_height, fb_scanline, fb_visual, fb_invert_colors))
     1291        if (screen_init(fb_addr, fb_width, fb_height, fb_scanline, fb_visual,
     1292                fb_invert_colors))
    12911293                return 0;
    12921294       
  • uspace/fb/main.c

    r9ab9c2ec rf8ddd17  
    4444        void *dest;
    4545
    46         dest = as_get_mappable_page(IPC_GET_ARG2(*call));
     46        dest = as_get_mappable_page(IPC_GET_ARG2(*call),
     47                PAGE_COLOR(IPC_GET_ARG1(*call)));
    4748        if (ipc_answer_fast(callid, 0, (sysarg_t)dest, 0) == 0) {
    4849                if (*area)
  • uspace/klog/klog.c

    r9ab9c2ec rf8ddd17  
    6464        printf("Kernel console output.\n");
    6565       
    66         mapping = as_get_mappable_page(PAGE_SIZE);
     66        mapping = as_get_mappable_page(PAGE_SIZE, sysinfo_value("klog.fcolor"));
    6767        res = ipc_call_sync_3(PHONE_NS, IPC_M_AS_AREA_RECV,
    68                               (sysarg_t)mapping, PAGE_SIZE, SERVICE_MEM_KLOG,
    69                               NULL,NULL,NULL);
     68                              (sysarg_t) mapping, PAGE_SIZE, SERVICE_MEM_KLOG,
     69                              NULL, NULL, NULL);
    7070        if (res) {
    7171                printf("Failed to initialize klog memarea\n");
  • uspace/libc/arch/amd64/include/config.h

    r9ab9c2ec rf8ddd17  
    3838#define PAGE_WIDTH      12
    3939#define PAGE_SIZE       (1<<PAGE_WIDTH)
     40#define PAGE_COLOR_BITS 0               /* dummy */
    4041
    4142#endif
  • uspace/libc/arch/ia32/include/config.h

    r9ab9c2ec rf8ddd17  
    3838#define PAGE_WIDTH      12
    3939#define PAGE_SIZE       (1<<PAGE_WIDTH)
     40#define PAGE_COLOR_BITS 0               /* dummy */
    4041
    4142#endif
  • uspace/libc/arch/ia64/include/config.h

    r9ab9c2ec rf8ddd17  
    3838#define PAGE_WIDTH      14
    3939#define PAGE_SIZE       (1<<PAGE_WIDTH)
     40#define PAGE_COLOR_BITS 0               /* dummy */
    4041
    4142#endif
  • uspace/libc/arch/mips32/include/config.h

    r9ab9c2ec rf8ddd17  
    3838#define PAGE_WIDTH      14
    3939#define PAGE_SIZE       (1<<PAGE_WIDTH)
     40#define PAGE_COLOR_BITS 0               /* dummy */
    4041
    4142#endif
  • uspace/libc/arch/ppc32/include/config.h

    r9ab9c2ec rf8ddd17  
    3838#define PAGE_WIDTH      12
    3939#define PAGE_SIZE       (1<<PAGE_WIDTH)
     40#define PAGE_COLOR_BITS 0               /* dummy */
    4041
    4142#endif
  • uspace/libc/arch/ppc64/include/config.h

    r9ab9c2ec rf8ddd17  
    3838#define PAGE_WIDTH      12
    3939#define PAGE_SIZE       (1<<PAGE_WIDTH)
     40#define PAGE_COLOR_BITS 0               /* dummy */
    4041
    4142#endif
  • uspace/libc/arch/sparc64/include/config.h

    r9ab9c2ec rf8ddd17  
    3838#define PAGE_WIDTH      13
    3939#define PAGE_SIZE       (1<<PAGE_WIDTH)
     40#define PAGE_COLOR_BITS 1               /**< Bit 13 is the page color. */
    4041
    4142#endif
  • uspace/libc/generic/as.c

    r9ab9c2ec rf8ddd17  
    3838#include <align.h>
    3939#include <types.h>
     40#include <bitops.h>
    4041
    4142/**
     
    5455void *as_area_create(void *address, size_t size, int flags)
    5556{
    56         return (void *) __SYSCALL3(SYS_AS_AREA_CREATE, (sysarg_t ) address, (sysarg_t) size, (sysarg_t) flags);
     57        return (void *) __SYSCALL3(SYS_AS_AREA_CREATE, (sysarg_t ) address,
     58                (sysarg_t) size, (sysarg_t) flags);
    5759}
    5860
    5961/** Resize address space area.
    6062 *
    61  * @param address Virtual address pointing into already existing address space area.
     63 * @param address Virtual address pointing into already existing address space
     64 *      area.
    6265 * @param size New requested size of the area.
    6366 * @param flags Currently unused.
     
    6770int as_area_resize(void *address, size_t size, int flags)
    6871{
    69         return __SYSCALL3(SYS_AS_AREA_RESIZE, (sysarg_t ) address, (sysarg_t) size, (sysarg_t) flags);
     72        return __SYSCALL3(SYS_AS_AREA_RESIZE, (sysarg_t ) address, (sysarg_t)
     73                size, (sysarg_t) flags);
    7074}
    7175
    7276/** Destroy address space area.
    7377 *
    74  * @param address Virtual address pointing into the address space area being destroyed.
     78 * @param address Virtual address pointing into the address space area being
     79 *      destroyed.
    7580 *
    7681 * @return Zero on success or a code from @ref errno.h on failure.
     
    134139        /* Return pointer to area not managed by sbrk */
    135140        return ((void *) &_heap + maxheapsize);
    136 
    137141}
    138142
    139143/** Return pointer to some unmapped area, where fits new as_area
    140144 *
     145 * @param sz Requested size of the allocation.
     146 * @param color Requested virtual color of the allocation.
     147 *
     148 * @return Pointer to the beginning
     149 *
    141150 * TODO: make some first_fit/... algorithm, we are now just incrementing
    142151 *       the pointer to last area
    143152 */
    144 void * as_get_mappable_page(size_t sz)
     153#include <stdio.h>
     154void *as_get_mappable_page(size_t sz, int color)
    145155{
    146156        void *res;
     157        uint64_t asz;
     158        int i;
     159       
     160        if (!sz)
     161                return NULL;   
     162
     163        asz = 1 << (fnzb64(sz - 1) + 1);
    147164
    148165        /* Set heapsize to some meaningful value */
     
    150167                set_maxheapsize(MAX_HEAP_SIZE);
    151168       
    152         if (!last_allocated)
    153                 last_allocated = (void *) ALIGN_UP((void *) &_heap + maxheapsize, PAGE_SIZE);
    154        
    155         sz = ALIGN_UP(sz, PAGE_SIZE);
     169        /*
     170         * Make sure we allocate from naturally aligned address and a page of
     171         * appropriate color.
     172         */
     173        i = 0;
     174        do {
     175                if (!last_allocated) {
     176                        last_allocated = (void *) ALIGN_UP((void *) &_heap +
     177                                maxheapsize, asz);
     178                } else {
     179                        last_allocated = (void *) ALIGN_UP(((uintptr_t)
     180                                last_allocated) + (int) (i > 0), asz);
     181                }
     182        } while ((asz < (1 << (PAGE_COLOR_BITS + PAGE_WIDTH))) &&
     183                (PAGE_COLOR((uintptr_t) last_allocated) != color) &&
     184                (++i < (1 << PAGE_COLOR_BITS)));
     185
    156186        res = last_allocated;
    157         last_allocated += sz;
     187        last_allocated += ALIGN_UP(sz, PAGE_SIZE);
    158188
    159189        return res;
  • uspace/libc/generic/mman.c

    r9ab9c2ec rf8ddd17  
    4040{
    4141        if (!start)
    42                 start = as_get_mappable_page(length);
     42                start = as_get_mappable_page(length, 0);
    4343       
    4444//      if (! ((flags & MAP_SHARED) ^ (flags & MAP_PRIVATE)))
  • uspace/libc/generic/time.c

    r9ab9c2ec rf8ddd17  
    4141#include <atomic.h>
    4242#include <futex.h>
     43#include <sysinfo.h>
    4344#include <ipc/services.h>
    4445
     
    7273
    7374        if (!ktime) {
    74                 mapping = as_get_mappable_page(PAGE_SIZE);
     75                mapping = as_get_mappable_page(PAGE_SIZE, (int)
     76                        sysinfo_value("clock.fcolor"));
    7577                /* Get the mapping of kernel clock */
    76                 res = ipc_call_sync_3(PHONE_NS, IPC_M_AS_AREA_RECV, (sysarg_t) mapping, PAGE_SIZE, SERVICE_MEM_REALTIME, NULL, &rights, NULL);
     78                res = ipc_call_sync_3(PHONE_NS, IPC_M_AS_AREA_RECV, (sysarg_t)
     79                        mapping, PAGE_SIZE, SERVICE_MEM_REALTIME, NULL, &rights,
     80                        NULL);
    7781                if (res) {
    7882                        printf("Failed to initialize timeofday memarea\n");
  • uspace/libc/include/as.h

    r9ab9c2ec rf8ddd17  
    4040#include <kernel/arch/mm/as.h>
    4141#include <kernel/mm/as.h>
     42#include <libarch/config.h>
     43
     44#define PAGE_COLOR(va)  (((va) >> PAGE_WIDTH) & ((1 << PAGE_COLOR_BITS) - 1))
    4245
    4346extern void *as_area_create(void *address, size_t size, int flags);
     
    4548extern int as_area_destroy(void *address);
    4649extern void *set_maxheapsize(size_t mhs);
    47 extern void * as_get_mappable_page(size_t sz);
     50extern void * as_get_mappable_page(size_t sz, int color);
    4851
    4952#endif
  • uspace/ns/ns.c

    r9ab9c2ec rf8ddd17  
    8484static void *klogaddr = NULL;
    8585
    86 static void get_as_area(ipc_callid_t callid, ipc_call_t *call, char *name, void **addr)
     86static void get_as_area(ipc_callid_t callid, ipc_call_t *call, char *name, char *colstr, void **addr)
    8787{
    8888        void *ph_addr;
     89        int ph_color;
    8990
    9091        if (!*addr) {
    91                 ph_addr = (void *)sysinfo_value(name);
     92                ph_addr = (void *) sysinfo_value(name);
    9293                if (!ph_addr) {
    9394                        ipc_answer_fast(callid, ENOENT, 0, 0);
    9495                        return;
    9596                }
    96                 *addr = as_get_mappable_page(PAGE_SIZE);
     97                ph_color = (int) sysinfo_value(colstr);
     98                *addr = as_get_mappable_page(PAGE_SIZE, ph_color);
    9799                physmem_map(ph_addr, *addr, 1, AS_AREA_READ | AS_AREA_CACHEABLE);
    98100        }
     
    117119                        switch (IPC_GET_ARG3(call)) {
    118120                        case SERVICE_MEM_REALTIME:
    119                                 get_as_area(callid, &call, "clock.faddr", &clockaddr);
     121                                get_as_area(callid, &call, "clock.faddr",
     122                                        "clock.fcolor", &clockaddr);
    120123                                break;
    121124                        case SERVICE_MEM_KLOG:
    122                                 get_as_area(callid, &call, "klog.faddr", &klogaddr);
     125                                get_as_area(callid, &call, "klog.faddr",
     126                                        "klog.fcolor", &klogaddr);
    123127                                break;
    124128                        default:
  • uspace/rd/rd.c

    r9ab9c2ec rf8ddd17  
    7474        size_t rd_size = sysinfo_value("rd.size");
    7575        void * rd_ph_addr = (void *) sysinfo_value("rd.address.physical");
     76        int rd_color = (int) sysinfo_value("rd.address.color");
    7677       
    7778        if (rd_size == 0)
    7879                return false;
    7980       
    80         void * rd_addr = as_get_mappable_page(rd_size);
     81        void * rd_addr = as_get_mappable_page(rd_size, rd_color);
    8182       
    8283        physmem_map(rd_ph_addr, rd_addr, ALIGN_UP(rd_size, PAGE_SIZE) >> PAGE_WIDTH, AS_AREA_READ | AS_AREA_WRITE);
Note: See TracChangeset for help on using the changeset viewer.