📄 drvfbi.c
字号:
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}#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 * for the inp() and outp() macros. * * slot - The number of the slot for which the card id is returned. * Out * Returns the card id read from the specified slot. If an illegal slot * number is specified, the function returns zero. * ************************/static int read_card_id(struct s_smc *smc, int slot)/* struct s_smc *smc ; Do not use. */{ int card_id ; SK_UNUSED(smc) ; /* Make LINT happy. */ if ((slot < 1) || (slot > 15)) /* max 16 slots, 0 = motherboard */ return (0) ; /* Illegal slot number specified. */ EnableSlotAccess(smc, slot) ; card_id = ((read_POS(smc,POS_ID_HIGH,slot - 1) & 0xff) << 8) | (read_POS(smc,POS_ID_LOW,slot - 1) & 0xff) ; DisableSlotAccess(smc) ; return (card_id) ;}/************************ * * BEGIN_MANUAL_ENTRY() * * get_board_para * * Get adapter configuration information. Fill all board specific * parameters within the 'smc' structure. * * int get_board_para( * struct s_smc *smc, * int slot) ; * In * smc - A pointer to the SMT Context struct, to which this function will * write some adapter configuration data. * * slot - The number of the slot, in which the adapter is installed. * Out * 0 = No adapter present. * 1 = Ok. * 2 = Adapter present, but card enable bit not set. * * END_MANUAL_ENTRY() * ************************/int get_board_para(struct s_smc *smc, int slot){ int val ; int i ; /* Check if adapter present & get type of adapter. */ switch (exist_board(smc, slot)) { case 0: /* Adapter not present. */ return (0) ; case 1: /* FM Rev. 1 */ smc->hw.rev = FM1_REV ; smc->hw.VFullRead = 0x0a ; smc->hw.VFullWrite = 0x05 ; smc->hw.DmaWriteExtraBytes = 8 ; /* 2 extra words. */ break ; } smc->hw.slot = slot ; EnableSlotAccess(smc, slot) ; if (!(read_POS(smc,POS_102, slot - 1) & POS_CARD_EN)) { DisableSlotAccess(smc) ; return (2) ; /* Card enable bit not set. */ } val = read_POS(smc,POS_104, slot - 1) ; /* I/O, IRQ */#ifndef MEM_MAPPED_IO /* is defined by the operating system */ i = val & POS_IOSEL ; /* I/O base addr. (0x0200 .. 0xfe00) */ smc->hw.iop = (i + 1) * 0x0400 - 0x200 ;#endif i = ((val & POS_IRQSEL) >> 6) & 0x03 ; /* IRQ <0, 1> */ smc->hw.irq = opt_ints[i] ; /* FPROM base addr. */ i = ((read_POS(smc,POS_103, slot - 1) & POS_MSEL) >> 4) & 0x07 ; smc->hw.eprom = opt_eproms[i] ; DisableSlotAccess(smc) ; /* before this, the smc->hw.iop must be set !!! */ smc->hw.slot_32 = inpw(CSF_A) & SLOT_32 ; return (1) ;}/* Enable access to specified MCA slot. */static void EnableSlotAccess(struct s_smc *smc, int slot){ SK_UNUSED(slot) ;#ifndef AIX SK_UNUSED(smc) ; /* System mode. */ outp(POS_SYS_SETUP, POS_SYSTEM) ; /* Select slot. */ outp(POS_CHANNEL_POS, POS_CHANNEL_BIT | (slot-1)) ;#else attach_POS_addr (smc) ;#endif}/* Disable access to MCA slot formerly enabled via EnableSlotAccess(). */static void DisableSlotAccess(struct s_smc *smc){#ifndef AIX SK_UNUSED(smc) ; outp(POS_CHANNEL_POS, 0) ;#else detach_POS_addr (smc) ;#endif}#endif /* MCA */#ifdef EISA#ifndef MEM_MAPPED_IO#define SADDR(slot) (((slot)<<12)&0xf000)#else /* MEM_MAPPED_IO */#define SADDR(slot) (smc->hw.iop)#endif /* MEM_MAPPED_IO *//************************ * * BEGIN_MANUAL_ENTRY() * * exist_board * * Check if an EISA 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 adapter. * * Pseudo * Read EISA ID * for all valid OEM_IDs * compare with ID read * if equal, return 1 * return(0 * * Note * The smc pointer must be valid now. * ************************/int exist_board(struct s_smc *smc, int slot){ int i ;#ifdef MULT_OEM SK_LOC_DECL(u_char,id[4]) ;#endif /* MULT_OEM */ /* No longer valid. */ if (smc == NULL) return(0); SK_UNUSED(slot) ;#ifndef MULT_OEM for (i = 0 ; i < 4 ; i++) { if (inp(SADDR(slot)+PRA(i)) != OEMID(smc,i)) return(0) ; } return(1) ;#else /* MULT_OEM */ for (i = 0 ; i < 4 ; i++) id[i] = inp(SADDR(slot)+PRA(i)) ; 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),4)) return (1) ; } return (0) ; /* No adapter found. */#endif /* MULT_OEM */}int get_board_para(struct s_smc *smc, int slot){ int i ; if (!exist_board(smc,slot)) return(0) ; smc->hw.slot = slot ;#ifndef MEM_MAPPED_IO /* if defined by the operating system */ smc->hw.iop = SADDR(slot) ;#endif if (!(inp(C0_A(0))&CFG_CARD_EN)) { return(2) ; /* CFG_CARD_EN bit not set! */ } smc->hw.irq = opt_ints[(inp(C1_A(0)) & CFG_IRQ_SEL)] ; smc->hw.dma = opt_dmas[((inp(C1_A(0)) & CFG_DRQ_SEL)>>3)] ; if ((i = inp(C2_A(0)) & CFG_EPROM_SEL) != 0x0f) smc->hw.eprom = opt_eproms[i] ; else smc->hw.eprom = 0 ; smc->hw.DmaWriteExtraBytes = 8 ; return(1) ;}#endif /* EISA */#ifdef ISA#ifndef MULT_OEMconst u_char sklogo[6] = SKLOGO_STR ;#define SIZE_SKLOGO(smc) sizeof(sklogo)#define SKLOGO(smc,i) sklogo[i]#else /* MULT_OEM */#define SIZE_SKLOGO(smc) smc->hw.oem_id->oi_logo_len#define SKLOGO(smc,i) smc->hw.oem_id->oi_logo[i]#endif /* MULT_OEM */int exist_board(struct s_smc *smc, HW_PTR port){ int i ;#ifdef MULT_OEM int bytes_read ; u_char board_logo[15] ; SK_LOC_DECL(u_char,id[4]) ;#endif /* MULT_OEM */ /* No longer valid. */ if (smc == NULL) return(0); SK_UNUSED(smc) ;#ifndef MULT_OEM for (i = SADDRL ; i < (signed) (SADDRL+SIZE_SKLOGO(smc)) ; i++) { if ((u_char)inpw((PRA(i)+port)) != SKLOGO(smc,i-SADDRL)) { return(0) ; } } /* check MAC address (S&K or other) */ for (i = 0 ; i < 3 ; i++) { if ((u_char)inpw((PRA(i)+port)) != OEMID(smc,i)) return(0) ; } return(1) ;#else /* MULT_OEM */ smc->hw.oem_id = (struct s_oem_ids *) &oem_ids[0] ; board_logo[0] = (u_char)inpw((PRA(SADDRL)+port)) ; bytes_read = 1 ; 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 ; /* Test all read bytes with current OEM_entry */ /* for (i=0; (i<bytes_read) && (i < SIZE_SKLOGO(smc)); i++) { */ for (i = 0; i < bytes_read; i++) { if (board_logo[i] != SKLOGO(smc,i)) break ; } /* If mismatch, switch to next OEM entry */ if ((board_logo[i] != SKLOGO(smc,i)) && (i < bytes_read)) continue ; --i ; while (bytes_read < SIZE_SKLOGO(smc)) { // inpw next byte SK_Logo i++ ; board_logo[i] = (u_char)inpw((PRA(SADDRL+i)+port)) ; bytes_read++ ; if (board_logo[i] != SKLOGO(smc,i)) break ; } for (i = 0 ; i < 3 ; i++) id[i] = (u_char)inpw((PRA(i)+port)) ; if ((board_logo[i] == SKLOGO(smc,i)) && (bytes_read == SIZE_SKLOGO(smc))) { if (is_equal_num(&id[0],&OEMID(smc,0),3)) return(1); } } /* for */ return(0) ;#endif /* MULT_OEM */}int get_board_para(struct s_smc *smc, int slot){ SK_UNUSED(smc) ; SK_UNUSED(slot) ; return(0) ; /* for ISA not supported */}#endif /* ISA */#ifdef PCI#ifdef USE_BIOS_FUNint exist_board(struct s_smc *smc, int slot){ u_short dev_id ; u_short ven_id ; int found ; int i ; found = FALSE ; /* make sure we returned with adatper not found*/ /* if an empty oemids.h was included */#ifdef MULT_OEM 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 ;#endif ven_id = OEMID(smc,0) + (OEMID(smc,1) << 8) ; dev_id = OEMID(smc,2) + (OEMID(smc,3) << 8) ; for (i = 0; i < slot; i++) { if (pci_find_device(i,&smc->hw.pci_handle, dev_id,ven_id) != 0) { found = FALSE ; } else { found = TRUE ; } } if (found) { return(1) ; /* adapter was found */ }#ifdef MULT_OEM }#endif return(0) ; /* adapter was not found */}#endif /* PCI */#endif /* USE_BIOS_FUNC */void driver_get_bia(struct s_smc *smc, struct fddi_addr *bia_addr){ int i ; extern const u_char canonical[256] ; for (i = 0 ; i < 6 ; i++) { bia_addr->a[i] = canonical[smc->hw.fddi_phys_addr.a[i]] ; }}void smt_start_watchdog(struct s_smc *smc){ SK_UNUSED(smc) ; /* Make LINT happy. */#ifndef DEBUG#ifdef PCI if (smc->hw.wdog_used) { outpw(ADDR(B2_WDOG_CRTL),TIM_START) ; /* Start timer. */ }#endif#endif /* DEBUG */}static void smt_stop_watchdog(struct s_smc *smc){ SK_UNUSED(smc) ; /* Make LINT happy. */#ifndef DEBUG#ifdef PCI if (smc->hw.wdog_used) { outpw(ADDR(B2_WDOG_CRTL),TIM_STOP) ; /* Stop timer. */ }#endif#endif /* DEBUG */}#ifdef PCIvoid mac_do_pci_fix(struct s_smc *smc){ SK_UNUSED(smc) ;}#endif /* PCI */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -