-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnetusbee.h
105 lines (88 loc) · 2.44 KB
/
netusbee.h
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
/*
* NetUSBee USB driver for TOS
*
* netusbee.h: miscellaneous header for netusbee.prg
*
* Copyright (C) 2018 Roger Burrows
*
* The delay_loop() function is derived from EmuTOS:
* asm.h - Assembler help routines
*
* Copyright (C) 2013-2017 The EmuTOS development team
*
* This file is distributed under the GPL, version 2 or at your
* option any later version. See doc/license.txt for details.
*/
/*
* quasi-standard C stuff
*/
#ifndef NULL
# define NULL ((void *)0L)
#endif
#define FALSE (0)
#define TRUE (!0)
#define UNUSED(x) (void)x
typedef unsigned long ulong;
/*
* TOS stuff
*/
#define E_OK 0L
#define ENOSYS -32L
#define _p_cookie 0x5a0L
#define CPU_COOKIE 0x5f435055L /* '_CPU' */
#define USB_COOKIE 0x5f555342L /* '_USB' */
/*
* delay stuff
*/
/*
* Loops for the specified count; for a 1 millisecond delay on the
* current system, use the value in the global 'loopcount_1_msec'.
*/
#define delay_loop(count) \
__extension__ \
({ulong _count = (count); \
__asm__ volatile \
("0:\n\t" \
"subq.l #1,%0\n\t" \
"jpl 0b" \
: /* outputs */ \
: "d"(_count) /* inputs */ \
: "cc", "memory" /* clobbered */ \
); \
})
static inline void mdelay(ulong millisecs)
{
while(millisecs--)
delay_loop(loopcount_1_msec);
}
extern ulong delay_1us;
static inline void udelay(ulong microsecs)
{
while(microsecs--)
delay_loop(delay_1us);
}
/*
* The following is used as a sub-microsecond delay on "slow" machines:
* on a 68000, it takes 4 cycles, which is 250ns on a 16MHz machine,
* 500ns on an 8MHz machine.
*/
#define nop \
__extension__ \
({ \
__asm__ volatile \
( \
"nop" \
: /* outputs */ \
: /* inputs */ \
: /* clobbered */ \
); \
})
/*
* MiNT-related stuff
*/
#define FS_INFO 0xf100
#define c_conws(x) (void)Cconws(x)
static inline unsigned short SWAP16(unsigned short value)
{
return (value<<8) | (value>>8);
}