Changeset bf9afa07 in mainline


Ignore:
Timestamp:
2006-06-02T11:35:05Z (19 years ago)
Author:
Ondrej Palkovsky <ondrap@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2d22049
Parents:
49d072e
Message:

Allocation function for allocating free areas for mmap, map_physmem etc.

Files:
7 edited

Legend:

Unmodified
Added
Removed
  • fb/ega.c

    r49d072e rbf9afa07  
    112112{
    113113        void *ega_ph_addr;
     114        size_t sz;
    114115
    115116
     
    118119        scr_height=sysinfo_value("fb.height");
    119120
    120         scr_addr=(void *)ALIGN_UP(((__address)set_maxheapsize(USER_ADDRESS_SPACE_SIZE_ARCH>>1)),PAGE_SIZE);
     121        sz = scr_width*scr_height*2;
     122        scr_addr = as_get_mappable_page(sz);
    121123
    122         if (ega_ph_addr != ALIGN_DOWN((unsigned long)ega_ph_addr, PAGE_SIZE))
    123                 return -1;
    124        
    125         map_physmem(ega_ph_addr, scr_addr, (scr_width*scr_height*2+PAGE_SIZE-1)>>PAGE_WIDTH,
     124        map_physmem(ega_ph_addr, scr_addr, ALIGN_UP(sz,PAGE_SIZE)>>PAGE_WIDTH,
    126125                    AS_AREA_READ | AS_AREA_WRITE);
    127 
    128126
    129127        async_set_client_connection(ega_client_connection);
  • fb/fb.c

    r49d072e rbf9afa07  
    360360 *
    361361 */
    362 static void screen_init(__address addr, unsigned int xres, unsigned int yres, unsigned int bpp, unsigned int scan)
     362static void screen_init(void *addr, unsigned int xres, unsigned int yres, unsigned int bpp, unsigned int scan)
    363363{
    364364        switch (bpp) {
     
    598598int fb_init(void)
    599599{
    600         __address fb_ph_addr;
     600        void *fb_ph_addr;
    601601        unsigned int fb_width;
    602602        unsigned int fb_height;
    603603        unsigned int fb_bpp;
    604604        unsigned int fb_scanline;
    605         __address fb_addr;
     605        void *fb_addr;
     606        size_t asz;
    606607
    607608        async_set_client_connection(fb_client_connection);
    608609
    609         fb_ph_addr=sysinfo_value("fb.address.physical");
     610        fb_ph_addr=(void *)sysinfo_value("fb.address.physical");
    610611        fb_width=sysinfo_value("fb.width");
    611612        fb_height=sysinfo_value("fb.height");
     
    613614        fb_scanline=sysinfo_value("fb.scanline");
    614615
    615         fb_addr=ALIGN_UP(((__address)set_maxheapsize(USER_ADDRESS_SPACE_SIZE_ARCH>>1)),PAGE_SIZE);
     616        asz = fb_scanline*fb_height;
     617        fb_addr = as_get_mappable_page(asz);
    616618       
    617         map_physmem((void *)((__address)fb_ph_addr),(void *)fb_addr,
    618                     (fb_scanline*fb_height+PAGE_SIZE-1)>>PAGE_WIDTH,
     619        map_physmem(fb_ph_addr, fb_addr, ALIGN_UP(asz,PAGE_SIZE) >>PAGE_WIDTH,
    619620                    AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE);
    620621       
  • libc/generic/as.c

    r49d072e rbf9afa07  
    2727 */
    2828
     29#include <stdlib.h>
     30#include <unistd.h>
     31#include <string.h>
     32#include <ddi.h>
     33#include <sysinfo.h>
     34#include <align.h>
     35#include <as.h>
     36#include <ipc/fb.h>
     37#include <ipc/ipc.h>
     38#include <ipc/ns.h>
     39#include <ipc/services.h>
     40#include <kernel/errno.h>
     41
     42
    2943#include <as.h>
    3044#include <libc.h>
    3145#include <unistd.h>
    32 #include <task.h>
     46#include <align.h>
    3347
    3448/** Create address space area.
     
    7185static size_t heapsize = 0;
    7286static size_t maxheapsize = (size_t)(-1);
     87
     88static void * last_allocated = 0;
     89
    7390/* Start of heap linker symbol */
    7491extern char _heap;
     
    108125}
    109126
     127/** Set maximum heap size and return pointer just after the heap */
    110128void *set_maxheapsize(size_t mhs)
    111129{
     
    115133
    116134}
     135
     136/** Return pointer to some unmapped area, where fits new as_area
     137 *
     138 * TODO: make some first_fit/... algorithm, we are now just incrementing
     139 *       the pointer to last area
     140 */
     141void * as_get_mappable_page(size_t sz)
     142{
     143        void *res;
     144
     145        /* Set heapsize to some meaningful value */
     146        if (maxheapsize == -1)
     147                set_maxheapsize(ALIGN_UP(USER_ADDRESS_SPACE_SIZE_ARCH>>1,PAGE_SIZE));
     148        if (!last_allocated)
     149                last_allocated = ALIGN_UP((void *)&_heap + maxheapsize, PAGE_SIZE);
     150       
     151        sz = ALIGN_UP(sz, PAGE_SIZE);
     152        res = last_allocated;
     153        last_allocated += sz;
     154
     155        return res;
     156}
  • libc/generic/time.c

    r49d072e rbf9afa07  
    5757 * sequence of subsequent gettimeofday calls is ordered.
    5858 */
    59 #define TMAREA (100*1024*1024)
    6059int gettimeofday(struct timeval *tv, struct timezone *tz)
    6160{
     
    6665
    6766        if (!ktime) {
    68                 /* TODO: specify better, where to map the area */
     67                mapping = as_get_mappable_page(PAGE_SIZE);
    6968                /* Get the mapping of kernel clock */
    7069                res = ipc_call_sync_3(PHONE_NS, IPC_M_AS_AREA_RECV,
    71                                       TMAREA,
    72                                       PAGE_SIZE,
    73                                       0,
     70                                      mapping, PAGE_SIZE, 0,
    7471                                      NULL,&rights,NULL);
    7572                if (res) {
     
    8077                        printf("Received bad rights on time area: %X\n",
    8178                               rights);
    82                         as_area_destroy(TMAREA);
     79                        as_area_destroy(mapping);
    8380                        _exit(1);
    8481                }
    85                 ktime = (void *) (TMAREA);
     82                ktime = mapping;
    8683        }
    8784        if (tz) {
  • libc/include/align.h

    r49d072e rbf9afa07  
    4343 * @param a Size of alignment, must be power of 2.
    4444 */
    45 #define ALIGN_UP(s, a)          (((s) + ((a) - 1)) & ~((a) - 1))
     45#define ALIGN_UP(s, a)          ((long)((s) + ((a) - 1)) & ~((long) (a) - 1))
    4646
    4747#endif
  • libc/include/as.h

    r49d072e rbf9afa07  
    4141extern int as_area_destroy(void *address);
    4242extern void *set_maxheapsize(size_t mhs);
     43extern void * as_get_mappable_page(size_t sz);
    4344
    4445#endif
  • ns/ns.c

    r49d072e rbf9afa07  
    8888                        return;
    8989                }
    90                 addr = (void *)(200*1024*1024); /* TODO: intelligent freemem space */
     90                addr = as_get_mappable_page(PAGE_SIZE);
    9191                map_physmem(ph_addr, addr, 1, AS_AREA_READ | AS_AREA_CACHEABLE);
    9292        }
Note: See TracChangeset for help on using the changeset viewer.