Пример #1
0
/*
 * This routine is called when everything should be correctly set up
 * for the transfer (ie floppy motor is on and the correct floppy is
 * selected).
 */
static void transfer(void) {

	read_track = (command == FD_READ) && (CURRENT_ERRORS < 4) &&
	    (floppy->sect <= MAX_BUFFER_SECTORS);

	configure_fdc_mode();
	if (reset) {
		redo_fd_request();
		return;
	}

	if (!seek) {
		setup_rw_floppy();
		return;
	}

	do_floppy = seek_interrupt;
	output_byte(FD_SEEK);
	if (read_track)
		output_byte(current_drive);
	else
		output_byte((head<<2) | current_drive);

	output_byte(seek_track);
	if (reset)
		redo_fd_request();
}
Пример #2
0
/**
 * dump switch table
 */
void dumpsw(WHILE *ws) {
        int     i,j;

        data_segment_gdata ();
        generate_label (ws->body_tab);
        if (ws->case_test != swstp) {
                j = ws->case_test;
                while (j < swstp) {
                        gen_def_word ();
                        i = 4;
                        while (i--) {
                                output_number (swstcase[j]);
                                output_byte (',');
                                print_label (swstlab[j++]);
                                if ((i == 0) | (j >= swstp)) {
                                        newline ();
                                        break;
                                }
                                output_byte (',');
                        }
                }
        }
        gen_def_word ();
        print_label (ws->incr_def);
        output_string (",0");
        newline ();
        code_segment_gtext ();
}
Пример #3
0
/*
 * Must do 4 FD_SENSEIs after reset because of ``drive polling''.
 */
static void reset_interrupt(void)
{
    short i;

    for (i=0; i<4; i++) {
        output_byte(FD_SENSEI);
        (void) result();
    }
    output_byte(FD_SPECIFY);
    output_byte(cur_spec1);		/* hut etc */
    output_byte(6);			/* Head load time =6ms, DMA */
    configure_fdc_mode();		/* reprogram fdc */
    if (initial_reset_flag) {
        initial_reset_flag = 0;
        recalibrate = 1;
        reset = 0;
        return;
    }
    if (!recover)
        redo_fd_request();
    else {
        recalibrate_floppy();
        recover = 0;
    }
}
Пример #4
0
/**
 * dump switch table
 */
dumpsw(loop_t *loop) {
        int     i,j;

        data_segment_gdata ();
        generate_label (loop->body_label);
        if (loop->test_label != swstp) {
                j = loop->test_label;
                while (j < swstp) {
                        gen_def_word ();
                        i = 4;
                        while (i--) {
                                output_number (swstcase[j]);
                                output_byte (',');
                                print_label (swstlab[j++]);
                                if ((i == 0) | (j >= swstp)) {
                                        newline ();
                                        break;
                                }
                                output_byte (',');
                        }
                }
        }
        gen_def_word ();
        print_label (loop->cont_label);
        output_string (",0");
        newline ();
        code_segment_gtext ();
}
Пример #5
0
static void shake_one(void) {
	if (retry_recal(shake_one)) return;
	do_floppy = shake_done;
	output_byte(FD_SEEK);
	output_byte(head << 2 | current_drive);
	output_byte(1);
}
Пример #6
0
void hd44780_clear()
{
    output_byte(0, CMD_CLEAR_DISPLAY(), 1);

#ifdef HD44780_MULTIENSUPPORT
    output_byte(0, CMD_CLEAR_DISPLAY(), 2);
#endif
}
Пример #7
0
static int retry_recal(void (*proc)(void)) {

	output_byte(FD_SENSEI);
	if (result() == 2 && (ST0 & 0x10) != 0x10) return 0;
	do_floppy = proc;
	output_byte(FD_RECALIBRATE);
	output_byte(head<<2 | current_drive);
	return 1;
}
Пример #8
0
static void recalibrate_floppy(void) {

	recalibrate = 0;
	current_track = 0;
	do_floppy = recal_interrupt;
	output_byte(FD_RECALIBRATE);
	output_byte(head<<2 | current_drive);
	if (reset)
		redo_fd_request();
}
Пример #9
0
/*
 * This has only been tested for the case fdc_version == FDC_TYPE_STD.
 * In case you have a 82077 and want to test it, you'll have to compile
 * with `FDC_FIFO_UNTESTED' defined. You may also want to add support for
 * recognizing drives with vertical recording support.
 */
static void configure_fdc_mode(void)
{
	if (fdc_version == FDC_TYPE_82077) {
		/* Enhanced version with FIFO & vertical recording. */
		output_byte(FD_CONFIGURE);
		output_byte(0);
		output_byte(0x1A);	/* FIFO on, polling off, 10 byte treshold */
		output_byte(0);		/* precompensation from track 0 upwards */
		printk(DEVICE_NAME ": FIFO enabled\n");
	}
} /* configure_fdc_mode */
Пример #10
0
void hd44780_init(void)
{

    /* init io pins */
    CTRL_OUTPUT();
    PIN_CLEAR(HD44780_RS);
    PIN_CLEAR(HD44780_EN);
#ifdef HAVE_HD44780_RW
    PIN_CLEAR(HD44780_RW);
#endif
    PIN_CLEAR(HD44780_D4);
    PIN_CLEAR(HD44780_D5);
    PIN_CLEAR(HD44780_D6);
    PIN_CLEAR(HD44780_D7);
    DATA_OUTPUT();

    _delay_ms(40);
    PIN_SET(HD44780_D4);
    PIN_SET(HD44780_D5);
    clock_write();

    _delay_ms(4);
    clock_write();

    _delay_ms(1);
    clock_write();

    /* init done */
    _delay_ms(1);
    PIN_CLEAR(HD44780_D4);
    clock_write();
    _delay_ms(1);

    /* configure for 4 bit, 2 lines, 5x9 font (datasheet, page 24) */
    output_byte(0, CMD_FUNCTIONSET(0, 1, 0));

    /* turn on display, cursor and blinking */
    hd44780_config(0,0);

    /* clear display */
    hd44780_clear();

    /* set shift and increment */
    output_byte(0, CMD_ENTRY_MODE(1, 0));

    /* set ddram address */
    output_byte(0, CMD_SETDRAMADR(0));

    /* open file descriptor */
    lcd = fdevopen(hd44780_put, NULL);
    
    /* set current virtual postion */
    current_pos = 0;
}
Пример #11
0
void
hd44780_define_char(uint8_t n_char, uint8_t *data, uint8_t en)
{
    if (n_char > 7) return;
    /* set cgram pointer to char number n */
    output_byte(0, CMD_SETCRAMADR(n_char * 8), en);
    n_char = 0;
    while (n_char < 8) {
        /* send the data to lcd into cgram */
        output_byte(1, *(data + n_char), en);
        n_char++;
    }
}
Пример #12
0
static void floppy_on_interrupt(void)
{
	if (inb(FD_DIR) & 0x80) {
		changed_floppies |= 1<<current_drive;
		buffer_track = -1;
		if (keep_data[current_drive]) {
			if (keep_data[current_drive] > 0)
				keep_data[current_drive]--;
		}
		else {
			if (ftd_msg[current_drive] && current_type[
			    current_drive] != NULL)
				printk("Disk type is undefined after disk "
				    "change in fd%d\r\n",current_drive);
			current_type[current_drive] = NULL;
			floppy_sizes[current_drive] = MAX_DISK_SIZE;
		}
/* Forcing the drive to seek makes the "media changed" condition go away.
 * There should be a cleaner solution for that ...
 */
		if (!reset && !recalibrate) {
			do_floppy = (current_track && current_track != NO_TRACK)
			    ?  shake_zero : shake_one;
			output_byte(FD_RECALIBRATE);
			output_byte(head<<2 | current_drive);
			return;
		}
	}
	if (reset) {
		reset_floppy();
		return;
	}
	if (recalibrate) {
		recalibrate_floppy();
		return;
	}
/* We cannot do a floppy-select, as that might sleep. We just force it */
	selected = 1;
	if (current_drive != (current_DOR & 3)) {
		seek = 1;
		current_track = NO_TRACK;
		current_DOR &= 0xFC;
		current_DOR |= current_drive;
		outb(current_DOR,FD_DOR);
		add_timer(2,&transfer);
	} else
		transfer();
}
Пример #13
0
/**
 * call the specified subroutine name
 * @param sname subroutine name
 */
void gen_call(char *sname) {
    output_with_tab ("call ");
    output_string (sname);
    output_byte(',');
    output_number(args);
    newline ();
}
Пример #14
0
static void copy_from_history(LHAPM2Decoder *decoder, unsigned int code,
                              uint8_t *buf, size_t *buf_len)
{
	int to_copy, offset;
	unsigned int i, pos, start;

	// Read number of bytes to copy and offset within history to copy
	// from.

	to_copy = history_get_count(decoder, code);
	offset = history_get_offset(decoder, code);

	if (to_copy < 0 || offset < 0) {
		return;
	}

	// Sanity check to prevent the potential for buffer overflow.

	if (to_copy > OUTPUT_BUFFER_SIZE) {
		return;
	}

	// Perform copy.

	start = decoder->ringbuf_pos + RING_BUFFER_SIZE - 1
	      - (unsigned int) offset;

	for (i = 0; i < (unsigned int) to_copy; ++i) {
		pos = (start + i) % RING_BUFFER_SIZE;

		output_byte(decoder, buf, buf_len, decoder->ringbuf[pos]);
	}
}
Пример #15
0
/**
 * dump all static variables
 */
void dumpglbs(void) {
    int dim, i, list_size, line_count, value;
    if (!glbflag)
        return;
    current_symbol_table_idx = rglobal_table_index;
    while (current_symbol_table_idx < global_table_index) {
        SYMBOL *symbol = &symbol_table[current_symbol_table_idx];
        if (symbol->identity != FUNCTION) {
            ppubext(symbol);
            if (symbol->storage != EXTERN) {
                output_string(symbol->name);
                output_label_terminator();
                dim = symbol->offset;
                list_size = 0;
                line_count = 0;
                if (find_symbol_initials(symbol->name)) { // has initials
                    list_size = get_size(symbol->name);
                    if (dim == -1) {
                        dim = list_size;
                    }
                }
                for (i=0; i<dim; i++) {
                    if (symbol->type == STRUCT) {
                        dump_struct(symbol, i);
                    } else {
                        if (line_count % 10 == 0) {
                            newline();
                            if ((symbol->type & CINT) || (symbol->identity == POINTER)) {
                                gen_def_word();
                            } else {
                                gen_def_byte();
                            }
                        }
                        if (i < list_size) {
                            // dump data
                            value = get_item_at(symbol->name, i, &tag_table[symbol->tagidx]);
                            output_number(value);
                        } else {
                            // dump zero, no more data available
                            output_number(0);
                        }
                        line_count++;
                        if (line_count % 10 == 0) {
                            line_count = 0;
                        } else {
                            if (i < dim-1) {
                                output_byte( ',' );
                            }
                        }
                    }
                }
                newline();
            }
        } else {
            fpubext(symbol);
        }
        current_symbol_table_idx++;
    }
}
Пример #16
0
void hd44780_init(void)
{
    /* verschiedene Hardware initialisieren */
    hd44780_hw_init();
    _delay_ms(40);

#if HD44780_TYPE == HD44780_KS0066U
    /* Hardware initialisiert -> Standardprozedur KS0066U Datenblatt 4bit Mode */
    output_nibble(0, 0x02);
#else
    /* Hardware initialisiert -> Standardprozedur HD44780 Datenblatt 4bit Mode */
    output_nibble(0, 0x03);

    _delay_ms(4);
    clock_write();

    _delay_ms(1);
    clock_write();

    _delay_ms(1);
    output_nibble(0, 0x02);		//4bit mode
    _delay_ms(1);
    /* init done */
#endif

    /* configure for 4 bit, 2 lines, 5x9 font (datasheet, page 24) */
    output_byte(0, CMD_FUNCTIONSET(0, 1, 0));

    /* turn on display, cursor and blinking */
    hd44780_config(0,0);

    /* clear display */
    hd44780_clear();

    /* set shift and increment */
    output_byte(0, CMD_ENTRY_MODE(1, 0));

    /* set ddram address */
    output_byte(0, CMD_SETDRAMADR(0));

    /* open file descriptor */
    lcd = fdevopen(hd44780_put, NULL);

    /* set current virtual postion */
    current_pos = 0;
}
Пример #17
0
static size_t lha_lh1_read(void *data, uint8_t *buf)
{
    LHALH1Decoder *decoder = data;
    size_t result;
    uint16_t code;

    result = 0;

    // Read the next code from the input stream.

    if (!read_code(decoder, &code)) {
        return 0;
    }

    // The code either indicates a single byte to be output, or
    // it indicates that a block should be copied from the ring
    // buffer as it is a repeat of a sequence earlier in the
    // stream.

    if (code < 0x100) {
        output_byte(decoder, buf, &result, (uint8_t) code);
    } else {
        unsigned int count, start, i, pos, offset;

        // Read the offset into the history at which to start
        // copying.

        if (!read_offset(decoder, &offset)) {
            return 0;
        }

        count = code - 0x100U + COPY_THRESHOLD;
        start = decoder->ringbuf_pos - offset + RING_BUFFER_SIZE - 1;

        // Copy from history into output buffer:

        for (i = 0; i < count; ++i) {
            pos = (start + i) % RING_BUFFER_SIZE;

            output_byte(decoder, buf, &result,
                        decoder->ringbuf[pos]);
        }
    }

    return result;
}
Пример #18
0
/*
 * This routine is called when everything should be correctly set up
 * for the transfer (ie floppy motor is on and the correct floppy is
 * selected).
 */
