OpenCores
URL https://opencores.org/ocsvn/c0or1k/c0or1k/trunk

Subversion Repositories c0or1k

[/] [c0or1k/] [trunk/] [conts/] [libmem/] [tests/] [test_allocpage.c] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 drasko
/*
2
 * Testing code for the page allocator.
3
 *
4
 * Copyright (C) 2007 Bahadir Balban
5
 */
6
#include <l4/macros.h>
7
#include <l4/config.h>
8
#include <l4/types.h>
9
#include <l4/lib/list.h>
10
#include INC_GLUE(memory.h)
11
#include <stdlib.h>
12
#include <stdio.h>
13
#include <time.h>
14
#include <string.h>
15
#include "test_allocpage.h"
16
#include "test_alloc_generic.h"
17
#include "debug.h"
18
 
19
unsigned int PAGE_ALLOCATIONS = 30;
20
unsigned int PAGE_ALLOC_SIZE_MAX = 8;
21
 
22
extern struct page_allocator allocator;
23
 
24
void print_page_area(struct page_area *a, int areano)
25
{
26
        printf("Area starts @: 0x%lu, %s, numpages: %d\n",
27
               __pfn_to_addr(a->pfn),
28
               (a->used) ? "used" : "unused", a->numpages);
29
        return;
30
}
31
 
32
void print_areas(struct link *area_head)
33
{
34
        struct page_area *cur;
35
        int areano = 1;
36
 
37
        printf("Page areas:\n-------------\n");
38
        list_foreach_struct(cur, area_head, list)
39
                print_page_area(cur, areano++);
40
}
41
 
42
void print_cache(struct mem_cache *c, int cacheno)
43
{
44
        printf("Cache %d state:\n-------------\n", cacheno);
45
        printf("Total: %d\n", c->total);
46
        printf("Free: %d\n", c->free);
47
        printf("Start: 0x%x\n", c->start);
48
}
49
 
50
void print_caches(struct link *cache_head)
51
{
52
        int caches = 1;
53
        struct mem_cache *cur;
54
 
55
        list_foreach_struct(cur, cache_head, list)
56
                print_cache(cur, caches++);
57
}
58
 
59
void print_page_allocator_state(void)
60
{
61
        print_areas(&allocator.page_area_list);
62
        printf("Data Cache:\n--------\n");
63
        print_caches(&allocator.dcache_list);
64
        printf("Cache Cache:\n----------\n");
65
        print_caches(&allocator.ccache_list);
66
}
67
 
68
/* FIXME: with current default parameters (allocations = 30, sizemax = 8),
69
 * for some odd reason, we got the bug at line 280 in alloc_page.c.
70
 * Very weird. Find out why.
71
 */
72
void test_allocpage(int page_allocations, int page_alloc_size_max,
73
                    FILE *init_state, FILE *exit_state)
74
{
75
        //if (!page_allocations)
76
        //      page_allocations = PAGE_ALLOCATIONS;
77
        //if (!page_alloc_size_max)
78
        //      page_alloc_size_max = PAGE_ALLOC_SIZE_MAX;
79
 
80
        dprintf("\nPAGE ALLOCATOR TEST:====================================\n\n");
81
        test_alloc_free_random_order(page_allocations, page_alloc_size_max,
82
                                     alloc_page, free_page,
83
                                     print_page_allocator_state,
84
                                     init_state, exit_state);
85
}

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.