summaryrefslogtreecommitdiff
path: root/common/usbx_network/inc/ux_network_driver.h
blob: 20c02c098272f475dbe3ca977503e690d3da45c4 (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/***************************************************************************
 * Copyright (c) 2024 Microsoft Corporation
 * Copyright (c) 2026-present Eclipse ThreadX contributors
 *
 * This program and the accompanying materials are made available under the
 * terms of the MIT License which is available at
 * https://opensource.org/licenses/MIT.
 *
 * SPDX-License-Identifier: MIT
 **************************************************************************/


/**************************************************************************/
/**************************************************************************/
/**                                                                       */
/** USBX Component                                                        */
/**                                                                       */
/**   USBX Network Driver for NETX 5.3 and above                          */
/**                                                                       */
/**************************************************************************/
/**************************************************************************/


/**************************************************************************/
/*                                                                        */
/*  COMPONENT DEFINITION                                   RELEASE        */
/*                                                                        */
/*    ux_network_driver.h                                 PORTABLE C      */
/*                                                           6.1.12       */
/*  AUTHOR                                                                */
/*                                                                        */
/*    Chaoqiong Xiao, Microsoft Corporation                               */
/*                                                                        */
/*  DESCRIPTION                                                           */
/*                                                                        */
/*    This file contains all the header and extern functions used by the  */
/*    USBX Network driver.                                                */
/*                                                                        */
/**************************************************************************/

#ifndef UX_NETWORK_DRIVER_H
#define UX_NETWORK_DRIVER_H

/* Determine if a C++ compiler is being used.  If so, ensure that standard
   C is used to process the API information.  */

#ifdef   __cplusplus

/* Yes, C++ compiler is present.  Use standard C.  */
extern   "C" {

#endif

#include "tx_api.h"
#include "nx_api.h"
#define USB_NETWORK_DEVICE_MAX_INSTANCES    8
#define USB_NETWORK_DRIVER_SUCCESS          UX_SUCCESS
#define USB_NETWORK_DRIVER_FAILURE          UX_ERROR

#define USB_NETWORK_DEVICE_MAC_HEADER_SIZE  14
#define NX_ETHERNET_SIZE                    14
#define NX_ETHERNET_ARP                     0x0806
#define NX_ETHERNET_RARP                    0x0835
#define NX_ETHERNET_IP                      0x0800
#define NX_ETHERNET_IPV6                    0x86DD
#define NX_ETHERNET_MTU                     1514

typedef struct USB_NETWORK_DEVICE_STRUCT
{

    /* ip_instance is populated by NetX, as part of the interface attachment. */
    NX_IP           *ux_network_device_ip_instance;

    /* interface_ptr is populated by NetX, as part of the interface attachment. */
    NX_INTERFACE    *ux_network_device_interface_ptr;

    /* Define synchronization objects for deactivation. Note that these are only
       used if the activation/deactivation functions are not called under interrupt.  */
    UCHAR           ux_network_device_activated_by_thread;
    TX_MUTEX        ux_network_device_deactivate_mutex;
    TX_SEMAPHORE    ux_network_device_deactivate_semaphore;
    UCHAR           ux_network_device_deactivate_thread_waiting;
    UINT            ux_network_device_num_threads_inside;

    /* usb_instance is populated by USB instance activation. */
    VOID            *ux_network_device_usb_instance_ptr;

    /* The write_function is populated by USB instance activation. */
    UINT            (*ux_network_device_write_function)(VOID *ux_instance, NX_PACKET *packet_ptr);

    USHORT          ux_network_device_usb_link_up;
    USHORT          ux_network_device_link_status;

    ULONG           ux_network_physical_address_msw;
    ULONG           ux_network_physical_address_lsw;


} USB_NETWORK_DEVICE_TYPE;


UINT  _ux_network_driver_init(VOID);

UINT  _ux_network_driver_activate(VOID *ux_instance, UINT(*ux_network_device_write_function)(VOID *, NX_PACKET *),
                                VOID **ux_network_handle, ULONG physical_address_msw, ULONG physical_address_lsw);

UINT  _ux_network_driver_deactivate(VOID *ux_instance, VOID *ux_network_handle);


VOID  _ux_network_driver_entry(NX_IP_DRIVER *nx_ip_driver);

VOID  _ux_network_driver_link_up(VOID *ux_network_handle);
VOID  _ux_network_driver_link_down(VOID *ux_network_handle);

VOID  _ux_network_driver_packet_received(VOID *ux_network_handle, NX_PACKET *packet_ptr);
/* Determine if a C++ compiler is being used.  If so, complete the standard
   C conditional started above.  */
#ifdef __cplusplus
}
#endif

#endif