static void transfer(void)
{
	read_track = (command == FD_READ) && (CURRENT_ERRORS < 4) &&
	    (floppy->sect <= MAX_BUFFER_SECTORS);
	if (cur_spec1 != floppy->spec1) {
		cur_spec1 = floppy->spec1;
		output_byte(FD_SPECIFY);
		output_byte(cur_spec1);		/* hut etc */
		output_byte(6);			/* Head load time =6ms, DMA */
	}
	if (cur_rate != floppy->rate) {
		/* use bit 6 of floppy->rate to indicate perpendicular mode */
		perpendicular_mode(floppy->rate);
		outb_p(cur_rate = ((floppy->rate)) & ~0x40, FD_DCR);
	}
	if (reset) {
		redo_fd_request();
		return;
	}
	if (!seek) {
		setup_rw_floppy();
		return;
	}
	do_floppy = seek_interrupt;
	output_byte(FD_SEEK);
	if (read_track)
		output_byte(current_drive);
	else
		output_byte((head<<2) | current_drive);
	output_byte(seek_track);
	if (reset)
		redo_fd_request();
}
Пример #19
0
static void describe_access(SYMBOL *sym)
{
    if (sym->storage == REGISTER) {
        output_string("r");
        output_number(sym->offset);
        newline();
        return;
    }
    output_byte('(');
    if (sym->storage == LSTATIC) {
        print_label(sym->offset);
    } else if (sym->storage == AUTO || sym->storage == DEFAUTO) {
        output_number(sym->offset);
        output_string("+fp");
    } else
        output_label_name(sym->name);
    output_byte(')');
    newline();
}
Пример #20
0
static void recal_interrupt(void)
{
	output_byte(FD_SENSEI);
	current_track = NO_TRACK;
	if (result()!=2 || (ST0 & 0xE0) == 0x60)
		reset = 1;
/* Recalibrate until track 0 is reached. Might help on some errors. */
	if ((ST0 & 0x10) == 0x10) recalibrate_floppy();
	else redo_fd_request();
}
Пример #21
0
static void unexpected_floppy_interrupt(void) {

	current_track = NO_TRACK;
	output_byte(FD_SENSEI);
	printk(DEVICE_NAME ": unexpected interrupt\n");
	if (result()!=2 || (ST0 & 0xE0) == 0x60)
		reset = 1;
	else
		recalibrate = 1;
}
Пример #22
0
int ByteAlign(void)
{
	if(bits_to_go!=8)
	{
		output_byte(0,bits_to_go);  /*byte align*/
		return bits_to_go;
	}
	else
		return 0;
}
Пример #23
0
static void floppy_ready(void) {
	if (inb(FDC_DIR) & 0x80) {
		changed_floppies |= 1<<current_drive;
		buffer_track = -1;
		if (keep_data[current_drive]) {
			if (keep_data[current_drive] > 0)
				keep_data[current_drive]--;
		} else {
			if (ftd_msg[current_drive] && current_type[current_drive] != NULL)
				printk("Disk type is undefined after disk "
				    "change in fd%d\n",current_drive);
			current_type[current_drive] = NULL;
			floppy_sizes[current_drive] = MAX_DISK_SIZE;
		}

		/* Forcing the drive to seek makes the "media changed" condition go away.
		 * There should be a cleaner solution for that ...
		 */
		if (!reset && !recalibrate) {
			if (current_track && current_track != NO_TRACK) {
				do_floppy = shake_zero;
			} else {
				do_floppy = shake_one;
			}

			output_byte(FD_RECALIBRATE);
			output_byte(head<<2 | current_drive);
			return;
		}
	}
	if (reset) {
		reset_floppy();
		return;
	}
	if (recalibrate) {
		recalibrate_floppy();
		return;
	}
	transfer();
}
Пример #24
0
static void output_block(LHALZSDecoder *decoder,
                         uint8_t *buf,
                         size_t *buf_len,
                         unsigned int start,
                         unsigned int len)
{
	unsigned int i;

	for (i = 0; i < len; ++i) {
		output_byte(decoder, buf, buf_len,
		            decoder->ringbuf[(start + i) % RING_BUFFER_SIZE]);
	}
}
Пример #25
0
void doerror(char *ptr)
{
        int k;
        gen_comment ();
        output_string (line);
        newline ();
        gen_comment ();
        k = 0;
        while (k < lptr) {
                if (line[k] == 9)
                        print_tab ();
                else
                        output_byte (' ');
                k++;
        }
        output_byte ('^');
        newline ();
        gen_comment ();
        output_string ("******  ");
        output_string (ptr);
        output_string ("  ******");
        newline ();
}
Пример #26
0
/* Set perpendicular mode as required, based on data rate, if supported.
 * 80277: 1Mbps data rate only possible with 82077-1.
 * Untested!! TODO: increase MAX_BUFFER_SECTORS, add floppy_type entries.
 */
