/*
* rtl8139.c
*
* This file contains a ethernet device driver for Realtek rtl8139 based
* ethernet cards.
*
* The valid messages and their parameters are:
*
* m_type DL_PORT DL_PROC DL_COUNT DL_MODE DL_ADDR
* |------------+----------+---------+----------+---------+---------|
* | HARD_INT | | | | | |
* |------------|----------|---------|----------|---------|---------|
* | SYS_SIG | | | | | |
* |------------|----------|---------|----------|---------|---------|
* | DL_WRITE | port nr | proc nr | count | mode | address |
* |------------|----------|---------|----------|---------|---------|
* | DL_WRITEV | port nr | proc nr | count | mode | address |
* |------------|----------|---------|----------|---------|---------|
* | DL_READ | port nr | proc nr | count | | address |
* |------------|----------|---------|----------|---------|---------|
* | DL_READV | port nr | proc nr | count | | address |
* |------------|----------|---------|----------|---------|---------|
* | DL_INIT | port nr | proc nr | mode | | address |
* |------------|----------|---------|----------|---------|---------|
* | DL_GETSTAT | port nr | proc nr | | | address |
* |------------|----------|---------|----------|---------|---------|
* | DL_GETNAME | | | | | |
* |------------|----------|---------|----------|---------|---------|
* | DL_STOP | port_nr | | | | |
* |------------|----------|---------|----------|---------|---------|
*
* The messages sent are:
*
* m-type DL_POR T DL_PROC DL_COUNT DL_STAT DL_CLCK
* |------------|----------|---------|----------|---------|---------|
* |DL_TASK_REPL| port nr | proc nr | rd-count | err|stat| clock |
* |------------|----------|---------|----------|---------|---------|
*
* m_type m3_i1 m3_i2 m3_ca1
* |------------+---------+-----------+---------------|
* |DL_INIT_REPL| port nr | last port | ethernet addr |
* |------------|---------|-----------|---------------|
*
* Created: Aug 2003 by Philip Homburg <philip@cs.vu.nl>
* Changes:
* Aug 15, 2004 sync alarms replace watchdogs timers (Jorrit N. Herder)
* May 02, 2004 flag alarms replace micro_elapsed() (Jorrit N. Herder)
*
*/
#include "../drivers.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stddef.h>
#include <minix/com.h>
#include <minix/keymap.h>
#include <minix/syslib.h>
#include <minix/type.h>
#include <minix/sysutil.h>
#include <timers.h>
#include <ibm/portio.h>
#include <net/hton.h>
#include <net/gen/ether.h>
#include <net/gen/eth_io.h>
#include <sys/types.h>
#include <fcntl.h>
#include <assert.h>
#include <unistd.h>
#include <sys/ioc_memory.h>
#include "../../kernel/const.h"
#include "../../kernel/config.h"
#include "../../kernel/type.h"
#define tmra_ut timer_t
#define tmra_inittimer(tp) tmr_inittimer(tp)
#define Proc_number(p) proc_number(p)
#define debug 0
#define printW() ((void)0)
#define vm_1phys2bus(p) (p)
#define VERBOSE 0 /* display message during init */
#include "../libpci/pci.h"
#include "rtl8139.h"
#define RX_BUFSIZE RL_RCR_RBLEN_64K_SIZE
#define RX_BUFBITS RL_RCR_RBLEN_64K
#define N_TX_BUF RL_N_TX
#define RE_PORT_NR 1 /* Minix */
/* I/O vectors are handled IOVEC_NR entries at a time. */
#define IOVEC_NR 16
/* Configuration */
#define RL_ENVVAR "RTLETH"
PRIVATE struct pcitab
{
u16_t vid;
u16_t did;
int checkclass;
} pcitab[]=
{
{ 0x10ec, 0x8139, 0 }, /* Realtek RTL8139 */
{ 0x1186, 0x1300, 0 }, /* D-Link RTL8139 */
{ 0x0000, 0x0000, 0 }
};
typedef struct re
{
port_t re_base_port;
int re_irq;
int re_mode;
int re_flags;
int re_client;
int re_link_up;
int re_got_int;
int re_send_int;
int re_report_link;
int re_clear_rx;
int re_need_reset;
int re_tx_alive;
char *re_model;
/* Rx */
phys_bytes re_rx_buf;
char *v_re_rx_buf;
vir_bytes re_read_s;
/* Tx */
int re_tx_head;
int re_tx_tail;
struct
{
int ret_busy;
phys_bytes ret_buf;
char * v_ret_buf;
} re_tx[N_TX_BUF];
u32_t re_ertxth; /* Early Tx Threshold */
/* PCI related */
int re_seen; /* TRUE iff device available */
u8_t re_pcibus;
u8_t re_pcidev;
u8_t re_pcifunc;
/* 'large' items */
int re_hook_id; /* IRQ hook id at kernel */
eth_stat_t re_stat;
ether_addr_t re_address;
message re_rx_mess;
message re_tx_mess;
char re_name[sizeof("rtl8139#n")];
iovec_t re_iovec[IOVEC_NR];
}
re_t;
#define REM_DISABLED 0x0
#define REM_ENABLED 0x1
#define REF_PACK_SENT 0x001
#define REF_PACK_RECV 0x002
#define REF_SEND_AVAIL 0x004
#define REF_READING 0x010
#define REF_EMPTY 0x000
#define REF_PROMISC 0x040
#define REF_MULTI 0x080
#define REF_BROAD 0x100
#define REF_ENABLED 0x200
static re_t re_table[RE_PORT_NR];
static u16_t eth_ign_proto;
static tmra_ut rl_watchdog;
FORWARD _PROTOTYPE( unsigned my_inb, (U16_t port) );
FORWARD _PROTOTYPE( unsigned my_inw, (U16_t port) );
FORWARD _PROTOTYPE( unsigned my_inl, (U16_t port) );
static unsigned my_inb(U16_t port) {
U8_t value;
int s;
if ((s=sys_inb(port, &value)) !=OK)
printf("RTL8139: warning, sys_inb failed: %d\n", s);
return value;
}
static unsigned my_inw(U16_t port) {
U16_t value;
int s;
if ((s=sys_inw(port, &value)) !=OK)
printf("RTL8139: warning, sys_inw failed: %d\n", s);
return value;
}
static unsigned my_inl(U16_t port) {
U32_t value;
int s;
if ((s=sys_inl(port, &value)) !=OK)
printf("RTL8139: warning, sys_inl failed: %d\n", s);
return value;
}
#define rl_inb(port, offset) (my_inb((port) + (offset)))
#define rl_inw(port, offset) (my_inw((port) + (offset)))
#define rl_inl(port, offset) (my_inl((port) + (offset)))
FORWARD _PROTOTYPE( void my_outb, (U16_t port, U8_t value) );
FORWARD _PROTOTYPE( void my_outw, (U16_t port, U16_t value) );
FORWARD _PROTOTYPE( void my_outl, (U16_t port, U32_t value) );
static void my_outb(U16_t port, U8_t value) {
int s;
if ((s=sys_outb(port, value)) !=OK)
printf("RTL8139: warning, sys_outb failed: %d\n", s);
}
static void my_outw(U16_t port, U16_t value) {
int s;
if ((s=sys_outw(port, value)) !=OK)
printf("RTL8139: warning, sys_outw failed: %d\n", s);
}
static void my_outl(U16_t port, U32_t value) {
int s;
if ((s=sys_outl(port, value)) !=OK)
printf("RTL8139: warning, sys_outl failed: %d\n", s);
}
#define rl_outb(port, offset, value) (my_outb((port) + (offset), (value)))
#define rl_outw(port, offset, value) (my_outw((port) + (offset), (value)))
#define rl_outl(port, offset, value) (my_outl((port) + (offset), (value)))
_PROTOTYPE( static void rl_init, (message *mp) );
_PROTOTYPE( static void rl_pci_conf, (void) );
_PROTOTYPE( static int rl_probe, (re_t *rep) );
_PROTOTYPE( static void rl_conf_hw, (re_t *rep) );
_PROTOTYPE( static void rl_init_buf, (re_t *rep) );
_PROTOTYPE( static void rl_init_hw, (re_t *rep) );
_PROTOTYPE( static void rl_reset_hw, (re_t *rep) );
_PROTOTYPE( static void rl_confaddr, (re_t *rep) );
_PROTOTYPE( static void rl_rec_mode, (re_t *rep) );
_PROTOTYPE( static void rl_readv, (message *mp, int from_int,
int vectored) );
_PROTOTYPE( static void rl_writev, (message *mp, int from_int,
int vectored) );
_PROTOTYPE( static void rl_check_ints, (re_t *rep) );
_PROTOTYPE( static void rl_report_link, (re_t *rep) );
_PROTOTYPE( static void mii_print_techab, (U16_t techab) );
_PROTOTYPE( static void mii_print_stat_speed, (U16_t stat,
U16_t extstat) );
_PROTOTYPE( static void rl_clear_rx, (re_t *rep) );
_PROTOTYPE( static void rl_do_reset, (re_t *rep) );
_PROTOTYPE( static void rl_getstat, (message *mp) );
_PROTOTYPE( static void rl_getname, (message *mp) );
_PROTOTYPE( static void reply, (re_t *rep, int err, int may_block) );
_PROTOTYPE( static void mess_reply, (message *req, message *reply) );
_PROTOTYPE( static void put_userdata, (int user_proc,
vir_
没有合适的资源?快使用搜索试试~ 我知道了~
minix_source_3_1_1.rar_minix
共497个文件
h:257个
c:174个
makefile:34个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 198 浏览量
2022-09-24
16:02:46
上传
评论
收藏 934KB RAR 举报
温馨提示
minix 操作系统源代码。对操作系统感兴趣的人有很大的参考价值
资源推荐
资源详情
资源评论
收起资源包目录
minix_source_3_1_1.rar_minix (497个子文件)
rtl8139.c 65KB
tcp.c 60KB
fxp.c 60KB
tty.c 60KB
at_wini.c 54KB
lance.c 51KB
dp8390.c 51KB
floppy.c 47KB
boot.c 43KB
udp.c 36KB
console.c 36KB
tcp_send.c 33KB
tcp_recv.c 32KB
sha2.c 32KB
sha2.c 32KB
pci.c 31KB
rs232.c 30KB
arp.c 29KB
icmp.c 28KB
ipr.c 27KB
proc.c 26KB
buf.c 25KB
eth.c 24KB
sr.c 24KB
ip_read.c 24KB
exec.c 22KB
signal.c 22KB
keyboard.c 22KB
installboot.c 21KB
8390.c 21KB
select.c 19KB
sb16_dsp.c 19KB
read.c 19KB
dp.c 18KB
mnx_eth.c 18KB
bootimage.c 18KB
psip.c 18KB
system.c 18KB
dmp_kernel.c 17KB
3c509.c 17KB
ip_eth.c 17KB
device.c 16KB
ip_ioctl.c 16KB
pty.c 16KB
manager.c 16KB
rijndael_api.c 16KB
open.c 15KB
bios_wini.c 15KB
main.c 15KB
alloc.c 15KB
main.c 15KB
printer.c 15KB
link.c 15KB
cache.c 15KB
misc.c 14KB
tcp_lib.c 14KB
log.c 14KB
rijndael_alg.c 14KB
inode.c 13KB
pipe.c 13KB
path.c 12KB
protect.c 12KB
driver.c 12KB
ip_write.c 12KB
memory.c 11KB
3c501.c 11KB
forkexit.c 11KB
pci_table.c 11KB
clock.c 11KB
init.c 11KB
misc.c 11KB
super.c 11KB
sb16_mixer.c 10KB
ip.c 10KB
main.c 10KB
wdeth.c 10KB
wd.c 9KB
dmap.c 9KB
rawfs.c 9KB
service.c 8KB
write.c 8KB
inet_config.c 8KB
cmos.c 8KB
main.c 8KB
rtl8029.c 8KB
inet.c 7KB
stadir.c 7KB
ne2000.c 7KB
utility.c 7KB
rescue.c 7KB
main.c 7KB
break.c 7KB
protect.c 7KB
i8259.c 6KB
mount.c 6KB
drvlib.c 6KB
3c503.c 6KB
ip_ps.c 6KB
table.c 6KB
lock.c 6KB
共 497 条
- 1
- 2
- 3
- 4
- 5
资源评论
JonSco
- 粉丝: 66
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功