USB1_Common.h
5.18 KB
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
//////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////
// USB_common.h
/////////////////////////////////////////////////////////
#include "CMemorySegment.h"
#include "MessageIO.h"
#include "VirtualComponentInterface.h"
#include "InterruptControllerInterface.h"
#include <stdio.h>
#include <stdlib.h>
//////////////////////////////////////////////////////////
// Structs
// structure for the Buffer Descriptor Table Entry
//////////////////////////////////////////////////////////
#ifndef _USB_common_
#define _USB_common_
const UnSignedLong MAX_CACHE_SIZE_IN_BYTES = 256;
#ifdef BIGEN
typedef volatile struct BufferDescriptor_Struct
{
unsigned rsrvd31_26 : 6;
unsigned bytecnt : 10;
unsigned rsrvd15_8 : 8;
unsigned own : 1; // 7: own
unsigned data0_1 : 1; // 6: data0/1
unsigned pid : 4; // 5-2: pid
unsigned rsrvd1_0 : 2;
unsigned buffer_addr : 32;
}BufferDescriptor ;
#else
typedef volatile struct BufferDescriptor_Struct
{
unsigned rsrvd1_0 : 2;
unsigned pid : 4; // 5-2: pid
unsigned data0_1 : 1; // 6: data0/1
unsigned own : 1; // 7: own
unsigned rsrvd15_8 : 8;
unsigned bytecnt : 10;
unsigned rsrvd31_26 : 6;
unsigned buffer_addr : 32;
}BufferDescriptor ;
#endif
const int g_MAX_ENDPOINTS = 4; // maximum number of endpoints
// register defines
const AddressType per_id_addr = 0x00;
const AddressType id_comp_addr = 0x04;
const AddressType rev_addr = 0x08;
const AddressType add_info_addr = 0x0C;
const AddressType otg_istat_addr = 0x10;
const AddressType otg_ictrl_addr = 0x14;
const AddressType otg_stat_addr = 0x18;
const AddressType otg_ctrl_addr = 0x1C;
const AddressType int_stat_addr = 0x80;
const AddressType int_enbl_addr = 0x84;
const AddressType err_stat_addr = 0x88;
const AddressType err_enbl_addr = 0x8C;
const AddressType usb_stat_addr = 0x90;
const AddressType usb_ctrl_addr = 0x94;
const AddressType usb_addr_addr = 0x98;
const AddressType bdt_pag0_addr = 0x9C;
const AddressType frm_numl_addr = 0xA0;
const AddressType frm_numh_addr = 0xA4;
const AddressType hst_tokn_addr = 0xA8;
const AddressType sof_thdl_addr = 0xAC;
const AddressType bdt_pag1_addr = 0xB0;
const AddressType bdt_pag2_addr = 0xB4;
const AddressType sof_thdh_addr = 0xB8;
const AddressType usb_rsrv_addr = 0xBC;
const AddressType end_ctl0_addr = 0xC0;
const AddressType end_ctl1_addr = 0xC4;
const AddressType end_ctl2_addr = 0xC8;
const AddressType end_ctl3_addr = 0xCC;
const AddressType end_ctl4_addr = 0xD0;
const AddressType end_ctl5_addr = 0xD4;
const AddressType end_ctl6_addr = 0xD8;
const AddressType end_ctl7_addr = 0xDC;
const AddressType end_ctl8_addr = 0xE0;
const AddressType end_ctl9_addr = 0xE4;
const AddressType end_ctla_addr = 0xE8;
const AddressType end_ctlb_addr = 0xEC;
const AddressType end_ctlc_addr = 0xF0;
const AddressType end_ctld_addr = 0xF4;
const AddressType end_ctle_addr = 0xF8;
const AddressType end_ctlf_addr = 0xFC;
const UnSignedLong timer0_cnt_addr = 0x21;
const UnSignedLong timer0_ctl_addr = 0x22;
const UnSignedLong timer0_lim_addr = 0x23;
const UnSignedLong host_pkt[16] = {0x00010203,0x04050607,0x08090a0b,0x0c0d0e0f,0x10111213,0x14151617,0x18191a1b,0x1c1d1e1f,0x20212223,0x24252627,0x28292a2b,0x2c2d2e2f,0x30313233,0x34353637,0x38393a3b,0x3c3d3e3f};
//UnSignedLong IntStatus_reset = 0x01;
//UnSignedLong IntStatus_sof = 0x04;
//UnSignedLong IntStatus_tokdone = 0x08;
//UnSignedLong IntStatus_attach = 0x40;
// set up the buffer descriptor table
// BDT array is [endpt][tx][odd]
typedef BufferDescriptor BufferDescriptorTableType[g_MAX_ENDPOINTS][2][2];
// ARC test code syntax:
// 3 2 2 2 2 1 1
// 1 8 7 4 3 6 5 4 3 0
//
// 0000.0000.0000.0000.0000.0000.0000.0000
// -+-- -+-- ------+-- ---------+---- -+--
// | | | | |
// | | | | +--> Error Definition
// | | | |
// | | | +---------> Part under test
// | | |
// | | +----------------------> Error Number
// | |
// | +--------------------------------> Test System
// |
// +-------------------------------------> Responsible Dept
//
// test code constants for vusb_hs test
//
// 8 ------ Vautomation (Responsible Dept.)
// 3 ----- VHDL TB (Test System)
// 5 - VUSB_1.1 (Part under Test)
#define BASE_TEST_CODE 0x83000f10 // 8 - VAuto 3 - VHDL f1 - VUSB_1.1
// Error Definitions
#define __PASSED 0x1
#define __WARNING 0x2
#define __FAILED 0x3
bool HostUsbInit(CVirtualComponentInterface *usb_initiator,
CMessageIO *message_interface,
BufferDescriptorTableType *bd_table_ptr,
CMemorySegment& host_packet_memory_segment,
CMemorySegment& host_rcv_memory_segment );
bool DevUsbInit(CVirtualComponentInterface *usb_initiator,
CMessageIO *message_interface,
BufferDescriptorTableType *bd_table_ptr);
bool SetMemoryForTable( BufferDescriptorTableType *bd_table_ptr,
CMemorySegment& setup_address1_segment,
CMemorySegment& setup_address2_segment );
#endif