summaryrefslogtreecommitdiff
path: root/cesar/hal/phy/maximus/inc/maximus_bridgedma_ctx.h
blob: 16cbc8b595b8bdcae2fe944ae53e5031a8b332a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#ifndef MAXIMUS_BRIDGEDMA_CTX_H_
#define MAXIMUS_BRIDGEDMA_CTX_H_
/* Cesar project {{{
 *
 * Copyright (C) 2007 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    hal/phy/maximus/inc/maximus_bridgedma_ctx.h
 * \brief   HAL Bridge DMA context for Maximus.
 * \ingroup hal_phy_maximus
 */

#include "lib/crc.h"
#include "hal/phy/bridgedma.h"
#ifdef ECOS
#include <cyg/hal/drv_api.h>
#endif /* ECOS */
#include "host/station/station.h"

/** 1 byte is processed into 5ns, so 8 bytes per tick (40ns) */
#define BRIDGEDMA_BYTE_PER_TICK  8
/** max additionnal processing time is 10us, so 250 ticks */
#define BRIDGEDMA_ADD_MAX_TICK   250

#define HPAV_CRC32_GENERATOR 0x04c11db7
#define HPAV_CRC32_INIT      0xffffffff
#define HPAV_CRC32_MAGIC     0x2144df1c

typedef enum
{
    PB_TO_MACFRAME,
    MACFRAME_TO_PB
} bridgedma_copy_dir_t;

struct phy_bridgedma_t
{
    phy_bridgedma_status_t status;
    //phy_bridgedma_ctrl_t control;
    phy_bridgedma_job_t *job_first;
    phy_bridgedma_job_t *job_current;
    phy_bridgedma_job_t *job_last;
    uint32_t icv_substitution;
    uint32_t icv_current;
    crc_t crc_ctx;
    void *user_data;
    phy_bridgedma_cb_t bridgedma_cb;
    phy_deferred_cb_t deferred_cb;
    station_ctx_t *station;
    netclock_callback_t netclock_cb;
#ifdef ECOS
    cyg_interrupt interrupt;
    cyg_handle_t interrupt_handle;
#endif /* ECOS */
};

#ifndef ECOS
int _pb_data_add(blk_t **pb_current, unsigned char **pb_data_ptr, unsigned int pb_size,
    unsigned char *mac_ptr, unsigned int mac_len, bridgedma_copy_dir_t direction);
#endif /* ECOS */

#endif /*MAXIMUS_BRIDGEDMA_CTX_H_*/