📄 drvfbi.c
字号:
void init_board(struct s_smc *smc, u_char *mac_addr){ card_start(smc) ; read_address(smc,mac_addr) ;#ifndef PCI if (inpw(CSR_A) & CS_SAS)#else if (!(inp(ADDR(B0_DAS)) & DAS_AVAIL))#endif smc->s.sas = SMT_SAS ; /* Single att. station */ else smc->s.sas = SMT_DAS ; /* Dual att. station */#ifndef PCI if (inpw(CSR_A) & CS_BYSTAT)#else if (!(inp(ADDR(B0_DAS)) & DAS_BYP_ST))#endif smc->mib.fddiSMTBypassPresent = 0 ; /* without opt. bypass */ else smc->mib.fddiSMTBypassPresent = 1 ; /* with opt. bypass */}/* * insert or deinsert optical bypass (called by ECM) */void sm_pm_bypass_req(struct s_smc *smc, int mode){#if (defined(ISA) || defined(EISA)) int csra_v ;#endif DB_ECMN(1,"ECM : sm_pm_bypass_req(%s)\n",(mode == BP_INSERT) ? "BP_INSERT" : "BP_DEINSERT",0) ; if (smc->s.sas != SMT_DAS) return ;#if (defined(ISA) || defined(EISA)) csra_v = inpw(CSR_A) & ~CS_BYPASS ;#ifdef EISA csra_v |= smc->hw.led ;#endif switch(mode) { case BP_INSERT : outpw(CSR_A,csra_v | CS_BYPASS) ; break ; case BP_DEINSERT : outpw(CSR_A,csra_v) ; break ; }#endif /* ISA / EISA */#ifdef MCA switch(mode) { case BP_INSERT : outp(ADDR(BYPASS(STAT_INS)),0) ;/* insert station */ break ; case BP_DEINSERT : outp(ADDR(BYPASS(STAT_BYP)),0) ; /* bypass station */ break ; }#endif#ifdef PCI switch(mode) { case BP_INSERT : outp(ADDR(B0_DAS),DAS_BYP_INS) ; /* insert station */ break ; case BP_DEINSERT : outp(ADDR(B0_DAS),DAS_BYP_RMV) ; /* bypass station */ break ; }#endif}/* * check if bypass connected */int sm_pm_bypass_present(struct s_smc *smc){#ifndef PCI return( (inpw(CSR_A) & CS_BYSTAT) ? FALSE : TRUE ) ;#else return( (inp(ADDR(B0_DAS)) & DAS_BYP_ST) ? TRUE: FALSE) ;#endif}void plc_clear_irq(struct s_smc *smc, int p){ SK_UNUSED(p) ;#if (defined(ISA) || defined(EISA)) switch (p) { case PA : /* reset PLC Int. bits */ outpw(PLC2_I,inpw(PLC2_I)) ; break ; case PB : /* reset PLC Int. bits */ outpw(PLC1_I,inpw(PLC1_I)) ; break ; }#else SK_UNUSED(smc) ;#endif}/* * led_indication called by rmt_indication() and * pcm_state_change() * * Input: * smc: SMT context * led_event: * 0 Only switch green LEDs according to their respective PCM state * LED_Y_OFF just switch yellow LED off * LED_Y_ON just switch yello LED on */void led_indication(struct s_smc *smc, int led_event){ /* use smc->hw.mac_ring_is_up == TRUE * as indication for Ring Operational */ u_short led_state ; struct s_phy *phy ; struct fddi_mib_p *mib_a ; struct fddi_mib_p *mib_b ; phy = &smc->y[PA] ; mib_a = phy->mib ; phy = &smc->y[PB] ; mib_b = phy->mib ;#ifdef EISA /* Ring up = yellow led OFF*/ if (led_event == LED_Y_ON) { smc->hw.led |= CS_LED_1 ; } else if (led_event == LED_Y_OFF) { smc->hw.led &= ~CS_LED_1 ; } else { /* Link at Port A or B = green led ON */ if (mib_a->fddiPORTPCMState == PC8_ACTIVE || mib_b->fddiPORTPCMState == PC8_ACTIVE) { smc->hw.led |= CS_LED_0 ; } else { smc->hw.led &= ~CS_LED_0 ; } }#endif#ifdef MCA led_state = inpw(LEDR_A) ; /* Ring up = yellow led OFF*/ if (led_event == LED_Y_ON) { led_state |= LED_1 ; } else if (led_event == LED_Y_OFF) { led_state &= ~LED_1 ; } else { led_state &= ~(LED_2|LED_0) ; /* Link at Port A = green led A ON */ if (mib_a->fddiPORTPCMState == PC8_ACTIVE) { led_state |= LED_2 ; } /* Link at Port B/S = green led B ON */ if (mib_b->fddiPORTPCMState == PC8_ACTIVE) { led_state |= LED_0 ; } } outpw(LEDR_A, led_state) ;#endif /* MCA */#ifdef PCI led_state = 0 ; /* Ring up = yellow led OFF*/ if (led_event == LED_Y_ON) { led_state |= LED_MY_ON ; } else if (led_event == LED_Y_OFF) { led_state |= LED_MY_OFF ; } else { /* PCM state changed */ /* Link at Port A/S = green led A ON */ if (mib_a->fddiPORTPCMState == PC8_ACTIVE) { led_state |= LED_GA_ON ; } else { led_state |= LED_GA_OFF ; } /* Link at Port B = green led B ON */ if (mib_b->fddiPORTPCMState == PC8_ACTIVE) { led_state |= LED_GB_ON ; } else { led_state |= LED_GB_OFF ; } } outp(ADDR(B0_LED), led_state) ;#endif /* PCI */}void pcm_state_change(struct s_smc *smc, int plc, int p_state){ /* * the current implementation of pcm_state_change() in the driver * parts must be renamed to drv_pcm_state_change() which will be called * now after led_indication. */ DRV_PCM_STATE_CHANGE(smc,plc,p_state) ; led_indication(smc,0) ;}void rmt_indication(struct s_smc *smc, int i){ /* Call a driver special function if defined */ DRV_RMT_INDICATION(smc,i) ; led_indication(smc, i ? LED_Y_OFF : LED_Y_ON) ;}/* * llc_recover_tx called by init_tx (fplus.c) */void llc_recover_tx(struct s_smc *smc){#ifdef LOAD_GEN extern int load_gen_flag ; load_gen_flag = 0 ;#endif#ifndef SYNC smc->hw.n_a_send= 0 ;#else SK_UNUSED(smc) ;#endif}/*--------------------------- DMA init ----------------------------*/#ifdef ISA/* * init DMA */void init_dma(struct s_smc *smc, int dma){ SK_UNUSED(smc) ; /* * set cascade mode, * clear mask bit (enable DMA cannal) */ if (dma > 3) { outp(0xd6,(dma & 0x03) | 0xc0) ; outp(0xd4, dma & 0x03) ; } else { outp(0x0b,(dma & 0x03) | 0xc0) ; outp(0x0a,dma & 0x03) ; }}/* * disable DMA */void dis_dma(struct s_smc *smc, int dma){ SK_UNUSED(smc) ; /* * set mask bit (disable DMA cannal) */ if (dma > 3) { outp(0xd4,(dma & 0x03) | 0x04) ; } else { outp(0x0a,(dma & 0x03) | 0x04) ; }}#endif /* ISA */#ifdef EISA/*arrays with io addresses of dma controller length and address registers*/static const int cntr[8] = { 0x001,0x003,0x005,0x007,0,0x0c6,0x0ca,0x0ce } ;static const int base[8] = { 0x000,0x002,0x004,0x006,0,0x0c4,0x0c8,0x0cc } ;static const int page[8] = { 0x087,0x083,0x081,0x082,0,0x08b,0x089,0x08a } ;void init_dma(struct s_smc *smc, int dma){ /* * extended mode register * 32 bit IO * type c * TC output * disable stop */ /* mode read (write) demand */ smc->hw.dma_rmode = (dma & 3) | 0x08 | 0x0 ; smc->hw.dma_wmode = (dma & 3) | 0x04 | 0x0 ; /* 32 bit IO's, burst DMA mode (type "C") */ smc->hw.dma_emode = (dma & 3) | 0x08 | 0x30 ; outp((dma < 4) ? 0x40b : 0x4d6,smc->hw.dma_emode) ; /* disable chaining */ outp((dma < 4) ? 0x40a : 0x4d4,(dma&3)) ; /*load dma controller addresses for fast access during set dma*/ smc->hw.dma_base_word_count = cntr[smc->hw.dma]; smc->hw.dma_base_address = base[smc->hw.dma]; smc->hw.dma_base_address_page = page[smc->hw.dma];}void dis_dma(struct s_smc *smc, int dma){ SK_UNUSED(smc) ; outp((dma < 4) ? 0x0a : 0xd4,(dma&3)|4) ;/* mask bit */}#endif /* EISA */#ifdef MCAvoid init_dma(struct s_smc *smc, int dma){ SK_UNUSED(smc) ; SK_UNUSED(dma) ;}void dis_dma(struct s_smc *smc, int dma){ SK_UNUSED(smc) ; SK_UNUSED(dma) ;}#endif#ifdef PCIvoid init_dma(struct s_smc *smc, int dma){ SK_UNUSED(smc) ; SK_UNUSED(dma) ;}void dis_dma(struct s_smc *smc, int dma){ SK_UNUSED(smc) ; SK_UNUSED(dma) ;}#endif#ifdef MULT_OEMstatic int is_equal_num(char comp1[], char comp2[], int num){ int i ; for (i = 0 ; i < num ; i++) { if (comp1[i] != comp2[i]) return (0) ; } return (1) ;} /* is_equal_num *//* * set the OEM ID defaults, and test the contents of the OEM data base * The default OEM is the first ACTIVE entry in the OEM data base * * returns: 0 success * 1 error in data base * 2 data base empty * 3 no active entry */int set_oi_id_def(struct s_smc *smc){ int sel_id ; int i ; int act_entries ; i = 0 ; sel_id = -1 ; act_entries = FALSE ; smc->hw.oem_id = 0 ; smc->hw.oem_min_status = OI_STAT_ACTIVE ; /* check OEM data base */ while (oem_ids[i].oi_status) { switch (oem_ids[i].oi_status) { case OI_STAT_ACTIVE: act_entries = TRUE ; /* we have active IDs */ if (sel_id == -1) sel_id = i ; /* save the first active ID */ case OI_STAT_VALID: case OI_STAT_PRESENT: i++ ; break ; /* entry ok */ default: return (1) ; /* invalid oi_status */ } } if (i == 0) return (2) ; if (!act_entries) return (3) ; /* ok, we have a valid OEM data base with an active entry */ smc->hw.oem_id = (struct s_oem_ids *) &oem_ids[sel_id] ; return (0) ;}#endif /* MULT_OEM */#ifdef MCA/************************ * * BEGIN_MANUAL_ENTRY() * * exist_board * * Check if an MCA board is present in the specified slot. * * int exist_board( * struct s_smc *smc, * int slot) ; * In * smc - A pointer to the SMT Context struct. * * slot - The number of the slot to inspect. * Out * 0 = No adapter present. * 1 = Found FM1 adapter. * * Pseudo * Read MCA ID * for all valid OEM_IDs * compare with ID read * if equal, return 1 * return(0 * * Note * The smc pointer must be valid now. * * END_MANUAL_ENTRY() * ************************/#define LONG_CARD_ID(lo, hi) ((((hi) & 0xff) << 8) | ((lo) & 0xff))int exist_board(struct s_smc *smc, int slot){#ifdef MULT_OEM SK_LOC_DECL(u_char,id[2]) ; int idi ;#endif /* MULT_OEM */ /* No longer valid. */ if (smc == NULL) return(0) ;#ifndef MULT_OEM if (read_card_id(smc, slot) == LONG_CARD_ID(OEMID(smc,0), OEMID(smc,1))) return (1) ; /* Found FM adapter. */#else /* MULT_OEM */ idi = read_card_id(smc, slot) ; id[0] = idi & 0xff ; id[1] = idi >> 8 ; smc->hw.oem_id = (struct s_oem_ids *) &oem_ids[0] ; for (; smc->hw.oem_id->oi_status != OI_STAT_LAST; smc->hw.oem_id++) { if (smc->hw.oem_id->oi_status < smc->hw.oem_min_status) continue ; if (is_equal_num(&id[0],&OEMID(smc,0),2)) return (1) ; }#endif /* MULT_OEM */ return (0) ; /* No adapter found. */}/************************ * * read_card_id * * Read the MCA card id from the specified slot. * In * smc - A pointer to the SMT Context struct. * CAVEAT: This pointer may be NULL and *must not* be used within this * function. It's only purpose is for drivers that need some information
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -