summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/lm32/shared/milkymist_networking/network.h
blob: 6d967c5b6c25ebdb4e717f1e8378aea5e8b0adbb (plain) (blame)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*  network.h
 *
 *  RTEMS driver for Minimac ethernet IP-core of Milkymist SoC
 *
 *  The license and distribution terms for this file may be
 *  found in the file LICENSE in this distribution or at
 *  http://www.rtems.com/license/LICENSE.
 *
 *  $Id$
 *
 *  COPYRIGHT (c) Yann Sionneau <yann.sionneau@telecom-sudparis.eu> (GSoC 2010)
 *  Telecom SudParis, France
 */


#ifndef _MM_NETWORKING_H_
#define _MM_NETWORKING_H_

#include "../include/system_conf.h"

#define IRQ_ETHRX 11
#define IRQ_ETHTX 12

#define INTERRUPT_EVENT RTEMS_EVENT_1
#define START_TRANSMIT_EVENT  RTEMS_EVENT_2

#define MINIMAC_STATE_EMPTY (0x0)
#define MINIMAC_STATE_LOADED  (0x1)
#define MINIMAC_STATE_PENDING (0x2)

#define MINIMAC_SETUP_RXRST (0x1)
#define MINIMAC_SETUP_TXRST (0x2)

#define NB_RX_SLOTS 4

#define MM_ETHTX_IRQMASK  (1 << IRQ_ETHTX)
#define MM_ETHRX_IRQMASK  (1 << IRQ_ETHRX)
#define ETHERNET_FRAME_LENGTH 1532

struct mm_packet {
  unsigned char preamble[8];
  char raw_data[MLEN];
} __attribute__((aligned(4), packed));

struct minimac_softc {

  struct arpcom arpcom;
  uint8_t registered;

  /*
   *  Statistics
   */

  rtems_id  rxDaemonTid;
  rtems_id  txDaemonTid;

  unsigned long int rxInterrupts;
  unsigned long int txInterrupts;
  unsigned long int rxedPackets;
  unsigned long int txFifoFull;
  unsigned long int txErrors;
};

int rtems_minimac_driver_attach (struct rtems_bsdnet_ifconfig *, int);

static void minimac_start(struct ifnet *);
static void minimac_init(void *);
static int minimac_ioctl(struct ifnet *, ioctl_command_t, caddr_t);
static void minimac_stop(struct minimac_softc *);

static void minimac_txDaemon(void *);
static void minimac_rxDaemon(void *);
static void minimac_sendpacket(struct ifnet *, struct mbuf *);

static rtems_isr minimac_rx_interrupt_handler (rtems_vector_number);
static rtems_isr minimac_tx_interrupt_handler (rtems_vector_number);

static void minimac_stats(struct minimac_softc *);

#endif