📄 parport.h
字号:
// $Id: parport.h,v 1.4 2006/12/12 18:23:01 vlahan Exp $
/*
* $Id: parport.h,v 1.4 2006/12/12 18:23:01 vlahan Exp $
*
****************************************************************************
*
* uisp - The Micro In-System Programmer for Atmel AVR microcontrollers.
* Copyright (C) 1999, 2000, 2001, 2002 Uros Platise
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
****************************************************************************
*/
/* Id: parport.h,v 1.1 1998/05/17 10:57:52 andrea Exp andrea */
#ifndef _PARPORT_H_
#define _PARPORT_H_
/* Start off with user-visible constants */
/* Maximum of 8 ports per machine */
#define PARPORT_MAX 8
/* Magic numbers */
#define PARPORT_IRQ_NONE -1
#define PARPORT_DMA_NONE -1
#define PARPORT_IRQ_AUTO -2
#define PARPORT_DMA_AUTO -2
#define PARPORT_DISABLE -2
#define PARPORT_IRQ_PROBEONLY -3
#define PARPORT_CONTROL_STROBE 0x1
#define PARPORT_CONTROL_AUTOFD 0x2
#define PARPORT_CONTROL_INIT 0x4
#define PARPORT_CONTROL_SELECT 0x8
#define PARPORT_CONTROL_INTEN 0x10
#define PARPORT_CONTROL_DIRECTION 0x20
#define PARPORT_STATUS_ERROR 0x8
#define PARPORT_STATUS_SELECT 0x10
#define PARPORT_STATUS_PAPEROUT 0x20
#define PARPORT_STATUS_ACK 0x40
#define PARPORT_STATUS_BUSY 0x80
/* Type classes for Plug-and-Play probe. */
typedef enum {
PARPORT_CLASS_LEGACY = 0, /* Non-IEEE1284 device */
PARPORT_CLASS_PRINTER,
PARPORT_CLASS_MODEM,
PARPORT_CLASS_NET,
PARPORT_CLASS_HDC, /* Hard disk controller */
PARPORT_CLASS_PCMCIA,
PARPORT_CLASS_MEDIA, /* Multimedia device */
PARPORT_CLASS_FDC, /* Floppy disk controller */
PARPORT_CLASS_PORTS,
PARPORT_CLASS_SCANNER,
PARPORT_CLASS_DIGCAM,
PARPORT_CLASS_OTHER, /* Anything else */
PARPORT_CLASS_UNSPEC /* No CLS field in ID */
} parport_device_class;
/* The "modes" entry in parport is a bit field representing the following
* modes.
* Note that PARPORT_MODE_PCECPEPP is for the SMC EPP+ECP mode which is NOT
* 100% compatible with EPP.
*/
#define PARPORT_MODE_PCSPP 0x0001
#define PARPORT_MODE_PCPS2 0x0002
#define PARPORT_MODE_PCEPP 0x0004
#define PARPORT_MODE_PCECP 0x0008
#define PARPORT_MODE_PCECPEPP 0x0010
#define PARPORT_MODE_PCECR 0x0020 /* ECR Register Exists */
#define PARPORT_MODE_PCECPPS2 0x0040
/* The rest is for the kernel only */
#ifdef __KERNEL__
#include <asm/system.h>
#include <asm/ptrace.h>
#include <asm/spinlock.h>
#include <linux/proc_fs.h>
#include <linux/config.h>
#define PARPORT_NEED_GENERIC_OPS
/* Define this later. */
struct parport;
struct pc_parport_state {
unsigned int ctr;
unsigned int ecr;
};
struct parport_state {
union {
struct pc_parport_state pc;
/* ARC has no state. */
/* AX uses same state information as PC */
void *misc;
} u;
};
struct parport_operations {
void (*write_data)(struct parport *, unsigned char);
unsigned char (*read_data)(struct parport *);
void (*write_control)(struct parport *, unsigned char);
unsigned char (*read_control)(struct parport *);
unsigned char (*frob_control)(struct parport *, unsigned char mask, unsigned char val);
void (*write_econtrol)(struct parport *, unsigned char);
unsigned char (*read_econtrol)(struct parport *);
unsigned char (*frob_econtrol)(struct parport *, unsigned char mask, unsigned char val);
void (*write_status)(struct parport *, unsigned char);
unsigned char (*read_status)(struct parport *);
void (*write_fifo)(struct parport *, unsigned char);
unsigned char (*read_fifo)(struct parport *);
void (*change_mode)(struct parport *, int);
void (*release_resources)(struct parport *);
int (*claim_resources)(struct parport *);
void (*epp_write_data)(struct parport *, unsigned char);
unsigned char (*epp_read_data)(struct parport *);
void (*epp_write_addr)(struct parport *, unsigned char);
unsigned char (*epp_read_addr)(struct parport *);
int (*epp_check_timeout)(struct parport *);
size_t (*epp_write_block)(struct parport *, void *, size_t);
size_t (*epp_read_block)(struct parport *, void *, size_t);
int (*ecp_write_block)(struct parport *, void *, size_t, void (*fn)(struct parport *, void *, size_t), void *);
int (*ecp_read_block)(struct parport *, void *, size_t, void (*fn)(struct parport *, void *, size_t), void *);
void (*init_state)(struct parport_state *);
void (*save_state)(struct parport *, struct parport_state *);
void (*restore_state)(struct parport *, struct parport_state *);
void (*enable_irq)(struct parport *);
void (*disable_irq)(struct parport *);
void (*interrupt)(int, void *, struct pt_regs *);
void (*inc_use_count)(void);
void (*dec_use_count)(void);
void (*fill_inode)(struct inode *inode, int fill);
};
struct parport_device_info {
parport_device_class class;
const char *class_name;
const char *mfr;
const char *model;
const char *cmdset;
const char *description;
};
/* Each device can have two callback functions:
* 1) a preemption function, called by the resource manager to request
* that the driver relinquish control of the port. The driver should
* return zero if it agrees to release the port, and nonzero if it
* refuses. Do not call parport_release() - the kernel will do this
* implicitly.
*
* 2) a wake-up function, called by the resource manager to tell drivers
* that the port is available to be claimed. If a driver wants to use
* the port, it should call parport_claim() here.
*/
/* A parallel port device */
struct pardevice {
const char *name;
struct parport *port;
int (*preempt)(void *);
void (*wakeup)(void *);
void *private;
void (*irq_func)(int, void *, struct pt_regs *);
unsigned int flags;
struct pardevice *next;
struct pardevice *prev;
struct parport_state *state; /* saved status over preemption */
struct wait_queue *wait_q;
unsigned long int time;
unsigned long int timeslice;
unsigned int waiting;
struct pardevice *waitprev;
struct pardevice *waitnext;
};
/* Directory information for the /proc interface */
struct parport_dir {
struct proc_dir_entry *entry; /* Directory /proc/parport/X */
struct proc_dir_entry *irq; /* .../irq */
struct proc_dir_entry *devices; /* .../devices */
struct proc_dir_entry *hardware; /* .../hardware */
struct proc_dir_entry *probe; /* .../autoprobe */
char name[4];
};
/* A parallel port */
struct parport {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -