📄 server.c
字号:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dos.h>
#include <conio.h>
#include <graph.h>
#include <time.h>
#include "common.h"
#define RTL_CR 0x37
#define RTL_9346CR 0x50
#define CFCS 0x04
#define CFLT 0x0c
#define CBIO 0x10
#define SUCCESSFUL 0x00
#define S_DEVICE_ID 0x0009 // DEC 21140
#define S_VENDOR_ID 0x1011 // DEC
#define S_DEVICE_ID1 0x0019 // DEC 21143
#define S_VENDOR_ID1 0x1011 // DEC
#define S_DEVICE_ID2 0x1229 // Intel 8255X
#define S_VENDOR_ID2 0x8086 // Intel
#define IO_ADDRESS 0x10
#define IO_ADDRESS1 0x14
unsigned int DEVICE_ID[] = {S_DEVICE_ID, S_DEVICE_ID1, S_DEVICE_ID2,};
unsigned int VENDOR_ID[] = {S_VENDOR_ID, S_VENDOR_ID1, S_VENDOR_ID2,};
unsigned char *strings[] ={"DEC-21140", "DEC-21143", "Intel-82559"};
#define FIND_NO 3
int init_card1(void);
extern char error_code;
extern unsigned char s_slot;
extern unsigned int s_io_base;
char s_bus_num,s_dev_fun_num;
unsigned char s_Hard_Int;
int init_card1(void)
{
int i;
char tmp,str[80];
unsigned int s_device_id,s_vendor_id, index;
_setbkcolor(BLUE);
for(i=0; i<FIND_NO; i++)
{
s_device_id=DEVICE_ID[i];
s_vendor_id=VENDOR_ID[i];
_asm mov ah,PCI_FUNCTION_ID // get BUS number, DEVICE number
_asm mov al,FIND_PCI_DEVICE
_asm mov cx,s_device_id
_asm mov dx,s_vendor_id
_asm mov si,0x0
_asm int PCI_BIOS_INT
_asm mov error_code,ah
_asm mov s_bus_num,bh
_asm mov s_dev_fun_num,bl
if(error_code == SUCCESSFUL)
{
strcpy(str, strings[i]);
break;
}
}
if(error_code !=0)
{
print_msg(RED,"Server Card Not found !!");
error_code=0x11;
return -1;
}
_settextwindow(1,1,25,80);
_settextcolor(RED);
_settextposition(6,57);
_outtext(str);
if(i==2)
index = 0x14;
else
index = 0x10;
_asm mov ah,PCI_FUNCTION_ID // get IO BASE
_asm mov al,READ_CONFIG_WORD
_asm mov bh,s_bus_num
_asm mov bl,s_dev_fun_num
_asm mov di,index
_asm int PCI_BIOS_INT
_asm mov error_code,ah
_asm and cl,11111110b
_asm mov s_io_base,cx
_settextcolor(WHITE);
_settextposition(6,74); // print SLOT
s_slot=(unsigned char)s_dev_fun_num>>3;
sprintf(str,"%02d",s_slot);
_outtext(str);
_settextposition(9,57);
sprintf(str,"%04Xh",s_io_base); // print IO BASE
_outtext(str);
_settextposition(7,57);
sprintf(str,"%04Xh",s_device_id); // print DEVICE ID
_outtext(str);
_settextposition(7,74);
sprintf(str,"%04Xh",s_vendor_id); // print VENDER ID
_outtext(str);
// ======================= enable bus master =========
_asm mov ah,PCI_FUNCTION_ID
_asm mov al,READ_CONFIG_BYTE
_asm mov bh,s_bus_num
_asm mov bl,s_dev_fun_num
_asm mov di,0x04
_asm int PCI_BIOS_INT
_asm or cl,0x04
_asm mov ah,PCI_FUNCTION_ID
_asm mov al,WRITE_CONFIG_BYTE
_asm mov di,0x04
_asm int PCI_BIOS_INT
// ===================================================
_asm mov dx,s_io_base
_asm add dx,RTL_CR
_asm mov al,00010000b
_asm out dx,al
_asm mov dx,s_io_base
_asm add dx,RTL_9346CR
_asm in al,dx
_asm and al,11111101b
_asm or al,00000001b
_asm out dx,al
_asm mov ah,PCI_FUNCTION_ID // get Hard_Int
_asm mov al,READ_CONFIG_BYTE
_asm mov di,0x3c
_asm int PCI_BIOS_INT
_asm mov s_Hard_Int,cl
_settextposition(9,74);
sprintf(str,"%02Xh",s_Hard_Int);
_outtext(str);
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -