Skip to content

Commit

Permalink
Merge pull request #1727 from ghaerr/df
Browse files Browse the repository at this point in the history
[driver] Optionally place direct floppy driver in far text segment
  • Loading branch information
ghaerr authored Sep 19, 2023
2 parents a232960 + ab7ef71 commit cece75e
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 47 deletions.
50 changes: 25 additions & 25 deletions elks/arch/i86/drivers/block/directfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ static int initial_reset_flag;
static int need_configure = 1; /* for 82077 */
static int recalibrate;
static int reset;
static int recover; /* recalibrate immediately after resetting */
static int recover; /* recalibrate immediately after resetting */
static int seek;

/* BIOS floppy motor timeout counter - FIXME leave this while BIOS driver present */
Expand Down Expand Up @@ -281,15 +281,15 @@ static unsigned char current_track = NO_TRACK;
static unsigned char command;
static unsigned char fdc_version;

static void floppy_ready(void);
static void redo_fd_request(void);
static void DFPROC floppy_ready(void);
static void DFPROC redo_fd_request(void);
static void recal_interrupt(void);
static void floppy_shutdown(void);
static void motor_off_callback(int);
static int floppy_register(void);
static void floppy_deregister(void);
static int DFPROC floppy_register(void);
static void DFPROC floppy_deregister(void);

static void delay_loop(int cnt)
static void DFPROC delay_loop(int cnt)
{
while (cnt-- > 0) asm("nop");
}
Expand All @@ -310,7 +310,7 @@ static struct timer_list select = { NULL, 0, 0, select_callback };
* FIXME: The argument (nr) is silently ignored, current_drive being used instead.
* is this OK?
*/
static void floppy_select(unsigned int nr)
static void DFPROC floppy_select(unsigned int nr)
{
DEBUG("sel0x%x-", current_DOR);
if (current_drive == (current_DOR & 3)) {
Expand Down Expand Up @@ -378,7 +378,7 @@ static void motor_off_callback(int nr)
*
* DOR (Data Output Register) is |MOTD|MOTC|MOTB|MOTA|DMA|/RST|DR1|DR0|
*/
static void floppy_on(int nr)
static void DFPROC floppy_on(int nr)
{
unsigned char mask = 0x10 << nr; /* motor on select */

Expand Down Expand Up @@ -482,7 +482,7 @@ int floppy_change(struct buffer_head *bh)
}
#endif

static void setup_DMA(void)
static void DFPROC setup_DMA(void)
{
unsigned long dma_addr;
unsigned int count, physaddr;
Expand Down Expand Up @@ -526,7 +526,7 @@ static void setup_DMA(void)
set_irq();
}

static void output_byte(char byte)
static void DFPROC output_byte(char byte)
{
int counter;
unsigned char status;
Expand All @@ -545,7 +545,7 @@ static void output_byte(char byte)
printk("fd: can't send to FDC\n");
}

static int result(void)
static int DFPROC result(void)
{
int i = 0, counter, status;

Expand All @@ -570,7 +570,7 @@ static int result(void)
return -1;
}

static void bad_flp_intr(void)
static void DFPROC bad_flp_intr(void)
{
int errors;

Expand All @@ -596,7 +596,7 @@ static void bad_flp_intr(void)
* 1Mbps data rate only possible with 82077-1.
* TODO: increase MAX_BUFFER_SECTORS.
*/
static void perpendicular_mode(unsigned char rate)
static void DFPROC perpendicular_mode(unsigned char rate)
{
if (fdc_version >= FDC_TYPE_82077) {
output_byte(FD_PERPENDICULAR);
Expand All @@ -620,7 +620,7 @@ static void perpendicular_mode(unsigned char rate)
}
} /* perpendicular_mode */

static void configure_fdc_mode(void)
static void DFPROC configure_fdc_mode(void)
{
if (need_configure && (fdc_version >= FDC_TYPE_82072)) {
/* Enhanced version with FIFO & write precompensation */
Expand All @@ -644,7 +644,7 @@ static void configure_fdc_mode(void)
}
} /* configure_fdc_mode */

static void tell_sector(int nr)
static void DFPROC tell_sector(int nr)
{
if (nr != 7) {
printk(" -- FDC reply error");
Expand Down Expand Up @@ -771,7 +771,7 @@ static void rw_interrupt(void)
* transfer mode. It continues to transfer data until the TC input is active."
* IOW: We tell the FDC where to start, and the DMA controller where to stop.
*/
void setup_rw_floppy(void)
static void DFPROC setup_rw_floppy(void)
{
DEBUG("setup_rw-");
setup_DMA();
Expand Down Expand Up @@ -818,7 +818,7 @@ static void seek_interrupt(void)
* for the transfer (ie floppy motor is on and the correct floppy is
* selected, error conditions cleared).
*/
static void transfer(void)
static void DFPROC transfer(void)
{
#ifdef CONFIG_TRACK_CACHE
read_track = (command == FD_READ) && (CURRENT->rq_errors < 4) &&
Expand Down Expand Up @@ -848,7 +848,7 @@ static void transfer(void)
redo_fd_request();
}

static void recalibrate_floppy(void)
static void DFPROC recalibrate_floppy(void)
{
DEBUG("recal-");
recalibrate = 0;
Expand Down Expand Up @@ -929,7 +929,7 @@ static void reset_interrupt(void)
/*
* reset is done by pulling bit 2 of DOR low for a while.
*/
static void reset_floppy(void)
static void DFPROC reset_floppy(void)
{
DEBUG("[%u]rst-", (unsigned int)jiffies);
do_floppy = reset_interrupt;
Expand Down Expand Up @@ -981,7 +981,7 @@ static void shake_done(void)
/*
* The result byte after the SENSEI cmd is ST3, not ST0
*/
static int retry_recal(void (*proc)())
static int DFPROC retry_recal(void (*proc)())
{
DEBUG("rrecal-");
output_byte(FD_SENSEI);
Expand Down Expand Up @@ -1011,7 +1011,7 @@ static void shake_one(void)
output_byte(1);
}

static void floppy_ready(void)
static void DFPROC floppy_ready(void)
{
DEBUG("RDY0x%x,%d,%d-", inb(FD_DIR), reset, recalibrate);
/* check if disk changed since last cmd (PC/AT+) */
Expand Down Expand Up @@ -1057,7 +1057,7 @@ static void floppy_ready(void)
transfer();
}

static void redo_fd_request(void)
static void DFPROC redo_fd_request(void)
{
unsigned int start;
struct request *req;
Expand Down Expand Up @@ -1405,7 +1405,7 @@ static void floppy_interrupt(int irq, struct pt_regs *regs)
#define FLOPPY_VEC (_MK_FP(0, (FLOPPY_IRQ+8) << 2))
static __u32 old_floppy_vec;

static void floppy_deregister(void)
static void DFPROC floppy_deregister(void)
{
outb(0x0c, FD_DOR); /* all motors off, enable IRQ and DMA */
free_dma(FLOPPY_DMA);
Expand All @@ -1417,7 +1417,7 @@ static void floppy_deregister(void)
}

/* Try to determine the floppy controller type */
static int get_fdc_version(void)
static int DFPROC get_fdc_version(void)
{
int type = FDC_TYPE_8272A;
const char *name;
Expand Down Expand Up @@ -1459,7 +1459,7 @@ static int get_fdc_version(void)
return type;
}

static int floppy_register(void)
static int DFPROC floppy_register(void)
{
int err;

Expand Down
23 changes: 12 additions & 11 deletions elks/arch/i86/drivers/block/dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <linuxmt/kernel.h>
#include <linuxmt/errno.h>
#include <linuxmt/debug.h>
#include <linuxmt/fd.h> /* for DFPROC */
#include <arch/dma.h>
#include <arch/system.h>

Expand Down Expand Up @@ -65,7 +66,7 @@ static struct dma_chan dma_chan_busy[MAX_DMA_CHANNELS] = {
__ret; \
} )

int request_dma(unsigned char dma, const char *device)
int DFPROC request_dma(unsigned char dma, const char *device)
{
if (dma >= MAX_DMA_CHANNELS)
return -EINVAL;
Expand All @@ -79,7 +80,7 @@ int request_dma(unsigned char dma, const char *device)
return 0;
} /* request_dma */

void free_dma(unsigned char dma)
void DFPROC free_dma(unsigned char dma)
{
if (dma >= MAX_DMA_CHANNELS)
debug("Trying to free DMA%u\n", dma);
Expand All @@ -89,7 +90,7 @@ void free_dma(unsigned char dma)

/* enable/disable a specific DMA channel */

void enable_dma(unsigned char dma)
void DFPROC enable_dma(unsigned char dma)
{
if (dma >= MAX_DMA_CHANNELS)
debug("Trying to enable DMA%u\n", dma);
Expand All @@ -99,7 +100,7 @@ void enable_dma(unsigned char dma)
dma_outb(dma & 3, DMA2_MASK_REG);
}

void disable_dma(unsigned char dma)
void DFPROC disable_dma(unsigned char dma)
{
if (dma >= MAX_DMA_CHANNELS)
debug("Trying to disable DMA%u\n", dma);
Expand All @@ -117,7 +118,7 @@ void disable_dma(unsigned char dma)
* --- only be used while interrupts are disabled! ---
*/

void clear_dma_ff(unsigned char dma)
void DFPROC clear_dma_ff(unsigned char dma)
{
if (dma >= MAX_DMA_CHANNELS)
debug("Trying to disable DMA%u\n", dma);
Expand All @@ -129,7 +130,7 @@ void clear_dma_ff(unsigned char dma)

/* set mode (above) for a specific DMA channel */

void set_dma_mode(unsigned char dma, unsigned char mode)
void DFPROC set_dma_mode(unsigned char dma, unsigned char mode)
{
if (dma >= MAX_DMA_CHANNELS)
debug("Trying to disable DMA%u\n", dma);
Expand All @@ -145,7 +146,7 @@ void set_dma_mode(unsigned char dma, unsigned char mode)
* boundary may have been crossed.
*/

void set_dma_page(unsigned char dma, unsigned char page)
void DFPROC set_dma_page(unsigned char dma, unsigned char page)
{
switch (dma) {
case 0:
Expand Down Expand Up @@ -176,7 +177,7 @@ void set_dma_page(unsigned char dma, unsigned char page)
* Assumes dma flipflop is clear.
*/

void set_dma_addr(unsigned char dma, unsigned long addr)
void DFPROC set_dma_addr(unsigned char dma, unsigned long addr)
{
set_dma_page(dma, (long)addr >> 16);
if (dma <= 3) {
Expand All @@ -197,7 +198,7 @@ void set_dma_addr(unsigned char dma, unsigned long addr)
* NOTE 2: "count" represents _bytes_ and must be even for channels 5-7.
*/

void set_dma_count(unsigned char dma, unsigned int count)
void DFPROC set_dma_count(unsigned char dma, unsigned int count)
{
count--;
if (dma <= 3) {
Expand All @@ -219,7 +220,7 @@ void set_dma_count(unsigned char dma, unsigned int count)
* Assumes DMA flip-flop is clear.
*/

int get_dma_residue(unsigned char dma)
int DFPROC get_dma_residue(unsigned char dma)
{
unsigned int io_port = (dma <= 3) ? (dma << 1) + 1 + IO_DMA1_BASE
: ((dma & 3) << 2) + 2 + IO_DMA2_BASE;
Expand All @@ -232,7 +233,7 @@ int get_dma_residue(unsigned char dma)
return (dma <= 3) ? count : (count << 1);
}

int get_dma_list(char *buf)
int DFPROC get_dma_list(char *buf)
{
int i, len = 0;

Expand Down
22 changes: 11 additions & 11 deletions elks/include/arch/dma.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,16 @@
#define DMA_MODE_WRITE 0x48 /* memory to I/O, no autoinit, increment, single mode */
#define DMA_MODE_CASCADE 0xC0 /* pass thru DREQ->HRQ, DACK<-HLDA only */

/* These are in kernel/dma.c: */
extern void enable_dma(unsigned char);
extern void disable_dma(unsigned char);
extern void clear_dma_ff(unsigned char);
extern void set_dma_mode(unsigned char,unsigned char);
extern void set_dma_page(unsigned char,unsigned char);
extern void set_dma_addr(unsigned char,unsigned long);
extern void set_dma_count(unsigned char,unsigned int);
extern int get_dma_residue(unsigned char);
extern int request_dma(unsigned char,const char *);
extern void free_dma(unsigned char);
/* These are in dma.c */
extern void DFPROC enable_dma(unsigned char);
extern void DFPROC disable_dma(unsigned char);
extern void DFPROC clear_dma_ff(unsigned char);
extern void DFPROC set_dma_mode(unsigned char,unsigned char);
extern void DFPROC set_dma_page(unsigned char,unsigned char);
extern void DFPROC set_dma_addr(unsigned char,unsigned long);
extern void DFPROC set_dma_count(unsigned char,unsigned int);
extern int DFPROC get_dma_residue(unsigned char);
extern int DFPROC request_dma(unsigned char,const char *);
extern void DFPROC free_dma(unsigned char);

#endif
11 changes: 11 additions & 0 deletions elks/include/linuxmt/fd.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
#ifndef __LINUXMT_FD_H
#define __LINUXMT_FD_H

/*
* Direct floppy (DF) driver header file
*/

/* place most of this driver in the far text section if possible */
#if defined(CONFIG_FARTEXT_KERNEL) && !defined(__STRICT_ANSI__)
#define DFPROC __far __attribute__ ((far_section, noinline, section (".fartext.df")))
#else
#define DFPROC
#endif

#define FDCLRPRM 0 /* clear user-defined parameters */
#define FDSETPRM 1 /* set user-defined parameters for current media */
#define FDDEFPRM 2 /* set user-defined parameters until explicitly cleared */
Expand Down

0 comments on commit cece75e

Please sign in to comment.