CSTATUS EnableInterrupts(int nHandle) { CARRIERDATA_STRUCT* pCarrier; PCI_BOARD_MEMORY_MAP* pPCICard; word nValue; pCarrier = GetCarrier(nHandle); if(pCarrier == 0) return E_INVALID_HANDLE; if(pCarrier->bInitialized == FALSE) return E_NOT_INITIALIZED; pPCICard = (PCI_BOARD_MEMORY_MAP*)pCarrier->lBaseAddress; nValue = input_word(nHandle,(word*)&pPCICard->controlReg); nValue |= APC_INT_PENDING_CLEAR; /* Clear any pending interrupts */ output_word(nHandle,(word*)&pPCICard->controlReg, nValue ); nValue |= APC_INT_ENABLE; /* Enable interrupts */ output_word(nHandle,(word*)&pPCICard->controlReg, nValue ); pCarrier->bIntEnabled = TRUE; /* Interrupts are Enabled */ return (CSTATUS)S_OK; }
CSTATUS SetIPClockControl(int nHandle, char chSlot, word uControl) { CARRIERDATA_STRUCT* pCarrier; PCI_BOARD_MEMORY_MAP* pPCICard; word nValue; pCarrier = GetCarrier(nHandle); if(pCarrier == 0) return E_INVALID_HANDLE; if(pCarrier->bInitialized == FALSE) return E_NOT_INITIALIZED; /* check carrier ID to see if 32MHZ IP clocking is supported */ if( pCarrier->uCarrierID & CARRIER_CLK ) /* nonzero can support 32MHZ IP clock */ { pPCICard = (PCI_BOARD_MEMORY_MAP*)pCarrier->lBaseAddress; nValue = input_word(nHandle, (word*)&pPCICard->IPClockControl); switch(chSlot) { case SLOT_A: nValue &= 0x00FE; /* default force bit 0 = 0 = 8MHZ IP clock */ if( uControl ) /* does caller want 32MHZ? */ nValue |= 1; /* make slot A IP clock 32MHZ */ break; case SLOT_B: nValue &= 0x00FD; /* default force bit 1 = 0 = 8MHZ IP clock */ if( uControl ) /* does caller want 32MHZ? */ nValue |= 2; /* make slot B IP clock 32MHZ */ break; case SLOT_C: nValue &= 0x00FB; /* default force bit 2 = 0 = 8MHZ IP clock */ if( uControl ) /* does caller want 32MHZ? */ nValue |= 4; /* make slot C IP clock 32MHZ */ break; case SLOT_D: nValue &= 0x00F7; /* default force bit 3 = 0 = 8MHZ IP clock */ if( uControl ) /* does caller want 32MHZ? */ nValue |= 8; /* make slot D IP clock 32MHZ */ break; case SLOT_E: nValue &= 0x00EF; /* default force bit 4 = 0 = 8MHZ IP clock */ if( uControl ) /* does caller want 32MHZ? */ nValue |= 0x10; /* make slot E IP clock 32MHZ */ break; default: return E_INVALID_SLOT; break; } output_word(nHandle, (word*)&pPCICard->IPClockControl, nValue ); /* write value */ return (CSTATUS)S_OK; } return (CSTATUS)E_NOT_IMPLEMENTED; }
CSTATUS CarrierInitialize(int nHandle) { CARRIERDATA_STRUCT* pCarrier; PCI_BOARD_MEMORY_MAP* pPCICard; word nValue; pCarrier = GetCarrier(nHandle); if(pCarrier == 0) return E_INVALID_HANDLE; /* determine the carrier type and initialize */ pPCICard = (PCI_BOARD_MEMORY_MAP*)pCarrier->lBaseAddress; /* now reset the carrier */ output_word(nHandle, (word*)&pPCICard->controlReg, SOFTWARE_RESET ); /* following a software reset 8620a type products will return either */ /* 0xAyyy or 0xByyyy values in the MS nibble of the control register (yyy = dont care)*/ /* original 8620 carriers will return 0x0yyy in the MS nibble of the control register */ /* 0x0yyy = original 8620 board - no extended features */ /* 0xAyyy = 8620a board with 32MHZ IP clock without extra memory space */ /* 0xByyy = 8620a board with 32MHZ IP clock and extra memory space */ nValue = input_word( nHandle,(word*)&pPCICard->controlReg); /* read again */ /* pCarrier->uCarrierID value is saved in the carrier structure for later use */ /* see include file apc8620.h for carrier attributes */ pCarrier->uCarrierID = PCI_CARRIER; /* attributes PCI */ /* test the result */ if((nValue & 0xF000) == 0xA000) pCarrier->uCarrierID |= CARRIER_CLK; if((nValue & 0xF000) == 0xB000) { pCarrier->uCarrierID |= CARRIER_CLK; pCarrier->uCarrierID |= CARRIER_MEM; } pCarrier->bInitialized = TRUE; /* Carrier is now initialized */ return (CSTATUS)S_OK; }
CSTATUS DisableInterrupts(int nHandle) { CARRIERDATA_STRUCT* pCarrier; PCI_BOARD_MEMORY_MAP* pPCICard; word nValue; pCarrier = GetCarrier(nHandle); if(pCarrier == 0) return E_INVALID_HANDLE; if(pCarrier->bInitialized == FALSE) return E_NOT_INITIALIZED; pPCICard = (PCI_BOARD_MEMORY_MAP*)pCarrier->lBaseAddress; nValue = input_word(nHandle,(word*)&pPCICard->controlReg); nValue &= ~APC_INT_ENABLE; /* Disable interrupts */ output_word(nHandle,(word*)&pPCICard->controlReg, nValue ); pCarrier->bIntEnabled = FALSE; return (CSTATUS)S_OK; }
/* Process a stream. This is where the real work happens, * except that centering is handled separately. */ static void process_stream(FILE *stream, const char *name) { size_t last_indent=SILLY; /* how many spaces in last indent? */ size_t para_line_number=0; /* how many lines already read in this para? */ size_t first_indent=SILLY; /* indentation of line 0 of paragraph */ HdrType prev_header_type=hdr_ParagraphStart; /* ^-- header_type of previous line; -1 at para start */ wchar_t *line; size_t length; if (centerP) { center_stream(stream, name); return; } while ((line=get_line(stream,&length)) != NULL) { size_t np=indent_length(line, length); { HdrType header_type=hdr_NonHeader; if (grok_mail_headers && prev_header_type!=hdr_NonHeader) { if (np==0 && might_be_header(line)) header_type = hdr_Header; else if (np>0 && prev_header_type>hdr_NonHeader) header_type = hdr_Continuation; } /* We need a new paragraph if and only if: * this line is blank, * OR it's a troff request (and we don't format troff), * OR it's a mail header, * OR it's not a mail header AND the last line was one, * OR the indentation has changed * AND the line isn't a mail header continuation line * AND this isn't the second line of an indented paragraph. */ if ( length==0 || (line[0]=='.' && !format_troff) || header_type==hdr_Header || (header_type==hdr_NonHeader && prev_header_type>hdr_NonHeader) || (np!=last_indent && header_type != hdr_Continuation && (!allow_indented_paragraphs || para_line_number != 1)) ) { new_paragraph(output_in_paragraph ? last_indent : first_indent, np); para_line_number = 0; first_indent = np; last_indent = np; if (header_type==hdr_Header) last_indent=2; /* for cont. lines */ if (length==0 || (line[0]=='.' && !format_troff)) { if (length==0) putwchar('\n'); else wprintf(L"%.*ls\n", (int)length, line); prev_header_type=hdr_ParagraphStart; continue; } } else { /* If this is an indented paragraph other than a mail header * continuation, set |last_indent|. */ if (np != last_indent && header_type != hdr_Continuation) last_indent=np; } prev_header_type = header_type; } { size_t n=np; while (n<length) { /* Find word end and count spaces after it */ size_t word_length=0, space_length=0; while (n+word_length < length && line[n+word_length] != ' ') ++word_length; space_length = word_length; while (n+space_length < length && line[n+space_length] == ' ') ++space_length; /* Send the word to the output machinery. */ output_word(first_indent, last_indent, line+n, word_length, space_length-word_length); n += space_length; } } ++para_line_number; } new_paragraph(output_in_paragraph ? last_indent : first_indent, 0); if (ferror(stream)) { warn("%s", name); ++n_errors; } }
static int generate_output(match_ctx ctx, search_nodep snp, struct sfx_decruncher *decr, encode_match_f * f, encode_match_data emd, int load, int len, int start, unsigned char *buf) { int pos; int pos_diff; int max_diff; int diff; static output_ctx out; output_ctxp old; output_ctx_init(out); old = emd->out; emd->out = out; pos = output_get_pos(out); pos_diff = pos; max_diff = 0; output_gamma_code(out, 16); output_bits(out, 1, 0); /* 1 bit out */ diff = output_get_pos(out) - pos_diff; if(diff > max_diff) { max_diff = diff; } while (snp != NULL) { const_matchp mp; mp = snp->match; if (mp != NULL && mp->len > 0) { if (mp->offset == 0) { /* literal */ output_byte(out, ctx->buf[snp->index]); output_bits(out, 1, 1); } else { f(mp, emd); output_bits(out, 1, 0); } pos_diff += mp->len; diff = output_get_pos(out) - pos_diff; if(diff > max_diff) { max_diff = diff; } } snp = snp->prev; } /* output header here */ optimal_out(out, emd); output_bits_flush(out); output_word(out, (unsigned short int) (load + len)); len = output_get_pos(out); decr->load(out, (unsigned short int) load - max_diff); output_copy_bytes(out, 0, len); /* second stage of decruncher */ decr->stages(out, (unsigned short int) start); /*len = output_ctx_close(out, of);*/ len = out->pos - out->start; memcpy(buf, out->buf + out->start, len); emd->out = old; return len; }