static void inline perpendicular_mode(unsigned char rate)
{
	if (fdc_version == FDC_TYPE_82077) {
		output_byte(FD_PERPENDICULAR);
		if (rate & 0x40) {
			unsigned char r = rate & 0x03;
			if (r == 0)
				output_byte(2);	/* perpendicular, 500 kbps */
			else if (r == 3)
				output_byte(3);	/* perpendicular, 1Mbps */
			else {
				printk(DEVICE_NAME ": Invalid data rate for perpendicular mode!\n");
				reset = 1;
			}
		} else
			output_byte(0);		/* conventional mode */
	} else {
		if (rate & 0x40) {
			printk(DEVICE_NAME ": perpendicular mode not supported by FDC.\n");
			reset = 1;
		}
	}
} /* perpendicular_mode */
Пример #27
0
/*
 * This is the routine called after every seek (or recalibrate) interrupt
 * from the floppy controller. Note that the "unexpected interrupt" routine
 * also does a recalibrate, but doesn't come here.
 */
static void seek_interrupt(void) {

	/* sense drive status */
	output_byte(FD_SENSEI);
	if (result() != 2 || (ST0 & 0xF8) != 0x20 || ST1 != seek_track) {
		printk(DEVICE_NAME ": seek failed\n");
		recalibrate = 1;
		bad_flp_intr();
		redo_fd_request();
		return;
	}
	current_track = ST1;
	setup_rw_floppy();
}
Пример #28
0
int constant(int val[]) {
    if (number (val))
        gen_immediate ();
    else if (quoted_char (val))
        gen_immediate ();
    else if (quoted_string (val)) {
        gen_immediate ();
        print_label (litlab);
        output_byte ('+');
    } else
        return (0);
    output_number (val[0]);
    newline ();
    return (1);
}
Пример #29
0
static void read_single_byte(LHAPM2Decoder *decoder, unsigned int code,
                             uint8_t *buf, size_t *buf_len)
{
	int offset;
	uint8_t b;

	offset = decode_variable_length(decoder, history_decode, code);

	if (offset < 0) {
		return;
	}

	b = find_in_history(decoder, (uint8_t) offset);
	output_byte(decoder, buf, buf_len, b);
}
Пример #30
0
/*
 * This has only been tested for the case fdc_version == FDC_TYPE_STD.
 * In case you have a 82077 and want to test it, you'll have to compile
 * with `FDC_FIFO_UNTESTED' defined. You may also want to add support for
 * recognizing drives with vertical recording support.
 */
static void configure_fdc_mode(void) {

	if (need_configure && (fdc_version == FDC_TYPE_82077)) {
		/* Enhanced version with FIFO & vertical recording. */
		output_byte(FD_CONFIGURE);
		output_byte_force(0);

		output_byte(0x1A);	        /* FIFO on, polling off, 10 byte threshold */
		output_byte_force(0);		/* precompensation from track 0 upwards */
		need_configure = 0;
		printk(DEVICE_NAME ": FIFO enabled\n");
	}
	if (cur_spec1 != floppy->spec1) {
		cur_spec1 = floppy->spec1;
		output_byte(FD_SPECIFY);
		output_byte(cur_spec1);		/* hut etc */
		output_byte(6);			    /* Head load time =6ms, DMA */
	}
	if (cur_rate != floppy->rate) {
		/* use bit 6 of floppy->rate to indicate perpendicular mode */
		perpendicular_mode(floppy->rate);
		outb_p((cur_rate = (floppy->rate)) & ~0x40, FDC_DCR);
	}
} /* configure_fdc_mode */