Changeset 11f3b9a in rtems for bsps


Ignore:
Timestamp:
Nov 26, 2018, 2:55:38 PM (11 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
75e1009f
Parents:
8b59916
git-author:
Sebastian Huber <sebastian.huber@…> (11/26/18 14:55:38)
git-committer:
Sebastian Huber <sebastian.huber@…> (12/21/18 13:54:13)
Message:

bsps/sparc: Add grlib_malloc(), grlib_calloc()

This avoids a dependency to errno in device driver code.

Location:
bsps/sparc
Files:
38 edited

Legend:

Unmodified
Added
Removed
  • bsps/sparc/include/bsp/gr1553rt.h

    r8b59916 r11f3b9a  
    7575         * !!Array must at least be of length bd_cnt!!
    7676         */
    77         unsigned short bds[1];          /* Array of BDIDs, -1 unused/end */
     77        unsigned short bds[0];          /* Array of BDIDs */
    7878};
    7979
  • bsps/sparc/include/grlib_impl.h

    r8b59916 r11f3b9a  
    1111
    1212#include <rtems/score/basedefs.h>
     13#include <rtems/malloc.h>
    1314
    1415/*
     
    6465#endif
    6566
     67#if (((__RTEMS_MAJOR__ << 16) | (__RTEMS_MINOR__ << 8) | __RTEMS_REVISION__) >= 0x050000)
     68
     69RTEMS_INLINE_ROUTINE void *grlib_malloc(size_t size)
     70{
     71 return rtems_malloc(size);
     72}
     73
     74RTEMS_INLINE_ROUTINE void *grlib_calloc(size_t nelem, size_t elsize)
     75{
     76 return rtems_calloc(nelem, elsize);
     77}
     78
     79#else
     80
     81RTEMS_INLINE_ROUTINE void *grlib_malloc(size_t size)
     82{
     83 return malloc(size);
     84}
     85
     86RTEMS_INLINE_ROUTINE void *grlib_calloc(size_t nelem, size_t elsize)
     87{
     88 return calloc(nelem, elsize);
     89}
     90
     91#endif
     92
    6693#ifdef __cplusplus
    6794}
  • bsps/sparc/shared/1553/b1553brm.c

    r8b59916 r11f3b9a  
    3131#include <ambapp.h>
    3232#include <drvmgr/ambapp_bus.h>
     33
     34#include <grlib_impl.h>
    3335
    3436/* Uncomment for debug output */
     
    310312
    311313        DBG("B1553BRM[%d] on bus %s\n", dev->minor_drv, dev->parent->dev->name);
    312         priv = dev->priv = malloc(sizeof(brm_priv));
     314        priv = dev->priv = grlib_calloc(1, sizeof(*priv));
    313315        if ( !priv )
    314316                return DRVMGR_NOMEM;
    315         memset(priv, 0, sizeof(*priv));
    316317        priv->dev = dev;
    317318
     
    473474                         * alignment
    474475                         */
    475                         mem = (unsigned int)malloc(size + 128 * 1024);
     476                        mem = (unsigned int)grlib_malloc(size + 128 * 1024);
    476477                        if (!mem){
    477478                                printk("BRM: Failed to allocate HW memory\n\r");
     
    632633        brm->rtmem = (void *)brm->mem;
    633634
    634         brm->rt_event = (struct rt_msg *) malloc(EVENT_QUEUE_SIZE*sizeof(struct rt_msg));
     635        brm->rt_event = grlib_malloc(EVENT_QUEUE_SIZE*sizeof(*brm->rt_event));
    635636 
    636637        if (brm->rt_event == NULL) {
     
    760761        brm->rtmem = NULL;
    761762       
    762         brm->bm_event    = (struct bm_msg *) malloc(EVENT_QUEUE_SIZE*sizeof(struct bm_msg));
     763        brm->bm_event    = grlib_malloc(EVENT_QUEUE_SIZE*sizeof(*brm->bm_event));
    763764 
    764765        if (brm->bm_event == NULL) {
  • bsps/sparc/shared/1553/b1553rt.c

    r8b59916 r11f3b9a  
    2323#include <ambapp.h>
    2424#include <drvmgr/ambapp_bus.h>
     25
     26#include <grlib_impl.h>
    2527
    2628/* Uncomment for debug output */
     
    168170
    169171    DBG("B1553RT[%d] on bus %s\n", dev->minor_drv, dev->parent->dev->name);
    170     priv = dev->priv = malloc(sizeof(rt_priv));
     172    priv = dev->priv = grlib_calloc(1, sizeof(*priv));
    171173    if ( !priv )
    172174        return DRVMGR_NOMEM;
    173     memset(priv, 0, sizeof(*priv));
    174175    priv->dev = dev;
    175176
     
    319320             * 4k DMA memory + 4k for alignment
    320321             */
    321             mem = (unsigned int)malloc(4 * 1024 * 2);
     322            mem = (unsigned int)grlib_malloc(4 * 1024 * 2);
    322323            if ( !mem ){
    323324                printk("RT: Failed to allocate HW memory\n\r");
     
    459460    rt->rt_event = NULL;
    460461
    461     rt->rt_event = (struct rt_msg *) malloc(EVENT_QUEUE_SIZE*sizeof(struct rt_msg));
     462    rt->rt_event = grlib_malloc(EVENT_QUEUE_SIZE*sizeof(*rt->rt_event));
    462463
    463464    if (rt->rt_event == NULL) {
  • bsps/sparc/shared/1553/gr1553b.c

    r8b59916 r11f3b9a  
    1414#include <bsp/gr1553b.h>
    1515
     16#include <grlib_impl.h>
     17
    1618/* Driver Manager interface for BC, RT, BM, BRM, BC-BM and RT-BM */
    1719
     
    220222        struct gr1553b_regs *regs;
    221223
    222         priv = malloc(sizeof(struct gr1553_device));
     224        priv = grlib_malloc(sizeof(*priv));
    223225        if ( priv == NULL )
    224226                return DRVMGR_NOMEM;
     
    235237        if ( GR1553B_READ_REG(&regs->bm_stat) & GR1553B_BM_STAT_BMSUP ) {
    236238                priv->features |= FEAT_BM;
    237                 feat = malloc(sizeof(struct gr1553_device_feature));
     239                feat = grlib_malloc(sizeof(*feat));
    238240                feat->dev = priv;
    239241                /* Init Minor and Next */
     
    243245        if ( GR1553B_READ_REG(&regs->bc_stat) & GR1553B_BC_STAT_BCSUP ) {
    244246                priv->features |= FEAT_BC;
    245                 feat = malloc(sizeof(struct gr1553_device_feature));
     247                feat = grlib_malloc(sizeof(*feat));
    246248                feat->dev = priv;
    247249                /* Init Minor and Next */
     
    251253        if ( GR1553B_READ_REG(&regs->rt_stat) & GR1553B_RT_STAT_RTSUP ) {
    252254                priv->features |= FEAT_RT;
    253                 feat = malloc(sizeof(struct gr1553_device_feature));
     255                feat = grlib_malloc(sizeof(*feat));
    254256                feat->dev = priv;
    255257                /* Init Minor and Next */
  • bsps/sparc/shared/1553/gr1553bc.c

    r8b59916 r11f3b9a  
    9191int gr1553bc_list_alloc(struct gr1553bc_list **list, int max_major)
    9292{
    93         int size;
     93        size_t size;
    9494        struct gr1553bc_list *l;
    9595
    96         size = sizeof(struct gr1553bc_list) + max_major * sizeof(void *);
    97         l = malloc(size);
     96        size = sizeof(*l) + max_major * sizeof(void *);
     97        l = grlib_calloc(1, size);
    9898        if ( l == NULL )
    9999                return -1;
    100         memset(l, 0, size);
    101100
    102101        l->major_cnt = max_major;
     
    311310                if (bdtab_custom == NULL) {
    312311                        /* Allocate descriptors */
    313                         list->_table = malloc(size + (GR1553BC_BD_ALIGN-1));
     312                        list->_table = grlib_malloc(size + (GR1553BC_BD_ALIGN-1));
    314313                        if ( list->_table == NULL )
    315314                                return -1;
     
    509508        struct gr1553bc_major *maj;
    510509        struct gr1553bc_minor *minor;
    511         int size, i;
     510        size_t size;
     511        int i;
    512512
    513513        if ( (cfg == NULL) || (major == NULL) || (cfg->minor_cnt <= 0) )
     
    515515
    516516        /* Allocate Major Frame description, but no descriptors */
    517         size = sizeof(struct gr1553bc_major) + cfg->minor_cnt *
    518                 (sizeof(struct gr1553bc_minor) + sizeof(void *));
    519         maj = (struct gr1553bc_major *)malloc(size);
     517        size = sizeof(*maj) + cfg->minor_cnt *
     518                (sizeof(*minor) + sizeof(void *));
     519        maj = grlib_malloc(size);
    520520        if ( maj == NULL )
    521521                return -1;
     
    12491249                goto fail;
    12501250
    1251         irq_log_p = malloc(GR1553BC_IRQLOG_SIZE*2);
     1251        irq_log_p = grlib_malloc(GR1553BC_IRQLOG_SIZE*2);
    12521252        if ( irq_log_p == NULL )
    12531253                goto fail;
    12541254
    1255         priv = malloc(sizeof(struct gr1553bc_priv));
     1255        priv = grlib_calloc(1, sizeof(*priv));
    12561256        if ( priv == NULL )
    12571257                goto fail;
    1258         memset(priv, 0, sizeof(struct gr1553bc_priv));
    12591258
    12601259        /* Init BC device */
  • bsps/sparc/shared/1553/gr1553bm.c

    r8b59916 r11f3b9a  
    130130                goto fail;
    131131
    132         priv = malloc(sizeof(struct gr1553bm_priv));
     132        priv = grlib_calloc(1, sizeof(*priv));
    133133        if ( priv == NULL )
    134134                goto fail;
    135         memset(priv, 0, sizeof(struct gr1553bm_priv));
    136135
    137136        /* Init BC device */
     
    210209                if (cfg->buffer_custom == NULL) {
    211210                        /* Allocate new buffer dynamically */
    212                         priv->buffer = malloc(priv->buffer_size + 8);
     211                        priv->buffer = grlib_malloc(priv->buffer_size + 8);
    213212                        if (priv->buffer == NULL)
    214213                                return -1;
  • bsps/sparc/shared/1553/gr1553rt.c

    r8b59916 r11f3b9a  
    240240{
    241241        struct gr1553rt_priv *priv = rt;
    242         int i, size;
     242        size_t size;
     243        int i;
    243244        struct gr1553rt_sw_bd *swbd;
    244245        unsigned short index;
     
    254255        if ( list == NULL ) {
    255256                /* Dynamically allocate LIST */
    256                 size = offsetof(struct gr1553rt_list, bds) +
    257                         (cfg->bd_cnt * sizeof(unsigned short));
    258                 list = (struct gr1553rt_list *)malloc(size);
     257                size = sizeof(*list) +
     258                        (cfg->bd_cnt * sizeof(list->bds[0]));
     259                list = grlib_malloc(size);
    259260                if ( list == NULL )
    260261                        return -1;
     
    662663                goto fail;
    663664
    664         priv = malloc(sizeof(struct gr1553rt_priv));
     665        priv = grlib_calloc(1, sizeof(*priv));
    665666        if ( priv == NULL )
    666667                goto fail;
    667         memset(priv, 0, sizeof(struct gr1553rt_priv));
    668668
    669669        /* Assign a device private to RT device */
     
    787787        } else {
    788788                if (priv->cfg.evlog_buffer == NULL) {
    789                         priv->evlog_buffer = malloc(priv->cfg.evlog_size * 2);
     789                        priv->evlog_buffer = grlib_malloc(
     790                                priv->cfg.evlog_size * 2);
    790791                        if (priv->evlog_buffer == NULL)
    791792                                return -1;
     
    827828        } else {
    828829                if ( priv->cfg.bd_buffer == NULL ) {
    829                         priv->bd_buffer = malloc(size + 0xf);
     830                        priv->bd_buffer = grlib_malloc(size + 0xf);
    830831                        if (priv->bd_buffer == NULL)
    831832                                return -1;
     
    850851#if (RTBD_MAX == 0)
    851852        /* Allocate software description of */
    852         priv->swbds = malloc(priv->cfg.bd_count * sizeof(struct gr1553rt_sw_bd));
     853        priv->swbds = grlib_malloc(priv->cfg.bd_count * sizeof(*priv->swbds));
    853854        if ( priv->swbds == NULL ) {
    854855                return -1;
     
    870871        } else {
    871872                if (priv->cfg.satab_buffer == NULL) {
    872                         priv->satab_buffer = malloc((16 * 32) * 2);
     873                        priv->satab_buffer = grlib_malloc((16 * 32) * 2);
    873874                        if (priv->satab_buffer == NULL)
    874875                                return -1;
  • bsps/sparc/shared/amba/ambapp.c

    r8b59916 r11f3b9a  
    1717#include <bsp.h>
    1818
     19#include <grlib_impl.h>
     20
    1921#define AMBA_CONF_AREA 0xff000
    2022#define AMBA_AHB_SLAVE_CONF_AREA (1 << 11)
     
    3133  else
    3234    size += sizeof(struct ambapp_ahb_info); /* AHB */
    33   dev = (struct ambapp_dev *)calloc(1, size);
     35  dev = grlib_calloc(1, size);
    3436  if (dev != NULL)
    3537    dev->dev_type = dev_type;
  • bsps/sparc/shared/analog/gradcdac.c

    r8b59916 r11f3b9a  
    2929*/
    3030#include <bsp/debug_defs.h>
     31
     32#include <grlib_impl.h>
    3133
    3234struct gradcdac_priv {
     
    100102        DBG("GRADCDAC[%d] on bus %s\n", dev->minor_drv, dev->parent->dev->name);
    101103
    102         priv = dev->priv = malloc(sizeof(struct gradcdac_priv));
     104        priv = dev->priv = grlib_calloc(1, sizeof(*priv));
    103105        if ( !priv )
    104106                return DRVMGR_NOMEM;
    105         memset(priv, 0, sizeof(*priv));
    106107        priv->dev = dev;
    107108
  • bsps/sparc/shared/ascs/grascs.c

    r8b59916 r11f3b9a  
    1313#include <ambapp.h>
    1414#include <bsp/grascs.h>
     15
     16#include <grlib_impl.h>
    1517
    1618#ifndef GAISLER_ASCS
     
    197199 
    198200  /* Allocate memory for config, status and capability struct */
    199   if((cfg = (GRASCS_cfg*)malloc(sizeof(GRASCS_cfg))) == NULL) {
     201  if((cfg = grlib_malloc(sizeof(*cfg))) == NULL) {
    200202    DBG("ASCS_init: Could not allocate memory for cfg struc\n");
    201203    return -1;
    202204  }
    203205 
    204   if((cfg->caps = (GRASCS_caps*)calloc(1,sizeof(GRASCS_caps))) == NULL) {
     206  if((cfg->caps = grlib_calloc(1,sizeof(*cfg->caps))) == NULL) {
    205207    DBG("ASCS_init: Could not allocate memory for caps struc\n");
    206208    goto init_error1;
  • bsps/sparc/shared/btimer/gptimer.c

    r8b59916 r11f3b9a  
    5555#endif
    5656
     57#include <grlib_impl.h>
     58
    5759/* GPTIMER Core Configuration Register (READ-ONLY) */
    5860#define GPTIMER_CFG_TIMERS_BIT  0
     
    232234        size = sizeof(struct gptimer_priv) +
    233235                timer_cnt*sizeof(struct gptimer_timer);
    234         priv = dev->priv = (struct gptimer_priv *)malloc(size);
     236        priv = dev->priv = grlib_calloc(1, size);
    235237        if ( !priv )
    236238                return DRVMGR_NOMEM;
    237         memset(priv, 0, size);
    238239        priv->dev = dev;
    239240        priv->regs = regs;
  • bsps/sparc/shared/can/canmux.c

    r8b59916 r11f3b9a  
    1919#include <bsp/canmux.h>
    2020#include <ambapp.h>
     21
     22#include <grlib_impl.h>
    2123
    2224#ifndef GAISLER_CANMUX
     
    141143
    142144        /* Create private structure */
    143         if ((priv = malloc(sizeof(struct canmux_priv))) == NULL) {
     145        if ((priv = grlib_malloc(sizeof(*priv))) == NULL) {
    144146                printk("CAN_MUX driver could not allocate memory for priv structure\n\r");
    145147                return -1;
  • bsps/sparc/shared/can/grcan.c

    r8b59916 r11f3b9a  
    257257        if (GRCAN_COUNT_MAX <= grcan_count)
    258258                return DRVMGR_ENORES;
    259         priv = dev->priv = malloc(sizeof(struct grcan_priv));
     259        priv = dev->priv = grlib_calloc(1, sizeof(*priv));
    260260        if ( !priv )
    261261                return DRVMGR_NOMEM;
    262         memset(priv, 0, sizeof(*priv));
    263262        priv->dev = dev;
    264263
     
    11141113                } else {
    11151114                        if (adr == 0) {
    1116                                 pDev->_tx = malloc(pDev->txbuf_size +
     1115                                pDev->_tx = grlib_malloc(pDev->txbuf_size +
    11171116                                                   BUFFER_ALIGNMENT_NEEDS);
    11181117                                if (!pDev->_tx)
     
    11581157                } else {
    11591158                        if (adr == 0) {
    1160                                 pDev->_rx = malloc(pDev->rxbuf_size +
     1159                                pDev->_rx = grlib_malloc(pDev->rxbuf_size +
    11611160                                                   BUFFER_ALIGNMENT_NEEDS);
    11621161                                if (!pDev->_rx)
  • bsps/sparc/shared/can/occan.c

    r8b59916 r11f3b9a  
    8181        CANMsg *tail, *head;
    8282        CANMsg *base;
    83         char fifoarea[0];
     83        CANMsg fifoarea[0];
    8484} occan_fifo;
    8585
     
    449449
    450450        DBG("OCCAN[%d] on bus %s\n", dev->minor_drv, dev->parent->dev->name);
    451         priv = dev->priv = malloc(sizeof(occan_priv));
     451        priv = dev->priv = grlib_calloc(1, sizeof(*priv));
    452452        if ( !priv )
    453453                return DRVMGR_NOMEM;
    454         memset(priv, 0, sizeof(*priv));
    455454        priv->dev = dev;
    456455
     
    18821881{
    18831882        occan_fifo *fifo;
    1884         fifo = malloc(sizeof(occan_fifo)+cnt*sizeof(CANMsg));
     1883        fifo = grlib_calloc(1, sizeof(*fifo)+cnt*sizeof(CANMsg));
    18851884        if ( fifo ){
    18861885                fifo->cnt = cnt;
    1887                 fifo->full = 0;
    1888                 fifo->ovcnt = 0;
    1889                 fifo->base = (CANMsg *)&fifo->fifoarea[0];
     1886                fifo->base = &fifo->fifoarea[0];
    18901887                fifo->tail = fifo->head = fifo->base;
    1891                 /* clear CAN Messages */
    1892                 memset(fifo->base,0,cnt * sizeof(CANMsg));
    18931888        }
    18941889        return fifo;
  • bsps/sparc/shared/can/satcan.c

    r8b59916 r11f3b9a  
    2020#include <ambapp.h>
    2121
     22#include <grlib_impl.h>
     23
    2224#ifndef GAISLER_SATCAN
    2325#define GAISLER_SATCAN 0x080
     
    147149static void almalloc(unsigned char **alptr, void **ptr, int sz)
    148150{
    149   *ptr = calloc(1,2*sz);
     151  *ptr = rtems_calloc(1,2*sz);
    150152  *alptr = (unsigned char *) (((int)*ptr+sz) & ~(sz-1));
    151153}
     
    683685
    684686        /* Create private structure */
    685         if ((priv = malloc(sizeof(struct satcan_priv))) == NULL) {
     687        if ((priv = grlib_malloc(sizeof(*priv))) == NULL) {
    686688                printk("SatCAN driver could not allocate memory for priv structure\n\r");
    687689                return -1;
     
    689691
    690692        DBG("SatCAN: Creating local copy of config structure\n\r");
    691         if ((priv->cfg = malloc(sizeof(satcan_config))) == NULL) {
     693        if ((priv->cfg = grlib_malloc(sizeof(*priv->cfg))) == NULL) {
    692694                printk("SatCAN driver could not allocate memory for cfg structure\n\r");
    693695                return 1;
  • bsps/sparc/shared/drvmgr/ambapp_bus_grlib.c

    r8b59916 r11f3b9a  
    2525#include <bsp/irq.h>
    2626
     27#include <grlib_impl.h>
     28
    2729#define DBG(args...)
    2830/*#define DBG(args...) printk(args)*/
     
    152154        DBG("AMBAPP GRLIB: intializing\n");
    153155
    154         config = malloc(sizeof(struct ambapp_config));
     156        config = grlib_malloc(sizeof(*config));
    155157        if ( !config )
    156158                return RTEMS_NO_MEMORY;
  • bsps/sparc/shared/gpio/gpiolib.c

    r8b59916 r11f3b9a  
    1515#include <bsp/gpiolib.h>
    1616
     17#include <grlib_impl.h>
     18
    1719struct gpiolib_port;
    1820
     
    7981                return -1;
    8082
    81         port = malloc(sizeof(*port));
     83        port = grlib_calloc(1, sizeof(*port));
    8284        if ( port == NULL )
    8385                return -1;
    8486
    85         memset(port, 0, sizeof(*port));
    8687        port->handle = handle;
    8788        port->minor = port_nr++;
  • bsps/sparc/shared/gpio/grgpio.c

    r8b59916 r11f3b9a  
    2323#include <ambapp.h>
    2424#include <grlib.h>
     25#include <grlib_impl.h>
    2526
    2627/*#define DEBUG 1*/
     
    118119                return DRVMGR_FAIL;
    119120
    120         priv = dev->priv = malloc(sizeof(struct grgpio_priv));
     121        priv = dev->priv = grlib_calloc(1, sizeof(*priv));
    121122        if ( !priv )
    122123                return DRVMGR_NOMEM;
    123         memset(priv, 0, sizeof(*priv));
    124124        priv->dev = dev;
    125125
  • bsps/sparc/shared/i2c/i2cmst.c

    r8b59916 r11f3b9a  
    2222
    2323#include <bsp/i2cmst.h>
     24
     25#include <grlib_impl.h>
    2426
    2527/* Enable debug printks? */
     
    340342        DBG("I2CMST[%d] on bus %s\n", dev->minor_drv, dev->parent->dev->name);
    341343
    342         priv = dev->priv = malloc(sizeof(gr_i2cmst_prv_t));
     344        priv = dev->priv = grlib_calloc(1, sizeof(*priv));
    343345        if ( !priv )
    344346                return DRVMGR_NOMEM;
    345         memset(priv, 0, sizeof(*priv));
    346347        priv->dev = dev;
    347348
  • bsps/sparc/shared/iommu/griommu.c

    r8b59916 r11f3b9a  
    1919#include <bsp.h>
    2020#include <bsp/griommu.h>
     21
     22#include <grlib_impl.h>
    2123
    2224/*#define STATIC*/
     
    10281030
    10291031        /* Allocate APV */
    1030         unsigned int * orig_ptr = (unsigned int *) malloc(
     1032        unsigned int * orig_ptr = grlib_malloc(
    10311033                        (GRIOMMU_APV_SIZE/priv->pagesize) + GRIOMMU_APV_ALIGN);
    10321034        if (orig_ptr == NULL) return NULL;
  • bsps/sparc/shared/irq/genirq.c

    r8b59916 r11f3b9a  
    1616#include <bsp/genirq.h>
    1717
     18#include <grlib_impl.h>
     19
    1820struct genirq_handler_entry {
    1921        struct genirq_handler_entry     *next;          /* Next ISR entry for this IRQ number */
     
    3234        int                             genirq_max;
    3335        /* IRQ Table index N reflect IRQ number N */
    34         struct genirq_irq_entry         genirq_table[1]; /* Length depends on */
     36        struct genirq_irq_entry         genirq_table[0]; /* Length depends on */
    3537};
    3638
    3739genirq_t genirq_init(int number_of_irqs)
    3840{
    39         int size;
     41        size_t size;
    4042        struct genirq_priv *priv;
    4143
    42         size = sizeof(int) +
    43                number_of_irqs * sizeof(struct genirq_irq_entry);
    44 
    45         priv = (struct genirq_priv *)malloc(size);
     44        size = sizeof(*priv) +
     45               number_of_irqs * sizeof(priv->genirq_table[0]);
     46
     47        priv = grlib_calloc(1, size);
    4648        if ( !priv )
    4749                return NULL;
    48         memset(priv, 0, size);
    4950        priv->genirq_max = number_of_irqs - 1;
    5051
     
    8788        struct genirq_handler_entry *newentry;
    8889
    89         newentry = malloc(sizeof(struct genirq_handler_entry));
     90        newentry = grlib_malloc(sizeof(*newentry));
    9091        if ( newentry ) {
    9192                /* Initialize ISR entry */
  • bsps/sparc/shared/mem/mctrl.c

    r8b59916 r11f3b9a  
    2323#include <bsp/mctrl.h>
    2424
     25#include <grlib_impl.h>
     26
    2527#define MEMSET(priv, start, c, length) memset((void *)start, c, length)
    2628
     
    106108
    107109        DBG("MCTRL[%d] on bus %s\n", dev->minor_drv, dev->parent->dev->name);
    108         priv = dev->priv = malloc(sizeof(struct mctrl_priv));
     110        priv = dev->priv = grlib_calloc(1, sizeof(*priv));
    109111        if ( !priv )
    110112                return DRVMGR_NOMEM;
    111         memset(priv, 0, sizeof(*priv));
    112113        priv->dev = dev;
    113114
  • bsps/sparc/shared/net/greth.c

    r8b59916 r11f3b9a  
    4444#include <netinet/if_ether.h>
    4545
    46 #include <grlib_impl.h>
    47 
    4846#ifdef malloc
    4947#undef malloc
     
    5250#undef free
    5351#endif
     52
     53#include <grlib_impl.h>
    5454
    5555#if defined(__m68k__)
     
    217217{
    218218        char *tmp;
    219         tmp = calloc(1, sz + (alignment-1));
     219        tmp = grlib_calloc(1, sz + (alignment-1));
    220220        tmp = (char *) (((int)tmp+alignment) & ~(alignment -1));
    221221        return(tmp);
     
    636636    regs->rxdesc = (int) sc->rxdesc_remote;
    637637
    638     sc->rxmbuf = calloc(sc->rxbufs, sizeof(*sc->rxmbuf));
    639     sc->txmbuf = calloc(sc->txbufs, sizeof(*sc->txmbuf));
     638    sc->rxmbuf = grlib_calloc(sc->rxbufs, sizeof(*sc->rxmbuf));
     639    sc->txmbuf = grlib_calloc(sc->txbufs, sizeof(*sc->txmbuf));
    640640
    641641    for (i = 0; i < sc->txbufs; i++)
     
    646646                sc->dev,
    647647                CPUMEM_TO_DMA,
    648                 (void *)malloc(GRETH_MAXBUF_LEN),
     648                (void *)grlib_malloc(GRETH_MAXBUF_LEN),
    649649                (void **)&sc->txdesc[i].addr,
    650650                GRETH_MAXBUF_LEN);
     
    15041504
    15051505        DBG("GRETH[%d] on bus %s\n", dev->minor_drv, dev->parent->dev->name);
    1506         priv = dev->priv = malloc(sizeof(struct greth_softc));
     1506        priv = dev->priv = grlib_calloc(1, sizeof(*priv));
    15071507        if ( !priv )
    15081508                return DRVMGR_NOMEM;
    1509         memset(priv, 0, sizeof(*priv));
    15101509        priv->dev = dev;
    15111510
     
    15361535
    15371536    /* Register GRETH device as an Network interface */
    1538     ifp = malloc(sizeof(struct rtems_bsdnet_ifconfig));
    1539     memset(ifp, 0, sizeof(*ifp));
     1537    ifp = grlib_cmalloc(1, sizeof(*ifp));
    15401538
    15411539    ifp->name = sc->devName;
  • bsps/sparc/shared/pci/gr_701.c

    r8b59916 r11f3b9a  
    317317        int resources_cnt;
    318318
    319         priv = malloc(sizeof(struct gr701_priv));
     319        priv = grlib_calloc(1, sizeof(*priv));
    320320        if ( !priv )
    321321                return DRVMGR_NOMEM;
    322322
    323         memset(priv, 0, sizeof(*priv));
    324323        dev->priv = priv;
    325324        priv->dev = dev;
  • bsps/sparc/shared/pci/gr_rasta_adcdac.c

    r8b59916 r11f3b9a  
    381381        int resources_cnt;
    382382
    383         priv = malloc(sizeof(struct gr_rasta_adcdac_priv));
     383        priv = grlib_calloc(1, sizeof(*priv));
    384384        if ( !priv )
    385385                return DRVMGR_NOMEM;
    386386
    387         memset(priv, 0, sizeof(*priv));
    388387        dev->priv = priv;
    389388        priv->dev = dev;
  • bsps/sparc/shared/pci/gr_rasta_io.c

    r8b59916 r11f3b9a  
    560560        int resources_cnt;
    561561
    562         priv = malloc(sizeof(struct gr_rasta_io_priv));
     562        priv = grlib_calloc(1, sizeof(*priv));
    563563        if ( !priv )
    564564                return DRVMGR_NOMEM;
    565565
    566         memset(priv, 0, sizeof(*priv));
    567566        dev->priv = priv;
    568567        priv->dev = dev;
  • bsps/sparc/shared/pci/gr_tmtc_1553.c

    r8b59916 r11f3b9a  
    300300        ((struct pci_dev_info *)dev->businfo)->irq = ((struct amba_dev_info *)dev->parent->dev->businfo)->info.irq;
    301301
    302         priv = malloc(sizeof(struct gr_tmtc_1553_priv));
     302        priv = grlib_calloc(1, sizeof(*priv));
    303303        if ( !priv )
    304304                return DRVMGR_NOMEM;
    305305
    306         memset(priv, 0, sizeof(*priv));
    307306        dev->priv = priv;
    308307        priv->dev = dev;
  • bsps/sparc/shared/pci/grpci2dma.c

    r8b59916 r11f3b9a  
    12861286{
    12871287        /* Allocate memory */
    1288         unsigned int * orig_ptr = (unsigned int *) malloc(
     1288        unsigned int * orig_ptr = (unsigned int *) grlib_malloc(
    12891289                        (GRPCI2DMA_BD_CHAN_SIZE)*number + GRPCI2DMA_BD_CHAN_ALIGN);
    12901290        if (orig_ptr == NULL) return NULL;
     
    13181318{
    13191319        /* Allocate memory */
    1320         unsigned int * orig_ptr = (unsigned int *) malloc(
     1320        unsigned int * orig_ptr = (unsigned int *) grlib_malloc(
    13211321                        (GRPCI2DMA_BD_DATA_SIZE)*number + GRPCI2DMA_BD_DATA_ALIGN);
    13221322        if (orig_ptr == NULL) return NULL;
     
    13761376
    13771377        /* Allocate and init Memory for DMA */
    1378         int size = sizeof(struct grpci2dma_priv);
    1379         priv = (struct grpci2dma_priv *) malloc(size);
     1378        priv = grlib_calloc(1, sizeof(*priv));
    13801379        if (priv == NULL)
    13811380                return DRVMGR_NOMEM;
    13821381
    1383         /* Initialize all fields */
    1384         memset(priv, 0, size);
    13851382        priv->regs = regs;
    13861383        strncpy(&priv->devname[0], "grpci2dma0", DEVNAME_LEN);
  • bsps/sparc/shared/pwm/grpwm.c

    r8b59916 r11f3b9a  
    2222#include <bsp/grpwm.h>
    2323#include <ambapp.h>
     24
     25#include <grlib_impl.h>
    2426
    2527/* #define DEBUG 1 */
     
    223225        DBG("GRPWM[%d] on bus %s\n", dev->minor_drv, dev->parent->dev->name);
    224226
    225         priv = dev->priv = malloc(sizeof(struct grpwm_priv));
     227        priv = dev->priv = grlib_malloc(sizeof(*priv));
    226228        if ( !priv )
    227229                return DRVMGR_NOMEM;
     
    790792        /* Find the number of PWM channels */
    791793        priv->channel_cnt = 1 + ((regs->cap1 & GRPWM_CAP_NPWM) >> GRPWM_CAP_NPWM_BIT);
    792         pwm = malloc(sizeof(*pwm)*priv->channel_cnt);
     794        pwm = grlib_calloc(priv->channel_cnt, sizeof(*pwm));
    793795        if ( !pwm )
    794796                return -1;
    795         memset(pwm, 0, sizeof(*pwm)*priv->channel_cnt);
    796797
    797798        /* Init all PWM channels */
  • bsps/sparc/shared/slink/grslink.c

    r8b59916 r11f3b9a  
    2727#include <ambapp.h>
    2828
     29#include <grlib_impl.h>
     30
    2931#ifndef GAISLER_SLINK
    3032#define GAISLER_SLINK 0x02F
     
    102104        int i, j;
    103105
    104         if ((q = malloc(SLINK_NUMQUEUES*sizeof(SLINK_queue))) == NULL)
     106        if ((q = grlib_malloc(SLINK_NUMQUEUES*sizeof(*q))) == NULL)
    105107                goto slink_qiniterr1;
    106108               
    107109        for (i = 0; i < SLINK_NUMQUEUES; i++) {
    108110                q[i].size = size;
    109                 if ((q[i].buf = malloc(size*sizeof(int))) == NULL)
     111                if ((q[i].buf = grlib_malloc(size*sizeof(int))) == NULL)
    110112                        goto slink_qiniterr2;
    111113                q[i].first = q[i].last = q[i].buf;
     
    346348
    347349        /* Allocate private config structure */
    348         if (cfg == NULL && (cfg = malloc(sizeof(SLINK_cfg))) == NULL) {
     350        if (cfg == NULL && (cfg = grlib_malloc(sizeof(*cfg))) == NULL) {
    349351                DBG("SLINK_init: Could not allocate cfg structure\n");
    350352                goto slink_initerr1;
     
    370372
    371373        /* Allocate status structure and initialize members */
    372         if ((cfg->status = calloc(1, sizeof(SLINK_status))) == NULL) {
     374        if ((cfg->status = grlib_calloc(1, sizeof(*cfg->status))) == NULL) {
    373375                DBG("SLINK_init: Could not allocate status structure\n");
    374376                goto slink_initerr2;
     
    379381#ifdef SLINK_COLLECT_STATISTICS
    380382        /* Allocate statistics structure and initialize members */
    381         if ((cfg->stats = calloc(1, sizeof(SLINK_stats))) == NULL) {
     383        if ((cfg->stats = grlib_calloc(1, sizeof(*cfg->stats))) == NULL) {
    382384                DBG("SLINK_init: Could not allocate statistics structure\n");
    383385                goto slink_initerr3;
  • bsps/sparc/shared/spi/spictrl.c

    r8b59916 r11f3b9a  
    2424
    2525#include <rtems/libi2c.h>
     26
     27#include <grlib_impl.h>
    2628
    2729/*#define DEBUG 1*/
     
    217219        DBG("SPICTRL[%d] on bus %s\n", dev->minor_drv, dev->parent->dev->name);
    218220
    219         priv = dev->priv = malloc(sizeof(struct spictrl_priv));
     221        priv = dev->priv = grlib_calloc(1, sizeof(*priv));
    220222        if ( !priv )
    221223                return DRVMGR_NOMEM;
    222         memset(priv, 0, sizeof(*priv));
    223224        priv->dev = dev;
    224225
  • bsps/sparc/shared/spw/grspw.c

    r8b59916 r11f3b9a  
    1818#include <ctype.h>
    1919#include <rtems/bspIo.h>
    20 #include <rtems/malloc.h>
    2120#include <ambapp.h>
    2221
     
    2423#include <drvmgr/ambapp_bus.h>
    2524#include <bsp/grspw.h>
     25
     26#include <grlib_impl.h>
    2627
    2728#define DBGSPW_IOCALLS 1
     
    386387        SPACEWIRE_DBG("GRSPW[%d] on bus %s\n", dev->minor_drv,
    387388                dev->parent->dev->name);
    388         priv = dev->priv = malloc(sizeof(GRSPW_DEV));
     389        priv = dev->priv = grlib_calloc(1, sizeof(*priv));
    389390        if ( !priv )
    390391                return DRVMGR_NOMEM;
    391         memset(priv, 0, sizeof(*priv));
    392392        priv->dev = dev;
    393393
     
    629629                        if (pDev->_ptr_rxbuf0)
    630630                                free((void *)pDev->_ptr_rxbuf0);
    631                         pDev->_ptr_rxbuf0 = (unsigned int) malloc(pDev->rxbufsize * pDev->rxbufcnt+4);
     631                        pDev->_ptr_rxbuf0 = (unsigned int) grlib_malloc(
     632                                pDev->rxbufsize * pDev->rxbufcnt+4);
    632633                        pDev->ptr_rxbuf0 = (char *)((pDev->_ptr_rxbuf0+7)&~7);
    633634                        if ( !pDev->ptr_rxbuf0 )
     
    658659                        if (pDev->ptr_txdbuf0)
    659660                                free(pDev->ptr_txdbuf0);
    660                         pDev->ptr_txdbuf0 = (char *) malloc(pDev->txdbufsize * pDev->txbufcnt);
     661                        pDev->ptr_txdbuf0 = (char *) grlib_malloc(
     662                                pDev->txdbufsize * pDev->txbufcnt);
    661663                        if (!pDev->ptr_txdbuf0)
    662664                                return 1;
     
    686688                        if (pDev->ptr_txhbuf0)
    687689                                free(pDev->ptr_txhbuf0);
    688                         pDev->ptr_txhbuf0 = (char *) malloc(pDev->txhbufsize * pDev->txbufcnt);
     690                        pDev->ptr_txhbuf0 = (char *) grlib_malloc(
     691                                pDev->txhbufsize * pDev->txbufcnt);
    689692                        if (!pDev->ptr_txhbuf0)
    690693                                return 1;
  • bsps/sparc/shared/spw/grspw_pkt.c

    r8b59916 r11f3b9a  
    2121#include <assert.h>
    2222#include <ctype.h>
    23 #include <malloc.h>
    2423#include <rtems/bspIo.h>
    2524
     
    550549                }
    551550        } else {
    552                 priv->bd_mem_alloced = (unsigned int)malloc(bdtabsize + BDTAB_ALIGN - 1);
     551                priv->bd_mem_alloced = (unsigned int)grlib_malloc(bdtabsize + BDTAB_ALIGN - 1);
    553552                if (priv->bd_mem_alloced == 0) {
    554553                        priv = NULL;
     
    16861685        /* Allocate memory for the two descriptor rings */
    16871686        size = sizeof(struct grspw_ring) * (GRSPW_RXBD_NR + GRSPW_TXBD_NR);
    1688         dma->rx_ring_base = (struct grspw_rxring *)malloc(size);
     1687        dma->rx_ring_base = grlib_malloc(size);
    16891688        dma->tx_ring_base = (struct grspw_txring *)&dma->rx_ring_base[GRSPW_RXBD_NR];
    16901689        if (dma->rx_ring_base == NULL)
     
    30573056        struct amba_dev_info *ambadev;
    30583057        struct ambapp_core *pnpinfo;
    3059         int i, size;
     3058        int i;
    30603059        unsigned int ctrl, icctrl, numi;
    30613060        union drvmgr_key_value *value;
     
    31453144
    31463145        /* Allocate and init Memory for all DMA channels */
    3147         size = sizeof(struct grspw_dma_priv) * priv->hwsup.ndma_chans;
    3148         priv->dma = (struct grspw_dma_priv *) malloc(size);
     3146        priv->dma = grlib_calloc(priv->hwsup.ndma_chans, sizeof(*priv->dma));
    31493147        if (priv->dma == NULL)
    31503148                return DRVMGR_NOMEM;
    3151         memset(priv->dma, 0, size);
    31523149        for (i=0; i<priv->hwsup.ndma_chans; i++) {
    31533150                priv->dma[i].core = priv;
  • bsps/sparc/shared/time/grctm.c

    r8b59916 r11f3b9a  
    1616#include <bsp/grctm.h>
    1717
     18#include <grlib_impl.h>
     19
    1820/* Private structure of GRCTM driver */
    1921struct grctm_priv {
     
    352354        struct grctm_regs *regs;
    353355
    354         priv = (struct grctm_priv *)malloc(sizeof(*priv));
     356        priv = grlib_calloc(1, sizeof(*priv));
    355357        if ( priv == NULL )
    356358                return -1;
    357         memset(priv, 0, sizeof(*priv));
    358359        priv->dev = dev;
    359360        dev->priv = priv;
  • bsps/sparc/shared/time/spwcuc.c

    r8b59916 r11f3b9a  
    1414#include <stdlib.h>
    1515#include <string.h>
    16  
     16
    1717#include <bsp/spwcuc.h>
     18
     19#include <grlib_impl.h>
    1820
    1921/* Private structure of SPWCUC driver. */
     
    312314        struct spwcuc_regs *regs;
    313315
    314         priv = (struct spwcuc_priv *)malloc(sizeof(*priv));
     316        priv = grlib_calloc(1, sizeof(*priv));
    315317        if ( priv == NULL )
    316318                return -1;
    317         memset(priv, 0, sizeof(*priv));
    318319        priv->dev = dev;
    319320        dev->priv = priv;
  • bsps/sparc/shared/tmtc/grtc.c

    r8b59916 r11f3b9a  
    1616#include <assert.h>
    1717#include <ctype.h>
    18 #include <malloc.h>
    1918#include <rtems/bspIo.h>
    2019
     
    618617static void *grtc_memalign(unsigned int boundary, unsigned int length, void *realbuf)
    619618{
    620         *(int *)realbuf = (int)malloc(length+(~GRTC_ASR_BUFST)+1);
     619        *(int *)realbuf = (int)grlib_malloc(length+(~GRTC_ASR_BUFST)+1);
    621620        DBG("GRTC: Alloced %d (0x%x) bytes, requested: %d\n",length+(~GRTC_ASR_BUFST)+1,length+(~GRTC_ASR_BUFST)+1,length);
    622621        return (void *)(((*(unsigned int *)realbuf)+(~GRTC_ASR_BUFST)+1) & ~(boundary-1));
     
    17801779                        free(pDev->pools);
    17811780                }
    1782                 pDev->pools = malloc(pocfg->pool_cnt * sizeof(struct grtc_frame_pool));
     1781                pDev->pools = grlib_malloc(pocfg->pool_cnt * sizeof(*pDev->pools));
    17831782                if ( !pDev->pools ) {
    17841783                        pDev->pool_cnt = 0;
  • bsps/sparc/shared/tmtc/grtm.c

    r8b59916 r11f3b9a  
    1616#include <assert.h>
    1717#include <ctype.h>
    18 #include <malloc.h>
    1918#include <rtems/bspIo.h>
    2019
     
    450449
    451450        DBG("GRTM[%d] on bus %s\n", dev->minor_drv, dev->parent->dev->name);
    452         priv = dev->priv = malloc(sizeof(struct grtm_priv));
     451        priv = dev->priv = grlib_calloc(1, sizeof(*priv));
    453452        if ( !priv )
    454453                return DRVMGR_NOMEM;
    455         memset(priv, 0, sizeof(*priv));
    456454        priv->dev = dev;
    457455
     
    585583        memset(pDev->bds, 0, 0x400);
    586584
    587         pDev->_ring = malloc(sizeof(struct grtm_ring) * 128);
     585        pDev->_ring = grlib_malloc(sizeof(*pDev->_ring) * 128);
    588586        if ( !pDev->_ring ) {
    589587                return -1;
     
    693691static void *grtm_memalign(unsigned int boundary, unsigned int length, void *realbuf)
    694692{
    695         *(int *)realbuf = (int)malloc(length+boundary);
     693        *(int *)realbuf = (int)grlib_malloc(length+boundary);
    696694        DBG("GRTM: Alloced %d (0x%x) bytes, requested: %d\n",length+boundary,length+boundary,length);
    697695        return (void *)(((*(unsigned int *)realbuf)+boundary) & ~(boundary-1));
Note: See TracChangeset for help on using the changeset viewer.