Changeset 5383ed4 in rtems-libbsd


Ignore:
Timestamp:
Feb 13, 2015, 9:31:27 AM (5 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, c1e05b9ea378b2971e3d7704779112b4bc4296da, freebsd-9.3, 4a77611a223ea883fb548679b516d326a020d447
Children:
8fe59fe
Parents:
aa4f504
git-author:
Sebastian Huber <sebastian.huber@…> (02/13/15 09:31:27)
git-committer:
Sebastian Huber <sebastian.huber@…> (02/13/15 09:34:18)
Message:

Add and use rtems_bsd_get_allocator_domain_size()

Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • Makefile

    raa4f504 r5383ed4  
    7373LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-get-file.c
    7474LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-get-mac-address.c
     75LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-get-allocator-domain-size.c
    7576LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-get-task-priority.c
    7677LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-get-task-stack-size.c
  • freebsd-to-rtems.py

    raa4f504 r5383ed4  
    671671                'rtems/rtems-bsd-get-file.c',
    672672                'rtems/rtems-bsd-get-mac-address.c',
     673                'rtems/rtems-bsd-get-allocator-domain-size.c',
    673674                'rtems/rtems-bsd-get-task-priority.c',
    674675                'rtems/rtems-bsd-get-task-stack-size.c',
  • libbsd.txt

    raa4f504 r5383ed4  
    240240function which may be provided by the application in case the default is not
    241241appropriate.
     242
     243=== Size for Allocator Domains ===
     244
     245The size for an allocator domain can be specified via the
     246`rtems_bsd_get_allocator_domain_size()` function.  The application may provide
     247their own implementation of the `rtems_bsd_get_allocator_domain_size()`
     248function (for example in the module which calls `rtems_bsd_initialize()`) if
     249different values are desired.  The default size is 8MiB for all domains.
    242250
    243251== Network Stack Features
  • rtemsbsd/include/rtems/bsd/bsd.h

    raa4f504 r5383ed4  
    104104size_t rtems_bsd_get_task_stack_size(const char *name);
    105105
     106typedef enum {
     107        RTEMS_BSD_ALLOCATOR_DOMAIN_PAGE,
     108        RTEMS_BSD_ALLOCATOR_DOMAIN_MBUF,
     109        RTEMS_BSD_ALLOCATOR_DOMAIN_MALLOC
     110} rtems_bsd_allocator_domain;
     111
     112/**
     113 * @brief Returns the size for a specific allocator domain.
     114 *
     115 * Applications may provide their own implementation of this function.  For
     116 * example they can define their implementation in the same module which calls
     117 * rtems_bsd_initialize().
     118 *
     119 * @param[in] domain The allocator domain.
     120 *
     121 * @return The desired size for the specified allocator domain.
     122 */
     123uintptr_t rtems_bsd_get_allocator_domain_size(
     124    rtems_bsd_allocator_domain domain);
     125
    106126/**
    107127 * @brief Returns the Ethernet MAC address for a specified device.
  • rtemsbsd/rtems/rtems-bsd-page.c

    raa4f504 r5383ed4  
    5151#include <stdlib.h>
    5252
     53#include <rtems/bsd/bsd.h>
    5354#include <rtems/malloc.h>
    5455#include <rtems/rbheap.h>
    55 
    56 /* FIXME: This must be application configurable */
    57 #define PAGE_HEAP_SIZE (8 * 1024 * 1024)
    5856
    5957void **rtems_bsd_page_object_table;
     
    117115        size_t i;
    118116        size_t n;
     117        uintptr_t heap_size;
    119118
    120119        mtx_init(&page_heap_mtx, "page heap", NULL, MTX_DEF);
    121120
    122         area = rtems_heap_allocate_aligned_with_boundary(PAGE_HEAP_SIZE,
    123             PAGE_SIZE, 0);
     121        heap_size = rtems_bsd_get_allocator_domain_size(
     122            RTEMS_BSD_ALLOCATOR_DOMAIN_PAGE);
     123
     124        area = rtems_heap_allocate_aligned_with_boundary(heap_size, PAGE_SIZE,
     125            0);
    124126        BSD_ASSERT(area != NULL);
    125127
    126         sc = rtems_rbheap_initialize(&page_heap, area, PAGE_HEAP_SIZE,
    127             PAGE_SIZE, rtems_rbheap_extend_descriptors_with_malloc, NULL);
     128        sc = rtems_rbheap_initialize(&page_heap, area, heap_size, PAGE_SIZE,
     129            rtems_rbheap_extend_descriptors_with_malloc, NULL);
    128130        BSD_ASSERT(sc == RTEMS_SUCCESSFUL);
    129131
     
    131133            rtems_rbheap_extend_descriptors_never);
    132134
    133         n = PAGE_HEAP_SIZE / PAGE_SIZE;
     135        n = heap_size / PAGE_SIZE;
    134136
    135137        chunks = malloc(n * sizeof(*chunks), M_RTEMS_HEAP, M_NOWAIT);
Note: See TracChangeset for help on using the changeset viewer.