arch/x86/include/asm/floppy.h

Source file repositories/reference/linux-study-clean/arch/x86/include/asm/floppy.h

File Facts

System
Linux kernel
Corpus path
arch/x86/include/asm/floppy.h
Extension
.h
Size
7035 bytes
Lines
297
Domain
Architecture Layer
Bucket
arch/x86
Inferred role
Architecture Layer: implementation source
Status
source implementation candidate

Why This File Exists

CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.

Dependency Surface

Detected Declarations

Annotated Snippet

#ifndef _ASM_X86_FLOPPY_H
#define _ASM_X86_FLOPPY_H

#include <linux/sizes.h>
#include <linux/vmalloc.h>

/*
 * The DMA channel used by the floppy controller cannot access data at
 * addresses >= 16MB
 *
 * Went back to the 1MB limit, as some people had problems with the floppy
 * driver otherwise. It doesn't matter much for performance anyway, as most
 * floppy accesses go through the track buffer.
 */
#define _CROSS_64KB(a, s, vdma)						\
	(!(vdma) &&							\
	 ((unsigned long)(a) / SZ_64K != ((unsigned long)(a) + (s) - 1) / SZ_64K))

#define SW fd_routine[use_virtual_dma & 1]
#define CSW fd_routine[can_use_virtual_dma & 1]


#define fd_request_dma()	CSW._request_dma(FLOPPY_DMA, "floppy")
#define fd_free_dma()		CSW._free_dma(FLOPPY_DMA)
#define fd_enable_irq()		enable_irq(FLOPPY_IRQ)
#define fd_disable_irq()	disable_irq(FLOPPY_IRQ)
#define fd_free_irq()		free_irq(FLOPPY_IRQ, NULL)
#define fd_get_dma_residue()	SW._get_dma_residue(FLOPPY_DMA)
#define fd_dma_mem_alloc(size)	SW._dma_mem_alloc(size)
#define fd_dma_setup(addr, size, mode, io) SW._dma_setup(addr, size, mode, io)

#define FLOPPY_CAN_FALLBACK_ON_NODMA

static int virtual_dma_count;
static int virtual_dma_residue;
static char *virtual_dma_addr;
static int virtual_dma_mode;
static int doing_pdma;

static inline u8 fd_inb(u16 base, u16 reg)
{
	u8 ret = inb_p(base + reg);

	native_io_delay();
	native_io_delay();
	native_io_delay();

	return ret;
}

static inline void fd_outb(u8 value, u16 base, u16 reg)
{
	outb_p(value, base + reg);

	native_io_delay();
	native_io_delay();
	native_io_delay();
}

static irqreturn_t floppy_hardint(int irq, void *dev_id)
{
	unsigned char st;

#undef TRACE_FLPY_INT

#ifdef TRACE_FLPY_INT
	static int calls;
	static int bytes;
	static int dma_wait;
#endif
	if (!doing_pdma)
		return floppy_interrupt(irq, dev_id);

#ifdef TRACE_FLPY_INT
	if (!calls)
		bytes = virtual_dma_count;
#endif

	{
		int lcount;
		char *lptr;

		for (lcount = virtual_dma_count, lptr = virtual_dma_addr;
		     lcount; lcount--, lptr++) {
			st = inb(virtual_dma_port + FD_STATUS);
			st &= STATUS_DMA | STATUS_READY;
			if (st != (STATUS_DMA | STATUS_READY))
				break;
			if (virtual_dma_mode)
				fd_outb(*lptr, virtual_dma_port, FD_DATA);

Annotation

Implementation Notes