00001 #ifndef PCI_H
00002 #define PCI_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #define PCI_COMMAND_IO 0x1
00025 #define PCI_COMMAND_MEM 0x2
00026 #define PCI_COMMAND_MASTER 0x4
00027 #define PCI_LATENCY_TIMER 0x0d
00028
00029 #define PCIBIOS_PCI_FUNCTION_ID 0xb1XX
00030 #define PCIBIOS_PCI_BIOS_PRESENT 0xb101
00031 #define PCIBIOS_FIND_PCI_DEVICE 0xb102
00032 #define PCIBIOS_FIND_PCI_CLASS_CODE 0xb103
00033 #define PCIBIOS_GENERATE_SPECIAL_CYCLE 0xb106
00034 #define PCIBIOS_READ_CONFIG_BYTE 0xb108
00035 #define PCIBIOS_READ_CONFIG_WORD 0xb109
00036 #define PCIBIOS_READ_CONFIG_DWORD 0xb10a
00037 #define PCIBIOS_WRITE_CONFIG_BYTE 0xb10b
00038 #define PCIBIOS_WRITE_CONFIG_WORD 0xb10c
00039 #define PCIBIOS_WRITE_CONFIG_DWORD 0xb10d
00040
00041 #define PCI_VENDOR_ID 0x00
00042 #define PCI_DEVICE_ID 0x02
00043 #define PCI_COMMAND 0x04
00044
00045 #define PCI_REVISION 0x08
00046 #define PCI_CLASS_CODE 0x0b
00047 #define PCI_SUBCLASS_CODE 0x0a
00048 #define PCI_HEADER_TYPE 0x0e
00049
00050 #define PCI_BASE_ADDRESS_0 0x10
00051 #define PCI_BASE_ADDRESS_1 0x14
00052 #define PCI_BASE_ADDRESS_2 0x18
00053 #define PCI_BASE_ADDRESS_3 0x1c
00054 #define PCI_BASE_ADDRESS_4 0x20
00055 #define PCI_BASE_ADDRESS_5 0x24
00056
00057 #ifndef PCI_BASE_ADDRESS_IO_MASK
00058 #define PCI_BASE_ADDRESS_IO_MASK (~0x03)
00059 #endif
00060 #define PCI_BASE_ADDRESS_SPACE_IO 0x01
00061 #define PCI_ROM_ADDRESS 0x30
00062 #define PCI_ROM_ADDRESS_ENABLE 0x01
00063
00064
00065
00066 #define PCI_FUNC(devfn) ((devfn) & 0x07)
00067
00068 #define BIOS32_SIGNATURE (('_' << 0) + ('3' << 8) + ('2' << 16) + ('_' << 24))
00069
00070
00071 #define PCI_SIGNATURE (('P' << 0) + ('C' << 8) + ('I' << 16) + (' ' << 24))
00072
00073
00074 #define PCI_SERVICE (('$' << 0) + ('P' << 8) + ('C' << 16) + ('I' << 24))
00075
00076 union bios32 {
00077 struct {
00078 unsigned long signature;
00079 unsigned long entry;
00080 unsigned char revision;
00081 unsigned char length;
00082 unsigned char checksum;
00083 unsigned char reserved[5];
00084 } fields;
00085 char chars[16];
00086 };
00087
00088 #define KERN_CODE_SEG 0x8
00089
00090
00091 #define save_flags(x) \
00092 __asm__ __volatile__("pushfl ; popl %0":"=g" (x): :"memory")
00093
00094 #define cli() __asm__ __volatile__ ("cli": : :"memory")
00095
00096 #define restore_flags(x) \
00097 __asm__ __volatile__("pushl %0 ; popfl": :"g" (x):"memory")
00098
00099 #define PCI_VENDOR_ID_ADMTEK 0x1317
00100 #define PCI_DEVICE_ID_ADMTEK_0985 0x0985
00101 #define PCI_VENDOR_ID_REALTEK 0x10ec
00102 #define PCI_DEVICE_ID_REALTEK_8029 0x8029
00103 #define PCI_DEVICE_ID_REALTEK_8139 0x8139
00104 #define PCI_VENDOR_ID_WINBOND2 0x1050
00105 #define PCI_DEVICE_ID_WINBOND2_89C940 0x0940
00106 #define PCI_DEVICE_ID_WINBOND2_89C840 0x0840
00107 #define PCI_VENDOR_ID_COMPEX 0x11f6
00108 #define PCI_DEVICE_ID_COMPEX_RL2000 0x1401
00109 #define PCI_DEVICE_ID_COMPEX_RL100ATX 0x2011
00110 #define PCI_VENDOR_ID_KTI 0x8e2e
00111 #define PCI_DEVICE_ID_KTI_ET32P2 0x3000
00112 #define PCI_VENDOR_ID_NETVIN 0x4a14
00113 #define PCI_DEVICE_ID_NETVIN_NV5000SC 0x5000
00114 #define PCI_VENDOR_ID_HOLTEK 0x12c3
00115 #define PCI_DEVICE_ID_HOLTEK_HT80232 0x0058
00116 #define PCI_VENDOR_ID_3COM 0x10b7
00117 #define PCI_DEVICE_ID_3COM_3C590 0x5900
00118 #define PCI_DEVICE_ID_3COM_3C595 0x5950
00119 #define PCI_DEVICE_ID_3COM_3C595_1 0x5951
00120 #define PCI_DEVICE_ID_3COM_3C595_2 0x5952
00121 #define PCI_DEVICE_ID_3COM_3C900TPO 0x9000
00122 #define PCI_DEVICE_ID_3COM_3C900COMBO 0x9001
00123 #define PCI_DEVICE_ID_3COM_3C905TX 0x9050
00124 #define PCI_DEVICE_ID_3COM_3C905T4 0x9051
00125 #define PCI_DEVICE_ID_3COM_3C905B_TX 0x9055
00126 #define PCI_DEVICE_ID_3COM_3C905C_TXM 0x9200
00127 #define PCI_VENDOR_ID_INTEL 0x8086
00128 #define PCI_DEVICE_ID_INTEL_82557 0x1229
00129 #define PCI_DEVICE_ID_INTEL_82559ER 0x1209
00130 #define PCI_DEVICE_ID_INTEL_ID1029 0x1029
00131 #define PCI_DEVICE_ID_INTEL_ID1030 0x1030
00132 #define PCI_DEVICE_ID_INTEL_82562 0x2449
00133 #define PCI_VENDOR_ID_AMD 0x1022
00134 #define PCI_DEVICE_ID_AMD_LANCE 0x2000
00135 #define PCI_VENDOR_ID_AMD_HOMEPNA 0x1022
00136 #define PCI_DEVICE_ID_AMD_HOMEPNA 0x2001
00137 #define PCI_VENDOR_ID_SMC_1211 0x1113
00138 #define PCI_DEVICE_ID_SMC_1211 0x1211
00139 #define PCI_VENDOR_ID_DEC 0x1011
00140 #define PCI_DEVICE_ID_DEC_TULIP 0x0002
00141 #define PCI_DEVICE_ID_DEC_TULIP_FAST 0x0009
00142 #define PCI_DEVICE_ID_DEC_TULIP_PLUS 0x0014
00143 #define PCI_DEVICE_ID_DEC_21142 0x0019
00144 #define PCI_VENDOR_ID_SMC 0x10B8
00145 #ifndef PCI_DEVICE_ID_SMC_EPIC100
00146 # define PCI_DEVICE_ID_SMC_EPIC100 0x0005
00147 #endif
00148 #define PCI_VENDOR_ID_MACRONIX 0x10d9
00149 #define PCI_DEVICE_ID_MX987x5 0x0531
00150 #define PCI_VENDOR_ID_LINKSYS 0x11AD
00151 #define PCI_DEVICE_ID_LC82C115 0xC115
00152 #define PCI_VENDOR_ID_VIATEC 0x1106
00153 #define PCI_DEVICE_ID_VIA_RHINE_I 0x3043
00154 #define PCI_DEVICE_ID_VIA_VT6102 0x3065
00155 #define PCI_DEVICE_ID_VIA_86C100A 0x6100
00156 #define PCI_VENDOR_ID_DAVICOM 0x1282
00157 #define PCI_DEVICE_ID_DM9009 0x9009
00158 #define PCI_DEVICE_ID_DM9102 0x9102
00159 #define PCI_VENDOR_ID_SIS 0x1039
00160 #define PCI_DEVICE_ID_SIS900 0x0900
00161 #define PCI_DEVICE_ID_SIS7016 0x7016
00162 #define PCI_VENDOR_ID_DLINK 0x1186
00163 #define PCI_DEVICE_ID_DFE530TXP 0x1300
00164 #define PCI_VENDOR_ID_NS 0x100B
00165 #define PCI_DEVICE_ID_DP83815 0x0020
00166 #define PCI_VENDOR_ID_OLICOM 0x108d
00167 #define PCI_DEVICE_ID_OLICOM_OC3136 0x0001
00168 #define PCI_DEVICE_ID_OLICOM_OC2315 0x0011
00169 #define PCI_DEVICE_ID_OLICOM_OC2325 0x0012
00170 #define PCI_DEVICE_ID_OLICOM_OC2183 0x0013
00171 #define PCI_DEVICE_ID_OLICOM_OC2326 0x0014
00172 #define PCI_DEVICE_ID_OLICOM_OC6151 0x0021
00173
00174 struct pci_device {
00175 unsigned short vendor, dev_id;
00176 const char *name;
00177 unsigned int membase;
00178 unsigned short ioaddr;
00179 unsigned char devfn;
00180 unsigned char bus;
00181 };
00182
00183 extern void eth_pci_init(struct pci_device *);
00184
00185 extern int pcibios_read_config_byte(unsigned int bus, unsigned int device_fn, unsigned int where, unsigned char *value);
00186 extern int pcibios_write_config_byte (unsigned int bus, unsigned int device_fn, unsigned int where, unsigned char value);
00187 extern int pcibios_read_config_word(unsigned int bus, unsigned int device_fn, unsigned int where, unsigned short *value);
00188 extern int pcibios_write_config_word (unsigned int bus, unsigned int device_fn, unsigned int where, unsigned short value);
00189 extern int pcibios_read_config_dword(unsigned int bus, unsigned int device_fn, unsigned int where, unsigned int *value);
00190 extern int pcibios_write_config_dword(unsigned int bus, unsigned int device_fn, unsigned int where, unsigned int value);
00191 void adjust_pci_device(struct pci_device *p);
00192 #endif
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226 #include <shared.h>
00227
00228
00229
00230
00231 #undef NO_DHCP_SUPPORT
00232
00233
00234
00235 #define RELOC 0
00236
00237
00238 #define BACKOFF_LIMIT 7
00239
00240 #include <osdep.h>
00241
00242 #define CTRL_C 3
00243
00244 #ifndef MAX_TFTP_RETRIES
00245 # define MAX_TFTP_RETRIES 20
00246 #endif
00247
00248 #ifndef MAX_BOOTP_RETRIES
00249 # define MAX_BOOTP_RETRIES 20
00250 #endif
00251
00252 #define MAX_BOOTP_EXTLEN (ETH_FRAME_LEN - ETH_HLEN - \
00253 sizeof (struct bootp_t))
00254
00255 #ifndef MAX_ARP_RETRIES
00256 # define MAX_ARP_RETRIES 20
00257 #endif
00258
00259 #ifndef MAX_RPC_RETRIES
00260 # define MAX_RPC_RETRIES 20
00261 #endif
00262
00263 #define TICKS_PER_SEC 18
00264
00265
00266 #define TIMEOUT (10 * TICKS_PER_SEC)
00267
00268
00269
00270 #define TFTP_TIMEOUT (30 * TICKS_PER_SEC)
00271
00272 #define TFTP_REXMT (3 * TICKS_PER_SEC)
00273
00274 #ifndef NULL
00275 # define NULL ((void *) 0)
00276 #endif
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287 #define ETH_ALEN 6
00288 #define ETH_HLEN 14
00289 #define ETH_ZLEN 60
00290
00291 #define ETH_FRAME_LEN 1514
00292
00293
00294
00295
00296 #define ETH_MAX_MTU (ETH_FRAME_LEN - ETH_HLEN \
00297 - sizeof (struct iphdr) \
00298 - sizeof (struct udphdr))
00299
00300 #define ARP_CLIENT 0
00301 #define ARP_SERVER 1
00302 #define ARP_GATEWAY 2
00303 #define ARP_ROOTSERVER 3
00304 #define ARP_SWAPSERVER 4
00305 #define MAX_ARP ARP_SWAPSERVER+1
00306
00307 #define RARP_REQUEST 3
00308 #define RARP_REPLY 4
00309
00310 #define IP 0x0800
00311 #define ARP 0x0806
00312 #define RARP 0x8035
00313
00314 #define BOOTP_SERVER 67
00315 #define BOOTP_CLIENT 68
00316 #define TFTP_PORT 69
00317 #define SUNRPC_PORT 111
00318
00319 #define IP_UDP 17
00320
00321 #define IP_BROADCAST 0xFFFFFFFF
00322
00323 #define ARP_REQUEST 1
00324 #define ARP_REPLY 2
00325
00326 #define BOOTP_REQUEST 1
00327 #define BOOTP_REPLY 2
00328
00329 #define TAG_LEN(p) (*((p) + 1))
00330 #define RFC1533_COOKIE 99, 130, 83, 99
00331 #define RFC1533_PAD 0
00332 #define RFC1533_NETMASK 1
00333 #define RFC1533_TIMEOFFSET 2
00334 #define RFC1533_GATEWAY 3
00335 #define RFC1533_TIMESERVER 4
00336 #define RFC1533_IEN116NS 5
00337 #define RFC1533_DNS 6
00338 #define RFC1533_LOGSERVER 7
00339 #define RFC1533_COOKIESERVER 8
00340 #define RFC1533_LPRSERVER 9
00341 #define RFC1533_IMPRESSSERVER 10
00342 #define RFC1533_RESOURCESERVER 11
00343 #define RFC1533_HOSTNAME 12
00344 #define RFC1533_BOOTFILESIZE 13
00345 #define RFC1533_MERITDUMPFILE 14
00346 #define RFC1533_DOMAINNAME 15
00347 #define RFC1533_SWAPSERVER 16
00348 #define RFC1533_ROOTPATH 17
00349 #define RFC1533_EXTENSIONPATH 18
00350 #define RFC1533_IPFORWARDING 19
00351 #define RFC1533_IPSOURCEROUTING 20
00352 #define RFC1533_IPPOLICYFILTER 21
00353 #define RFC1533_IPMAXREASSEMBLY 22
00354 #define RFC1533_IPTTL 23
00355 #define RFC1533_IPMTU 24
00356 #define RFC1533_IPMTUPLATEAU 25
00357 #define RFC1533_INTMTU 26
00358 #define RFC1533_INTLOCALSUBNETS 27
00359 #define RFC1533_INTBROADCAST 28
00360 #define RFC1533_INTICMPDISCOVER 29
00361 #define RFC1533_INTICMPRESPOND 30
00362 #define RFC1533_INTROUTEDISCOVER 31
00363 #define RFC1533_INTROUTESOLICIT 32
00364 #define RFC1533_INTSTATICROUTES 33
00365 #define RFC1533_LLTRAILERENCAP 34
00366 #define RFC1533_LLARPCACHETMO 35
00367 #define RFC1533_LLETHERNETENCAP 36
00368 #define RFC1533_TCPTTL 37
00369 #define RFC1533_TCPKEEPALIVETMO 38
00370 #define RFC1533_TCPKEEPALIVEGB 39
00371 #define RFC1533_NISDOMAIN 40
00372 #define RFC1533_NISSERVER 41
00373 #define RFC1533_NTPSERVER 42
00374 #define RFC1533_VENDOR 43
00375 #define RFC1533_NBNS 44
00376 #define RFC1533_NBDD 45
00377 #define RFC1533_NBNT 46
00378 #define RFC1533_NBSCOPE 47
00379 #define RFC1533_XFS 48
00380 #define RFC1533_XDM 49
00381 #ifndef NO_DHCP_SUPPORT
00382 #define RFC2132_REQ_ADDR 50
00383 #define RFC2132_MSG_TYPE 53
00384 #define RFC2132_SRV_ID 54
00385 #define RFC2132_PARAM_LIST 55
00386 #define RFC2132_MAX_SIZE 57
00387 #define RFC2132_VENDOR_CLASS_ID 60
00388
00389 #define DHCPDISCOVER 1
00390 #define DHCPOFFER 2
00391 #define DHCPREQUEST 3
00392 #define DHCPACK 5
00393 #endif
00394
00395 #define RFC1533_VENDOR_MAJOR 0
00396 #define RFC1533_VENDOR_MINOR 0
00397
00398 #define RFC1533_VENDOR_MAGIC 128
00399 #define RFC1533_VENDOR_ADDPARM 129
00400 #define RFC1533_VENDOR_MNUOPTS 160
00401 #define RFC1533_VENDOR_SELECTION 176
00402 #define RFC1533_VENDOR_MOTD 184
00403 #define RFC1533_VENDOR_NUMOFMOTD 8
00404 #define RFC1533_VENDOR_IMG 192
00405 #define RFC1533_VENDOR_NUMOFIMG 16
00406
00407 #define RFC1533_VENDOR_CONFIGFILE 150
00408
00409 #define RFC1533_END 255
00410
00411 #define BOOTP_VENDOR_LEN 64
00412 #ifndef NO_DHCP_SUPPORT
00413 #define DHCP_OPT_LEN 312
00414 #endif
00415
00416 #define TFTP_DEFAULTSIZE_PACKET 512
00417 #define TFTP_MAX_PACKET 1432
00418
00419 #define TFTP_RRQ 1
00420 #define TFTP_WRQ 2
00421 #define TFTP_DATA 3
00422 #define TFTP_ACK 4
00423 #define TFTP_ERROR 5
00424 #define TFTP_OACK 6
00425
00426 #define TFTP_CODE_EOF 1
00427 #define TFTP_CODE_MORE 2
00428 #define TFTP_CODE_ERROR 3
00429 #define TFTP_CODE_BOOT 4
00430 #define TFTP_CODE_CFG 5
00431
00432 #define AWAIT_ARP 0
00433 #define AWAIT_BOOTP 1
00434 #define AWAIT_TFTP 2
00435 #define AWAIT_RARP 3
00436 #define AWAIT_RPC 4
00437 #define AWAIT_QDRAIN 5
00438
00439 typedef struct
00440 {
00441 unsigned long s_addr;
00442 }
00443 in_addr;
00444
00445 struct arptable_t
00446 {
00447 in_addr ipaddr;
00448 unsigned char node[6];
00449 };
00450
00451
00452
00453
00454
00455 struct arprequest
00456 {
00457 unsigned short hwtype;
00458 unsigned short protocol;
00459 char hwlen;
00460 char protolen;
00461 unsigned short opcode;
00462 char shwaddr[6];
00463 char sipaddr[4];
00464 char thwaddr[6];
00465 char tipaddr[4];
00466 };
00467
00468 struct iphdr
00469 {
00470 char verhdrlen;
00471 char service;
00472 unsigned short len;
00473 unsigned short ident;
00474 unsigned short frags;
00475 char ttl;
00476 char protocol;
00477 unsigned short chksum;
00478 in_addr src;
00479 in_addr dest;
00480 };
00481
00482 struct udphdr
00483 {
00484 unsigned short src;
00485 unsigned short dest;
00486 unsigned short len;
00487 unsigned short chksum;
00488 };
00489
00490
00491 struct bootp_t
00492 {
00493 char bp_op;
00494 char bp_htype;
00495 char bp_hlen;
00496 char bp_hops;
00497 unsigned long bp_xid;
00498 unsigned short bp_secs;
00499 unsigned short unused;
00500 in_addr bp_ciaddr;
00501 in_addr bp_yiaddr;
00502 in_addr bp_siaddr;
00503 in_addr bp_giaddr;
00504 char bp_hwaddr[16];
00505 char bp_sname[64];
00506 char bp_file[128];
00507 #ifdef NO_DHCP_SUPPORT
00508 char bp_vend[BOOTP_VENDOR_LEN];
00509 #else
00510 char bp_vend[DHCP_OPT_LEN];
00511 #endif
00512 };
00513
00514
00515 struct bootpip_t
00516 {
00517 struct iphdr ip;
00518 struct udphdr udp;
00519 struct bootp_t bp;
00520 };
00521
00522
00523 struct bootpd_t
00524 {
00525 struct bootp_t bootp_reply;
00526 unsigned char bootp_extension[MAX_BOOTP_EXTLEN];
00527 };
00528
00529 struct tftp_t
00530 {
00531 struct iphdr ip;
00532 struct udphdr udp;
00533 unsigned short opcode;
00534 union
00535 {
00536 char rrq[TFTP_DEFAULTSIZE_PACKET];
00537
00538 struct
00539 {
00540 unsigned short block;
00541 char download[TFTP_MAX_PACKET];
00542 }
00543 data;
00544
00545 struct
00546 {
00547 unsigned short block;
00548 }
00549 ack;
00550
00551 struct
00552 {
00553 unsigned short errcode;
00554 char errmsg[TFTP_DEFAULTSIZE_PACKET];
00555 }
00556 err;
00557
00558 struct
00559 {
00560 char data[TFTP_DEFAULTSIZE_PACKET+2];
00561 }
00562 oack;
00563 }
00564 u;
00565 };
00566
00567
00568
00569 struct tftpreq_t
00570 {
00571 struct iphdr ip;
00572 struct udphdr udp;
00573 unsigned short opcode;
00574 union
00575 {
00576 char rrq[512];
00577
00578 struct
00579 {
00580 unsigned short block;
00581 }
00582 ack;
00583
00584 struct
00585 {
00586 unsigned short errcode;
00587 char errmsg[512-2];
00588 }
00589 err;
00590 }
00591 u;
00592 };
00593
00594 #define TFTP_MIN_PACKET (sizeof(struct iphdr) + sizeof(struct udphdr) + 4)
00595
00596 struct rpc_t
00597 {
00598 struct iphdr ip;
00599 struct udphdr udp;
00600 union
00601 {
00602 char data[300];
00603
00604 struct
00605 {
00606 long id;
00607 long type;
00608 long rpcvers;
00609 long prog;
00610 long vers;
00611 long proc;
00612 long data[1];
00613 }
00614 call;
00615
00616 struct
00617 {
00618 long id;
00619 long type;
00620 long rstatus;
00621 long verifier;
00622 long v2;
00623 long astatus;
00624 long data[1];
00625 }
00626 reply;
00627 }
00628 u;
00629 };
00630
00631 #define PROG_PORTMAP 100000
00632 #define PROG_NFS 100003
00633 #define PROG_MOUNT 100005
00634
00635 #define MSG_CALL 0
00636 #define MSG_REPLY 1
00637
00638 #define PORTMAP_GETPORT 3
00639
00640 #define MOUNT_ADDENTRY 1
00641 #define MOUNT_UMOUNTALL 4
00642
00643 #define NFS_LOOKUP 4
00644 #define NFS_READ 6
00645
00646 #define NFS_FHSIZE 32
00647
00648 #define NFSERR_PERM 1
00649 #define NFSERR_NOENT 2
00650 #define NFSERR_ACCES 13
00651
00652
00653
00654
00655 #define NFS_READ_SIZE 1024
00656
00657 #define FLOPPY_BOOT_LOCATION 0x7c00
00658
00659 #define ROM_SEGMENT 0x1fa
00660 #define ROM_LENGTH 0x1fc
00661
00662 #define ROM_INFO_LOCATION (FLOPPY_BOOT_LOCATION + ROM_SEGMENT)
00663
00664
00665 struct rom_info
00666 {
00667 unsigned short rom_segment;
00668 unsigned short rom_length;
00669 };
00670
00671 static inline int
00672 rom_address_ok (struct rom_info *rom, int assigned_rom_segment)
00673 {
00674 return (assigned_rom_segment < 0xC000
00675 || assigned_rom_segment == rom->rom_segment);
00676 }
00677
00678
00679 struct ebinfo
00680 {
00681 unsigned char major, minor;
00682 unsigned short flags;
00683 };
00684
00685
00686
00687
00688
00689 extern void print_network_configuration (void);
00690 extern int ifconfig (char *ip, char *sm, char *gw, char *svr);
00691 extern int udp_transmit (unsigned long destip, unsigned int srcsock,
00692 unsigned int destsock, int len, const void *buf);
00693 extern int await_reply (int type, int ival, void *ptr, int timeout);
00694 extern int decode_rfc1533 (unsigned char *, int, int, int);
00695 extern long rfc2131_sleep_interval (int base, int exp);
00696 extern void cleanup (void);
00697 extern int rarp (void);
00698 extern int bootp (void);
00699 extern void cleanup_net (void);
00700
00701
00702 extern void print_config (void);
00703 extern void eth_reset (void);
00704 extern int eth_probe (void);
00705 extern int eth_poll (void);
00706 extern void eth_transmit (const char *d, unsigned int t,
00707 unsigned int s, const void *p);
00708 extern void eth_disable (void);
00709
00710
00711 extern void twiddle (void);
00712 extern void sleep (int secs);
00713 extern int getdec (char **s);
00714 extern void etherboot_printf (const char *, ...);
00715 extern int etherboot_sprintf (char *, const char *, ...);
00716 extern int inet_aton (char *p, in_addr *i);
00717
00718
00719
00720
00721
00722 extern int ip_abort;
00723 extern int network_ready;
00724 extern struct rom_info rom;
00725 extern struct arptable_t arptable[MAX_ARP];
00726 extern struct bootpd_t bootp_data;
00727 #define BOOTP_DATA_ADDR (&bootp_data)
00728 extern unsigned char *end_of_rfc1533;
00729
00730
00731 extern struct nic nic;
00732
00733
00734 #ifndef GRUB
00735 # undef printf
00736 # define printf etherboot_printf
00737 # undef sprintf
00738 # define sprintf etherboot_sprintf
00739 #endif
00740
00741
00742
00743
00744
00745
00746
00747 #ifndef NIC_H
00748 #define NIC_H
00749
00750
00751
00752
00753
00754
00755 struct nic
00756 {
00757 void (*reset)((struct nic *));
00758 int (*poll)P((struct nic *));
00759 void (*transmit)P((struct nic *, const char *d,
00760 unsigned int t, unsigned int s, const char *p));
00761 void (*disable)P((struct nic *));
00762 int flags;
00763 struct rom_info *rom_info;
00764 unsigned char *node_addr;
00765 char *packet;
00766 unsigned int packetlen;
00767 void *priv_data;
00768 };
00769
00770 #endif
00771 #ifndef CARDS_H
00772 #define CARDS_H
00773
00774
00775
00776
00777
00778
00779
00780
00781 #include "nic.h"
00782
00783
00784
00785
00786
00787 #ifdef PCI_H
00788 #define PCI_ARG(x) ,x
00789 #else
00790 #define PCI_ARG(x)
00791 #endif
00792
00793 #ifdef INCLUDE_WD
00794 extern struct nic *wd_probe(struct nic *, unsigned short *
00795 PCI_ARG(struct pci_device *));
00796 #endif
00797
00798 #ifdef INCLUDE_3C503
00799 extern struct nic *t503_probe(struct nic *, unsigned short *
00800 PCI_ARG(struct pci_device *));
00801 #endif
00802
00803 #ifdef INCLUDE_VIA_RHINE
00804 extern struct nic *rhine_probe(struct nic *, unsigned short *
00805 PCI_ARG(struct pci_device *));
00806 #endif
00807
00808 #ifdef INCLUDE_NE
00809 extern struct nic *ne_probe(struct nic *, unsigned short *
00810 PCI_ARG(struct pci_device *));
00811 #endif
00812
00813 #ifdef INCLUDE_NS8390
00814 extern struct nic *nepci_probe(struct nic *, unsigned short *
00815 PCI_ARG(struct pci_device *));
00816 #endif
00817
00818 #ifdef INCLUDE_3C509
00819 extern struct nic *t509_probe(struct nic *, unsigned short *
00820 PCI_ARG(struct pci_device *));
00821 #endif
00822
00823 #ifdef INCLUDE_3C529
00824 extern struct nic *t529_probe(struct nic *, unsigned short *
00825 PCI_ARG(struct pci_device *));
00826 #endif
00827
00828 #ifdef INCLUDE_3C595
00829 extern struct nic *t595_probe(struct nic *, unsigned short *
00830 PCI_ARG(struct pci_device *));
00831 #endif
00832
00833 #ifdef INCLUDE_3C90X
00834 extern struct nic *a3c90x_probe(struct nic *, unsigned short *
00835 PCI_ARG(struct pci_device *));
00836 #endif
00837
00838 #ifdef INCLUDE_EEPRO
00839 extern struct nic *eepro_probe(struct nic *, unsigned short *
00840 PCI_ARG(struct pci_device *));
00841 #endif
00842
00843 #ifdef INCLUDE_EEPRO100
00844 extern struct nic *eepro100_probe(struct nic *, unsigned short *
00845 PCI_ARG(struct pci_device *));
00846 #endif
00847
00848 #ifdef INCLUDE_EPIC100
00849 extern struct nic *epic100_probe(struct nic *, unsigned short *
00850 PCI_ARG(struct pci_device *));
00851 #endif
00852
00853 #ifdef INCLUDE_OTULIP
00854 extern struct nic *otulip_probe(struct nic *, unsigned short *
00855 PCI_ARG(struct pci_device *));
00856 #endif
00857
00858 #ifdef INCLUDE_TULIP
00859 extern struct nic *tulip_probe(struct nic *, unsigned short *
00860 PCI_ARG(struct pci_device *));
00861 #endif
00862
00863 #ifdef INCLUDE_DAVICOM
00864 extern struct nic *davicom_probe(struct nic *, unsigned short *
00865 PCI_ARG(struct pci_device *));
00866 #endif
00867
00868 #ifdef INCLUDE_CS89X0
00869 extern struct nic *cs89x0_probe(struct nic *, unsigned short *
00870 PCI_ARG(struct pci_device *));
00871 #endif
00872
00873 #ifdef INCLUDE_LANCE
00874 extern struct nic *lancepci_probe(struct nic *, unsigned short *
00875 PCI_ARG(struct pci_device *));
00876 #endif
00877
00878 #ifdef INCLUDE_NE2100
00879 extern struct nic *ne2100_probe(struct nic *, unsigned short *
00880 PCI_ARG(struct pci_device *));
00881 #endif
00882
00883 #ifdef INCLUDE_NI6510
00884 extern struct nic *ni6510_probe(struct nic *, unsigned short *
00885 PCI_ARG(struct pci_device *));
00886 #endif
00887
00888 #ifdef INCLUDE_SK_G16
00889 extern struct nic *SK_probe(struct nic *, unsigned short *
00890 PCI_ARG(struct pci_device *));
00891 #endif
00892
00893 #ifdef INCLUDE_3C507
00894 extern struct nic *t507_probe(struct nic *, unsigned short *
00895 PCI_ARG(struct pci_device *));
00896 #endif
00897
00898 #ifdef INCLUDE_NI5010
00899 extern struct nic *ni5010_probe(struct nic *, unsigned short *
00900 PCI_ARG(struct pci_device *));
00901 #endif
00902
00903 #ifdef INCLUDE_NI5210
00904 extern struct nic *ni5210_probe(struct nic *, unsigned short *
00905 PCI_ARG(struct pci_device *));
00906 #endif
00907
00908 #ifdef INCLUDE_EXOS205
00909 extern struct nic *exos205_probe(struct nic *, unsigned short *
00910 PCI_ARG(struct pci_device *));
00911 #endif
00912
00913 #ifdef INCLUDE_SMC9000
00914 extern struct nic *smc9000_probe(struct nic *, unsigned short *
00915 PCI_ARG(struct pci_device *));
00916 #endif
00917
00918 #ifdef INCLUDE_TIARA
00919 extern struct nic *tiara_probe(struct nic *, unsigned short *
00920 PCI_ARG(struct pci_device *));
00921 #endif
00922
00923 #ifdef INCLUDE_DEPCA
00924 extern struct nic *depca_probe(struct nic *, unsigned short *
00925 PCI_ARG(struct pci_device *));
00926 #endif
00927
00928 #ifdef INCLUDE_RTL8139
00929 extern struct nic *rtl8139_probe(struct nic *, unsigned short *
00930 PCI_ARG(struct pci_device *));
00931 #endif
00932
00933 #ifdef INCLUDE_W89C840
00934 extern struct nic *w89c840_probe(struct nic *, unsigned short *
00935 PCI_ARG(struct pci_device *));
00936 #endif
00937
00938 #ifdef INCLUDE_SIS900
00939 extern struct nic *sis900_probe(struct nic *, unsigned short *
00940 PCI_ARG(struct pci_device *));
00941 #endif
00942
00943 #ifdef INCLUDE_NATSEMI
00944 extern struct nic *natsemi_probe(struct nic *, unsigned short *
00945 PCI_ARG(struct pci_device *));
00946 #endif
00947
00948 #ifdef INCLUDE_TLAN
00949 extern struct nic *tlan_probe(struct nic *, unsigned short *
00950 PCI_ARG(struct pci_device *));
00951 #endif
00952
00953 #endif
00954
00955
00956
00957
00958
00959
00960
00961
00962
00963 #ifndef TIMER_H
00964 #define TIMER_H
00965
00966
00967 #define TIMER2_PORT 0x42
00968 #define TIMER_MODE_PORT 0x43
00969
00970
00971 #define TIMER0_SEL 0x00
00972 #define TIMER1_SEL 0x40
00973 #define TIMER2_SEL 0x80
00974 #define READBACK_SEL 0xC0
00975
00976 #define LATCH_COUNT 0x00
00977 #define LOBYTE_ACCESS 0x10
00978 #define HIBYTE_ACCESS 0x20
00979 #define WORD_ACCESS 0x30
00980
00981 #define MODE0 0x00
00982 #define MODE1 0x02
00983 #define MODE2 0x04
00984 #define MODE3 0x06
00985 #define MODE4 0x08
00986 #define MODE5 0x0A
00987
00988 #define BINARY_COUNT 0x00
00989 #define BCD_COUNT 0x01
00990
00991
00992 #define TICKS_PER_MS 1193
00993
00994
00995 #define PPC_PORTB 0x61
00996
00997
00998 #define PPCB_T2OUT 0x20
00999 #define PPCB_SPKR 0x02
01000 #define PPCB_T2GATE 0x01
01001
01002
01003
01004 extern void load_timer2(unsigned int ticks);
01005 extern inline int timer2_running(void)
01006 {
01007 return ((inb(PPC_PORTB) & PPCB_T2OUT) == 0);
01008 }
01009
01010 extern inline void waiton_timer2(unsigned int ticks)
01011 {
01012 load_timer2(ticks);
01013 while ((inb(PPC_PORTB) & PPCB_T2OUT) == 0)
01014 ;
01015 }
01016
01017 #endif
01018 #ifndef __OSDEP_H__
01019 #define __OSDEP_H__
01020
01021
01022
01023
01024
01025
01026
01027
01028 #define __LITTLE_ENDIAN
01029
01030
01031 #if defined(__BIG_ENDIAN)
01032 # if !defined(__constant_htonl)
01033 # define __constant_htonl(x) (x)
01034 # endif
01035 # if !defined(__constant_htons)
01036 # define __constant_htons(x) (x)
01037 # endif
01038 #elif defined(__LITTLE_ENDIAN)
01039 # if !defined(__constant_htonl)
01040 # define __constant_htonl(x) \
01041 ((unsigned long int)((((unsigned long int)(x) & 0x000000ffU) << 24) | \
01042 (((unsigned long int)(x) & 0x0000ff00U) << 8) | \
01043 (((unsigned long int)(x) & 0x00ff0000U) >> 8) | \
01044 (((unsigned long int)(x) & 0xff000000U) >> 24)))
01045 # endif
01046 # if !defined(__constant_htons)
01047 # define __constant_htons(x) \
01048 ((unsigned short int)((((unsigned short int)(x) & 0x00ff) << 8) | \
01049 (((unsigned short int)(x) & 0xff00) >> 8)))
01050 # endif
01051 #else
01052 # error "Don't know if bytes are big- or little-endian!"
01053 #endif
01054
01055 #define ntohl(x) \
01056 (__builtin_constant_p(x) ? \
01057 __constant_htonl((x)) : \
01058 __swap32(x))
01059 #define htonl(x) \
01060 (__builtin_constant_p(x) ? \
01061 __constant_htonl((x)) : \
01062 __swap32(x))
01063 #define ntohs(x) \
01064 (__builtin_constant_p(x) ? \
01065 __constant_htons((x)) : \
01066 __swap16(x))
01067 #define htons(x) \
01068 (__builtin_constant_p(x) ? \
01069 __constant_htons((x)) : \
01070 __swap16(x))
01071
01072 static inline unsigned long int __swap32(unsigned long int x)
01073 {
01074 __asm__("xchgb %b0,%h0\n\t"
01075 "rorl $16,%0\n\t"
01076 "xchgb %b0,%h0"
01077 : "=q" (x)
01078 : "0" (x));
01079 return x;
01080 }
01081
01082 static inline unsigned short int __swap16(unsigned short int x)
01083 {
01084 __asm__("xchgb %b0,%h0"
01085 : "=q" (x)
01086 : "0" (x));
01087 return x;
01088 }
01089
01090
01091 #define swap32(x) __swap32(x)
01092 #define swap16(x) __swap16(x)
01093
01094 #include "linux-asm-io.h"
01095
01096 typedef unsigned long Address;
01097
01098
01099 #ifdef __STDC__
01100 #define P(x) x
01101 #else
01102 #define P(x) ()
01103 #endif
01104
01105 #endif
01106
01107
01108
01109
01110
01111