|
|
1.1 root 1: /* netboot
2: *
3: * proto.h,v
4: * Revision 1.1 1993/07/08 16:04:10 brezak
5: * Diskless boot prom code from Jim McKim ([email protected])
6: *
7: * Revision 1.4 1993/06/30 20:14:15 mckim
8: * Added BOOTP support.
9: *
10: * Revision 1.3 1993/06/08 14:22:38 mckim
11: * Fast in line assembly bcopy(), bzero().
12: *
13: * Revision 1.2 1993/05/28 20:01:28 mckim
14: * Fixed various StartProg() problems.
15: *
16: * Revision 1.1.1.1 1993/05/28 11:41:08 mckim
17: * Initial version.
18: *
19: *
20: * TBD - need for common typedefs - rethink?
21: * TBD - move config include into the source files - this is just expedient
22: */
23:
24: #include "config.h"
25: #include "nbtypes.h"
26:
27: #define TRUE 1
28: #define FALSE 0
29: #define MDUMP 100 /* TBD - remove */
30: #define MAX_FILE_NAME_LEN 128
31: #define CRTBASE ((char *)0xb8000)
32: #define CHECKPOINT(x) (CRTBASE[0] = x)
33: #define nelt(x) (sizeof(x)/sizeof((x)[0]))
34:
35: void ENTER(char *); /* remove TBD */
36: int IsKbdCharReady(void);
37: u_char GetKbdChar(void);
38: void HandleKbdAttn(void);
39: void KbdWait(int n);
40:
41: int bcmp(const void *, const void *, int);
42: void volatile exit(int);
43: void volatile ExitToBios(void);
44: void gateA20(void);
45: int getc(void);
46: int getchar(void);
47: u_short GetMemSize(u_short);
48: int gets(char *);
49: int ischar(void);
50: void longjmp(jmp_buf env, int val);
51: void printf( /* const char *, ... */ );
52: void putc(int);
53: void putchar(int);
54: int rand(void);
55: void ResetCpu(void);
56: int setjmp(jmp_buf env);
57: void srand(u_int);
58: void StartProg(u_long phyaddr, u_long *args);
59: int strlen(const char *);
60: char *strncat(char *, const char *, int len);
61: char *strncpy(char *, const char *, int len);
62: int strcmp(const char *, const char *);
63: u_long timer(void);
64:
65: /* macros in pio.h, rewritten as in-line functions */
66: /* TBD - define addr arg as long - short might result in extra
67: bit masking whereas longs simply get plonked down in %edx */
68: #undef inb
69: #undef outb
70: #undef inw
71: #undef outw
72: #undef inl
73: #undef outl
74:
75: static inline u_char
76: inb(u_short addr) {
77: u_char datum;
78: asm volatile("inb %1, %0" : "=a" (datum) : "d" (addr));
79: return datum;
80: }
81:
82: static inline void
83: outb(u_short addr, u_char datum) {
84: asm volatile("outb %0, %1" : : "a" (datum), "d" (addr));
85: }
86:
87: static inline u_short
88: inw(u_short addr) {
89: u_short datum;
90: asm volatile(".byte 0x66; inl %1, %0" : "=a" (datum) : "d" (addr));
91: return datum;
92: }
93:
94: static inline void
95: outw(u_short addr, u_short datum) {
96: asm volatile(".byte 0x66; outw %0, %1" : : "a" (datum), "d" (addr));
97: }
98:
99: static inline u_long
100: inl(u_short addr) {
101: u_long datum;
102: asm volatile("inw %1, %0" : "=a" (datum) : "d" (addr));
103: return datum;
104: }
105:
106: static inline void
107: outl(u_short addr, u_long datum) {
108: asm volatile("outw %0, %1" : : "a" (datum), "d" (addr));
109: }
110:
111: #if __GCC__ >= 2
112: /* fast versions of bcopy(), bzero() */
113: static inline void
114: bcopy(const void *from, void *to, int len) {
115: /* assumes %es == %ds */
116: asm("
117: mov %0, %%esi
118: mov %1, %%edi
119: mov %2, %%ecx
120: cld
121: rep
122: movsb
123: " : : "g" (from), "g" (to), "g" (len) : "esi", "edi", "ecx");
124: }
125:
126: static inline void
127: bzero(void *dest, int len) {
128: /* assumes %es == %ds */
129: asm("
130: mov %0, %%edi
131: mov %1, %%ecx
132: xor %%eax, %%eax
133: cld
134: rep
135: stosb
136: " : : "g" (dest), "g" (len) : "edi", "ecx", "eax");
137: }
138: #else
139:
140: static inline void
141: bcopy(char *from, char *to, int len)
142: {
143: while (len-- > 0)
144: *to++ = *from++;
145: }
146:
147: static inline void
148: bzero(char *to, int len)
149: {
150: while (len-- > 0)
151: *to++ = '\0';
152: }
153:
154: #endif
155:
156: static inline void PhysBcopy(u_long src, u_long dest, u_long nbytes) {
157: bcopy((void *)src, (void *)dest, nbytes);
158: }
159:
160: static inline void PhysBzero(u_long dest, u_long nbytes) {
161: bzero((void *)dest, nbytes);
162: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.