diff options
Diffstat (limited to 'include/linux')
143 files changed, 16610 insertions, 0 deletions
diff --git a/include/linux/a.out.h b/include/linux/a.out.h new file mode 100644 index 000000000..4e1a815a2 --- /dev/null +++ b/include/linux/a.out.h @@ -0,0 +1,270 @@ +#ifndef __A_OUT_GNU_H__ +#define __A_OUT_GNU_H__ + +#define __GNU_EXEC_MACROS__ + +#ifndef __STRUCT_EXEC_OVERRIDE__ + +struct exec +{ + unsigned long a_info; /* Use macros N_MAGIC, etc for access */ + unsigned a_text; /* length of text, in bytes */ + unsigned a_data; /* length of data, in bytes */ + unsigned a_bss; /* length of uninitialized data area for file, in bytes */ + unsigned a_syms; /* length of symbol table data in file, in bytes */ + unsigned a_entry; /* start address */ + unsigned a_trsize; /* length of relocation info for text, in bytes */ + unsigned a_drsize; /* length of relocation info for data, in bytes */ +}; + +#endif /* __STRUCT_EXEC_OVERRIDE__ */ + +/* these go in the N_MACHTYPE field */ +enum machine_type { +#if defined (M_OLDSUN2) + M__OLDSUN2 = M_OLDSUN2, +#else + M_OLDSUN2 = 0, +#endif +#if defined (M_68010) + M__68010 = M_68010, +#else + M_68010 = 1, +#endif +#if defined (M_68020) + M__68020 = M_68020, +#else + M_68020 = 2, +#endif +#if defined (M_SPARC) + M__SPARC = M_SPARC, +#else + M_SPARC = 3, +#endif + /* skip a bunch so we don't run into any of sun's numbers */ + M_386 = 100, +}; + +#if !defined (N_MAGIC) +#define N_MAGIC(exec) ((exec).a_info & 0xffff) +#endif +#define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff)) +#define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff) +#define N_SET_INFO(exec, magic, type, flags) \ + ((exec).a_info = ((magic) & 0xffff) \ + | (((int)(type) & 0xff) << 16) \ + | (((flags) & 0xff) << 24)) +#define N_SET_MAGIC(exec, magic) \ + ((exec).a_info = (((exec).a_info & 0xffff0000) | ((magic) & 0xffff))) + +#define N_SET_MACHTYPE(exec, machtype) \ + ((exec).a_info = \ + ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16)) + +#define N_SET_FLAGS(exec, flags) \ + ((exec).a_info = \ + ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24)) + +/* Code indicating object file or impure executable. */ +#define OMAGIC 0407 +/* Code indicating pure executable. */ +#define NMAGIC 0410 +/* Code indicating demand-paged executable. */ +#define ZMAGIC 0413 +/* This indicates a demand-paged executable with the header in the text. + The first page is unmapped to help trap NULL pointer references */ +#define QMAGIC 0314 + +/* Code indicating core file. */ +#define CMAGIC 0421 + +#if !defined (N_BADMAG) +#define N_BADMAG(x) (N_MAGIC(x) != OMAGIC \ + && N_MAGIC(x) != NMAGIC \ + && N_MAGIC(x) != ZMAGIC \ + && N_MAGIC(x) != QMAGIC) +#endif + +#define _N_HDROFF(x) (1024 - sizeof (struct exec)) + +#if !defined (N_TXTOFF) +#define N_TXTOFF(x) \ + (N_MAGIC(x) == ZMAGIC ? _N_HDROFF((x)) + sizeof (struct exec) : \ + (N_MAGIC(x) == QMAGIC ? 0 : sizeof (struct exec))) +#endif + +#if !defined (N_DATOFF) +#define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text) +#endif + +#if !defined (N_TRELOFF) +#define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data) +#endif + +#if !defined (N_DRELOFF) +#define N_DRELOFF(x) (N_TRELOFF(x) + (x).a_trsize) +#endif + +#if !defined (N_SYMOFF) +#define N_SYMOFF(x) (N_DRELOFF(x) + (x).a_drsize) +#endif + +#if !defined (N_STROFF) +#define N_STROFF(x) (N_SYMOFF(x) + (x).a_syms) +#endif + +/* Address of text segment in memory after it is loaded. */ +#if !defined (N_TXTADDR) +#define N_TXTADDR(x) (N_MAGIC(x) == QMAGIC ? PAGE_SIZE : 0) +#endif + +/* Address of data segment in memory after it is loaded. + Note that it is up to you to define SEGMENT_SIZE + on machines not listed here. */ +#if defined(vax) || defined(hp300) || defined(pyr) +#define SEGMENT_SIZE page_size +#endif +#ifdef sony +#define SEGMENT_SIZE 0x2000 +#endif /* Sony. */ +#ifdef is68k +#define SEGMENT_SIZE 0x20000 +#endif +#if defined(m68k) && defined(PORTAR) +#define PAGE_SIZE 0x400 +#define SEGMENT_SIZE PAGE_SIZE +#endif + +#ifdef linux +#include <asm/page.h> +#define SEGMENT_SIZE 1024 +#endif + +#define _N_SEGMENT_ROUND(x) (((x) + SEGMENT_SIZE - 1) & ~(SEGMENT_SIZE - 1)) + +#define _N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text) + +#ifndef N_DATADDR +#define N_DATADDR(x) \ + (N_MAGIC(x)==OMAGIC? (_N_TXTENDADDR(x)) \ + : (_N_SEGMENT_ROUND (_N_TXTENDADDR(x)))) +#endif + +/* Address of bss segment in memory after it is loaded. */ +#if !defined (N_BSSADDR) +#define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data) +#endif + +#if !defined (N_NLIST_DECLARED) +struct nlist { + union { + char *n_name; + struct nlist *n_next; + long n_strx; + } n_un; + unsigned char n_type; + char n_other; + short n_desc; + unsigned long n_value; +}; +#endif /* no N_NLIST_DECLARED. */ + +#if !defined (N_UNDF) +#define N_UNDF 0 +#endif +#if !defined (N_ABS) +#define N_ABS 2 +#endif +#if !defined (N_TEXT) +#define N_TEXT 4 +#endif +#if !defined (N_DATA) +#define N_DATA 6 +#endif +#if !defined (N_BSS) +#define N_BSS 8 +#endif +#if !defined (N_FN) +#define N_FN 15 +#endif + +#if !defined (N_EXT) +#define N_EXT 1 +#endif +#if !defined (N_TYPE) +#define N_TYPE 036 +#endif +#if !defined (N_STAB) +#define N_STAB 0340 +#endif + +/* The following type indicates the definition of a symbol as being + an indirect reference to another symbol. The other symbol + appears as an undefined reference, immediately following this symbol. + + Indirection is asymmetrical. The other symbol's value will be used + to satisfy requests for the indirect symbol, but not vice versa. + If the other symbol does not have a definition, libraries will + be searched to find a definition. */ +#define N_INDR 0xa + +/* The following symbols refer to set elements. + All the N_SET[ATDB] symbols with the same name form one set. + Space is allocated for the set in the text section, and each set + element's value is stored into one word of the space. + The first word of the space is the length of the set (number of elements). + + The address of the set is made into an N_SETV symbol + whose name is the same as the name of the set. + This symbol acts like a N_DATA global symbol + in that it can satisfy undefined external references. */ + +/* These appear as input to LD, in a .o file. */ +#define N_SETA 0x14 /* Absolute set element symbol */ +#define N_SETT 0x16 /* Text set element symbol */ +#define N_SETD 0x18 /* Data set element symbol */ +#define N_SETB 0x1A /* Bss set element symbol */ + +/* This is output from LD. */ +#define N_SETV 0x1C /* Pointer to set vector in data area. */ + +#if !defined (N_RELOCATION_INFO_DECLARED) +/* This structure describes a single relocation to be performed. + The text-relocation section of the file is a vector of these structures, + all of which apply to the text section. + Likewise, the data-relocation section applies to the data section. */ + +struct relocation_info +{ + /* Address (within segment) to be relocated. */ + int r_address; + /* The meaning of r_symbolnum depends on r_extern. */ + unsigned int r_symbolnum:24; + /* Nonzero means value is a pc-relative offset + and it should be relocated for changes in its own address + as well as for changes in the symbol or section specified. */ + unsigned int r_pcrel:1; + /* Length (as exponent of 2) of the field to be relocated. + Thus, a value of 2 indicates 1<<2 bytes. */ + unsigned int r_length:2; + /* 1 => relocate with value of symbol. + r_symbolnum is the index of the symbol + in file's the symbol table. + 0 => relocate with the address of a segment. + r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS + (the N_EXT bit may be set also, but signifies nothing). */ + unsigned int r_extern:1; + /* Four bits that aren't used, but when writing an object file + it is desirable to clear them. */ +#ifdef NS32K + unsigned r_bsr:1; + unsigned r_disp:1; + unsigned r_pad:2; +#else + unsigned int r_pad:4; +#endif +}; +#endif /* no N_RELOCATION_INFO_DECLARED. */ + + +#endif /* __A_OUT_GNU_H__ */ diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h new file mode 100644 index 000000000..10f639e78 --- /dev/null +++ b/include/linux/binfmts.h @@ -0,0 +1,53 @@ +#ifndef _LINUX_BINFMTS_H +#define _LINUX_BINFMTS_H + +#include <linux/ptrace.h> + +/* + * MAX_ARG_PAGES defines the number of pages allocated for arguments + * and envelope for the new program. 32 should suffice, this gives + * a maximum env+arg of 128kB ! + */ +#define MAX_ARG_PAGES 32 + +/* + * This structure is used to hold the arguments that are used when loading binaries. + */ +struct linux_binprm{ + char buf[128]; + unsigned long page[MAX_ARG_PAGES]; + unsigned long p; + int sh_bang; + struct inode * inode; + int e_uid, e_gid; + int argc, envc; + char * filename; /* Name of binary */ +}; + +/* + * This structure defines the functions that are used to load the binary formats that + * linux accepts. + */ +struct linux_binfmt { + struct linux_binfmt * next; + int *use_count; + int (*load_binary)(struct linux_binprm *, struct pt_regs * regs); + int (*load_shlib)(int fd); + int (*core_dump)(long signr, struct pt_regs * regs); +}; + +extern int register_binfmt(struct linux_binfmt *); +extern int unregister_binfmt(struct linux_binfmt *); + +extern int read_exec(struct inode *inode, unsigned long offset, + char * addr, unsigned long count); + +extern int open_inode(struct inode * inode, int mode); + +extern void flush_old_exec(struct linux_binprm * bprm); +extern unsigned long change_ldt(unsigned long text_size,unsigned long * page); +extern unsigned long * create_tables(char * p,int argc,int envc,int ibcs); +extern unsigned long copy_strings(int argc,char ** argv,unsigned long *page, + unsigned long p, int from_kmem); + +#endif diff --git a/include/linux/bios32.h b/include/linux/bios32.h new file mode 100644 index 000000000..4684186e5 --- /dev/null +++ b/include/linux/bios32.h @@ -0,0 +1,45 @@ +/* + * BIOS32, PCI BIOS functions and defines + * Copyright 1994, Drew Eckhardt + * + * For more information, please consult + * + * PCI BIOS Specification Revision + * PCI Local Bus Specification + * PCI System Design Guide + * + * PCI Special Interest Group + * M/S HF3-15A + * 5200 N.E. Elam Young Parkway + * Hillsboro, Oregon 97124-6497 + * +1 (503) 696-2000 + * +1 (800) 433-5177 + * + * Manuals are $25 each or $50 for all three, plus $7 shipping + * within the United States, $35 abroad. + */ + +#ifndef BIOS32_H +#define BIOS32_H + +unsigned long bios32_init(unsigned long memory_start, unsigned long memory_end); + +extern int pcibios_find_class (unsigned long class_code, unsigned short index, + unsigned char *bus, unsigned char *device_fn); +extern int pcibios_find_device (unsigned short vendor, unsigned short device_id, + unsigned short index, unsigned char *bus, unsigned char *device_fn); +extern int pcibios_read_config_byte (unsigned char bus, + unsigned char device_fn, unsigned char where, unsigned char *value); +extern int pcibios_read_config_word (unsigned char bus, + unsigned char device_fn, unsigned char where, unsigned short *value); +extern int pcibios_read_config_dword (unsigned char bus, + unsigned char device_fn, unsigned char where, unsigned long *value); +extern int pcibios_present (void); +extern int pcibios_write_config_byte (unsigned char bus, + unsigned char device_fn, unsigned char where, unsigned char value); +extern int pcibios_write_config_word (unsigned char bus, + unsigned char device_fn, unsigned char where, unsigned short value); +extern pcibios_write_config_dword (unsigned char bus, + unsigned char device_fn, unsigned char where, unsigned long value); + +#endif /* ndef BIOS32_H */ diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h new file mode 100644 index 000000000..84b48d93c --- /dev/null +++ b/include/linux/blkdev.h @@ -0,0 +1,47 @@ +#ifndef _LINUX_BLKDEV_H +#define _LINUX_BLKDEV_H + +#include <linux/major.h> +#include <linux/sched.h> +#include <linux/genhd.h> + +/* + * Ok, this is an expanded form so that we can use the same + * request for paging requests when that is implemented. In + * paging, 'bh' is NULL, and the semaphore is used to wait + * for read/write completion. + */ +struct request { + int dev; /* -1 if no request */ + int cmd; /* READ or WRITE */ + int errors; + unsigned long sector; + unsigned long nr_sectors; + unsigned long current_nr_sectors; + char * buffer; + struct semaphore * sem; + struct buffer_head * bh; + struct buffer_head * bhtail; + struct request * next; +}; + +struct blk_dev_struct { + void (*request_fn)(void); + struct request * current_request; +}; + +struct sec_size { + unsigned block_size; + unsigned block_size_bits; +}; + +extern struct sec_size * blk_sec[MAX_BLKDEV]; +extern struct blk_dev_struct blk_dev[MAX_BLKDEV]; +extern struct wait_queue * wait_for_request; +extern void resetup_one_dev(struct gendisk *dev, int drive); + +extern int * blk_size[MAX_BLKDEV]; + +extern int * blksize_size[MAX_BLKDEV]; + +#endif diff --git a/include/linux/busmouse.h b/include/linux/busmouse.h new file mode 100644 index 000000000..33c6ec7a9 --- /dev/null +++ b/include/linux/busmouse.h @@ -0,0 +1,100 @@ +#ifndef _LINUX_BUSMOUSE_H +#define _LINUX_BUSMOUSE_H + +/* + * linux/include/linux/mouse.h: header file for Logitech Bus Mouse driver + * by James Banks + * + * based on information gleamed from various mouse drivers on the net + * + * Heavily modified by David giller (rafetmad@oxy.edu) + * + * Minor modifications for Linux 0.96c-pl1 by Nathan Laredo + * gt7080a@prism.gatech.edu (13JUL92) + * + * Microsoft BusMouse support by Teemu Rantanen (tvr@cs.hut.fi) (02AUG92) + * + * Microsoft Bus Mouse support modified by Derrick Cole (cole@concert.net) + * 8/28/92 + * + * Microsoft Bus Mouse support folded into 0.97pl4 code + * by Peter Cervasio (pete%q106fm.uucp@wupost.wustl.edu) (08SEP92) + * Changes: Logitech and Microsoft support in the same kernel. + * Defined new constants in busmouse.h for MS mice. + * Added int mse_busmouse_type to distinguish busmouse types + * Added a couple of new functions to handle differences in using + * MS vs. Logitech (where the int variable wasn't appropriate). + * + */ + +#define MOUSE_IRQ 5 +#define LOGITECH_BUSMOUSE 0 /* Minor device # for Logitech */ +#define MICROSOFT_BUSMOUSE 2 /* Minor device # for Microsoft */ + +/*--------- LOGITECH BUSMOUSE ITEMS -------------*/ + +#define MSE_DATA_PORT 0x23c +#define MSE_SIGNATURE_PORT 0x23d +#define MSE_CONTROL_PORT 0x23e +#define MSE_INTERRUPT_PORT 0x23e +#define MSE_CONFIG_PORT 0x23f + +#define MSE_ENABLE_INTERRUPTS 0x00 +#define MSE_DISABLE_INTERRUPTS 0x10 + +#define MSE_READ_X_LOW 0x80 +#define MSE_READ_X_HIGH 0xa0 +#define MSE_READ_Y_LOW 0xc0 +#define MSE_READ_Y_HIGH 0xe0 + +/* Magic number used to check if the mouse exists */ +#define MSE_CONFIG_BYTE 0x91 +#define MSE_DEFAULT_MODE 0x90 +#define MSE_SIGNATURE_BYTE 0xa5 + +/* useful Logitech Mouse macros */ + +#define MSE_INT_OFF() outb(MSE_DISABLE_INTERRUPTS, MSE_CONTROL_PORT) +#define MSE_INT_ON() outb(MSE_ENABLE_INTERRUPTS, MSE_CONTROL_PORT) + +/*--------- MICROSOFT BUSMOUSE ITEMS -------------*/ + +#define MS_MSE_DATA_PORT 0x23d +#define MS_MSE_SIGNATURE_PORT 0x23e +#define MS_MSE_CONTROL_PORT 0x23c +#define MS_MSE_CONFIG_PORT 0x23f + +#define MS_MSE_ENABLE_INTERRUPTS 0x11 +#define MS_MSE_DISABLE_INTERRUPTS 0x10 + +#define MS_MSE_READ_BUTTONS 0x00 +#define MS_MSE_READ_X 0x01 +#define MS_MSE_READ_Y 0x02 + +#define MS_MSE_START 0x80 +#define MS_MSE_COMMAND_MODE 0x07 + +/* useful microsoft busmouse macros */ + +#define MS_MSE_INT_OFF() {outb(MS_MSE_COMMAND_MODE, MS_MSE_CONTROL_PORT); \ + outb(MS_MSE_DISABLE_INTERRUPTS, MS_MSE_DATA_PORT);} +#define MS_MSE_INT_ON() {outb(MS_MSE_COMMAND_MODE, MS_MSE_CONTROL_PORT); \ + outb(MS_MSE_ENABLE_INTERRUPTS, MS_MSE_DATA_PORT);} + + +struct mouse_status { + unsigned char buttons; + unsigned char latch_buttons; + int dx; + int dy; + int present; + int ready; + int active; + struct wait_queue *wait; +}; + +/* Function Prototypes */ +extern long mouse_init(long); + +#endif + diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h new file mode 100644 index 000000000..f7e7d7b5c --- /dev/null +++ b/include/linux/cdrom.h @@ -0,0 +1,392 @@ +/**************************************************************************************** + * * + * general (not only SCSI) header library for linux CDROM drivers * + * (C) 1992 David Giller rafetmad@oxy.edu * + * 1994 Eberhard Moenkeberg emoenke@gwdg.de ("read audio" and some other stuff) * + * * + * <linux/cdrom.h> -- CD-ROM IOCTLs and structs * + * * + ****************************************************************************************/ + +#ifndef _LINUX_CDROM_H +#define _LINUX_CDROM_H + +/* + * some fix numbers + */ +#define CD_MINS 74 /* max. minutes per CD */ +#define CD_SECS 60 /* seconds per minute */ +#define CD_FRAMES 75 /* frames per second */ +#define CD_CHUNK_SIZE 24 /* lowest-level "data bytes piece" */ +#define CD_NUM_OF_CHUNKS 98 /* chunks per frame */ +#define CD_FRAMESIZE 2048 /* bytes per frame, cooked mode */ +#define CD_FRAMESIZE_RAW0 2336 /* bytes per frame, "raw" mode */ +#define CD_FRAMESIZE_XA 2340 /* bytes per frame, "xa" mode */ +#define CD_FRAMESIZE_RAW 2352 /* bytes per frame, "raw" mode */ +#define CD_FRAMESIZE_SUB 96 /* subchannel data size */ +#define CD_BLOCK_OFFSET 150 /* offset of first logical frame */ +#define CD_XA_HEAD 12 /* header size of XA frame */ +#define CD_XA_TAIL 280 /* tail size of XA frame */ + +/* + * + * For IOCTL calls, we will commandeer byte 0x53, or 'S'. + * + */ + +/* + * CD-ROM-specific SCSI command opcodes + */ + +/* + * Group 2 (10-byte). All of these are called 'optional' by SCSI-II. + */ + +#define SCMD_READ_TOC 0x43 /* read table of contents */ +#define SCMD_PLAYAUDIO_MSF 0x47 /* play data at time offset */ +#define SCMD_PLAYAUDIO_TI 0x48 /* play data at track/index */ +#define SCMD_PAUSE_RESUME 0x4B /* pause/resume audio */ +#define SCMD_READ_SUBCHANNEL 0x42 /* read SC info on playing disc */ +#define SCMD_PLAYAUDIO10 0x45 /* play data at logical block */ +#define SCMD_READ_HEADER 0x44 /* read TOC header */ + +/* + * Group 5 + */ + +#define SCMD_PLAYAUDIO12 0xA5 /* play data at logical block */ +#define SCMD_PLAYTRACK_REL12 0xA9 /* play track at relative offset*/ + +/* + * Group 6 Commands + */ + +#define SCMD_CD_PLAYBACK_CONTROL 0xC9 /* Sony vendor-specific audio */ +#define SCMD_CD_PLAYBACK_STATUS 0xC4 /* control opcodes. info please!*/ + +/* + * CD-ROM capacity structure. + */ + +struct scsi_capacity + { + u_long capacity; + u_long lbasize; + }; + +/* + * CD-ROM MODE_SENSE/MODE_SELECT parameters + */ + +#define ERR_RECOVERY_PARMS 0x01 +#define DISCO_RECO_PARMS 0x02 +#define FORMAT_PARMS 0x03 +#define GEOMETRY_PARMS 0x04 +#define CERTIFICATION_PARMS 0x06 +#define CACHE_PARMS 0x38 + +/* + * standard mode-select header prepended to all mode-select commands + */ + +struct ccs_modesel_head + { + u_char _r1; /* reserved */ + u_char medium; /* device-specific medium type */ + u_char _r2; /* reserved */ + u_char block_desc_length; /* block descriptor length */ + u_char density; /* device-specific density code */ + u_char number_blocks_hi; /* number of blocks in this block desc */ + u_char number_blocks_med; + u_char number_blocks_lo; + u_char _r3; + u_char block_length_hi; /* block length for blocks in this desc */ + u_short block_length; + }; + +/* + * error recovery parameters + */ + +struct ccs_err_recovery + { + u_char _r1 : 2; /* reserved */ + u_char page_code : 6; /* page code */ + u_char page_length; /* page length */ + u_char awre : 1; /* auto write realloc enabled */ + u_char arre : 1; /* auto read realloc enabled */ + u_char tb : 1; /* transfer block */ + u_char rc : 1; /* read continuous */ + u_char eec : 1; /* enable early correction */ + u_char per : 1; /* post error */ + u_char dte : 1; /* disable transfer on error */ + u_char dcr : 1; /* disable correction */ + u_char retry_count; /* error retry count */ + u_char correction_span; /* largest recov. to be attempted, bits */ + u_char head_offset_count; /* head offset (2's C) for each retry */ + u_char strobe_offset_count; /* data strobe " */ + u_char recovery_time_limit; /* time limit on recovery attempts */ +}; + +/* + * disco/reco parameters + */ + +struct ccs_disco_reco + { + u_char _r1 : 2; /* reserved */ + u_char page_code : 6; /* page code */ + u_char page_length; /* page length */ + u_char buffer_full_ratio; /* write buffer reconnect threshold */ + u_char buffer_empty_ratio; /* read " */ + u_short bus_inactivity_limit; /* limit on bus inactivity time */ + u_short disconnect_time_limit; /* minimum disconnect time */ + u_short connect_time_limit; /* minimum connect time */ + u_short _r2; /* reserved */ +}; + +/* + * drive geometry parameters + */ + +struct ccs_geometry + { + u_char _r1 : 2; /* reserved */ + u_char page_code : 6; /* page code */ + u_char page_length; /* page length */ + u_char cyl_ub; /* #cyls */ + u_char cyl_mb; + u_char cyl_lb; + u_char heads; /* #heads */ + u_char precomp_cyl_ub; /* precomp start */ + u_char precomp_cyl_mb; + u_char precomp_cyl_lb; + u_char current_cyl_ub; /* reduced current start */ + u_char current_cyl_mb; + u_char current_cyl_lb; + u_short step_rate; /* stepping motor rate */ + u_char landing_cyl_ub; /* landing zone */ + u_char landing_cyl_mb; + u_char landing_cyl_lb; + u_char _r2; + u_char _r3; + u_char _r4; + }; + +/* + * cache parameters + */ + +struct ccs_cache + { + u_char _r1 : 2; /* reserved */ + u_char page_code : 6; /* page code */ + u_char page_length; /* page length */ + u_char mode; /* cache control byte */ + u_char threshold; /* prefetch threshold */ + u_char max_prefetch; /* maximum prefetch size */ + u_char max_multiplier; /* maximum prefetch multiplier */ + u_char min_prefetch; /* minimum prefetch size */ + u_char min_multiplier; /* minimum prefetch multiplier */ + u_char _r2[8]; + }; + +/* + * CDROM IOCTL structures + */ + +struct cdrom_msf + { + u_char cdmsf_min0; /* start minute */ + u_char cdmsf_sec0; /* start second */ + u_char cdmsf_frame0; /* start frame */ + u_char cdmsf_min1; /* end minute */ + u_char cdmsf_sec1; /* end second */ + u_char cdmsf_frame1; /* end frame */ + }; + +struct cdrom_ti + { + u_char cdti_trk0; /* start track */ + u_char cdti_ind0; /* start index */ + u_char cdti_trk1; /* end track */ + u_char cdti_ind1; /* end index */ + }; + +struct cdrom_tochdr + { + u_char cdth_trk0; /* start track */ + u_char cdth_trk1; /* end track */ + }; + +struct cdrom_tocentry + { + u_char cdte_track; + u_char cdte_adr :4; + u_char cdte_ctrl :4; + u_char cdte_format; + union + { + struct + { + u_char minute; + u_char second; + u_char frame; + } msf; + int lba; + } cdte_addr; + u_char cdte_datamode; + }; + +/* + * CD-ROM address types (cdrom_tocentry.cdte_format) + */ +#define CDROM_LBA 0x01 /* "logical block": first frame is #0 */ +#define CDROM_MSF 0x02 /* "minute-second-frame": binary, not bcd here! */ + +/* + * bit to tell whether track is data or audio + */ + +#define CDROM_DATA_TRACK 0x04 + +/* + * The leadout track is always 0xAA, regardless of # of tracks on disc + */ + +#define CDROM_LEADOUT 0xAA + +struct cdrom_subchnl + { + u_char cdsc_format; + u_char cdsc_audiostatus; + u_char cdsc_adr: 4; + u_char cdsc_ctrl: 4; + u_char cdsc_trk; + u_char cdsc_ind; + union + { + struct + { + u_char minute; + u_char second; + u_char frame; + } msf; + int lba; + } cdsc_absaddr; + union + { + struct + { + u_char minute; + u_char second; + u_char frame; + } msf; + int lba; + } cdsc_reladdr; + }; + +/* + * return value from READ SUBCHANNEL DATA + */ + +#define CDROM_AUDIO_INVALID 0x00 /* audio status not supported */ +#define CDROM_AUDIO_PLAY 0x11 /* audio play operation in progress */ +#define CDROM_AUDIO_PAUSED 0x12 /* audio play operation paused */ +#define CDROM_AUDIO_COMPLETED 0x13 /* audio play successfully completed */ +#define CDROM_AUDIO_ERROR 0x14 /* audio play stopped due to error */ +#define CDROM_AUDIO_NO_STATUS 0x15 /* no current audio status to return */ + +struct cdrom_volctrl + { + u_char channel0; + u_char channel1; + u_char channel2; + u_char channel3; + }; + +struct cdrom_read + { + int cdread_lba; + caddr_t cdread_bufaddr; + int cdread_buflen; + }; + +/* + * preliminary extensions for transferring audio frames + * currently used by sbpcd.c + * (still may change if other drivers will use it, too): + */ +struct cdrom_read_audio + { + union + { + struct + { + u_char minute; + u_char second; + u_char frame; + } msf; + int lba; + } addr; /* frame address */ + u_char addr_format; /* CDROM_LBA or CDROM_MSF */ + int nframes; /* number of 2352-byte-frames to read at once, limited by the drivers */ + u_char *buf; /* frame buffer (size: nframes*2352 bytes) */ + }; + +#ifdef FIVETWELVE +#define CDROM_MODE1_SIZE 512 +#else +#define CDROM_MODE1_SIZE 2048 +#endif FIVETWELVE +#define CDROM_MODE2_SIZE 2336 + +/* + * CD-ROM IOCTL commands + */ + +#define CDROMPAUSE 0x5301 /* pause */ +#define CDROMRESUME 0x5302 /* resume */ + +#define CDROMPLAYMSF 0x5303 /* (struct cdrom_msf) */ + /* SCMD_PLAY_AUDIO_MSF */ + +#define CDROMPLAYTRKIND 0x5304 /* (struct cdrom_ti) */ + /* SCMD_PLAY_AUDIO_TI */ + +#define CDROMREADTOCHDR 0x5305 /* (struct cdrom_tochdr) */ + /* read the TOC header */ +#define CDROMREADTOCENTRY 0x5306 /* (struct cdrom_tocentry) */ + /* read a TOC entry */ + +#define CDROMSTOP 0x5307 /* stop the drive motor */ +#define CDROMSTART 0x5308 /* turn the motor on */ + +#define CDROMEJECT 0x5309 /* eject CD-ROM media */ + +#define CDROMVOLCTRL 0x530a /* (struct cdrom_volctrl) */ + /* volume control */ + +#define CDROMSUBCHNL 0x530b /* (struct cdrom_subchnl) */ + /* read Q sub-channel data */ + +#define CDROMREADMODE2 0x530c /* (struct cdrom_read) */ + /* read type-2 data (not suppt) */ + +#define CDROMREADMODE1 0x530d /* (struct cdrom_read) */ + /* read type-1 data */ +/* + * preliminary extension for transferring audio frames + * currently used by cdu31a.c and sbpcd.c + * (still may change if other drivers will use it, too): + */ +#define CDROMREADAUDIO 0x530e /* (struct cdrom_read_audio) */ +/* + * preliminary extension for enable (1) / disable (0) auto-ejecting + * currently used by sbpcd.c + * (still may change if other drivers will use it, too): + */ +#define CDROMEJECT_SW 0x530f /* arg: 0 or 1 */ + +#endif _LINUX_CDROM_H + diff --git a/include/linux/cdu31a.h b/include/linux/cdu31a.h new file mode 100644 index 000000000..fc1150fef --- /dev/null +++ b/include/linux/cdu31a.h @@ -0,0 +1,382 @@ +/* + * Definitions for a Sony interface CDROM drive. + * + * Corey Minyard (minyard@wf-rch.cirr.com) + * + * Copyright (C) 1993 Corey Minyard + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +/* + * General defines. + */ +#define SONY_XA_DISK_TYPE 0x20 + +/* + * Offsets (from the base address) and bits for the various write registers + * of the drive. + */ +#define SONY_CMD_REG_OFFSET 0 +#define SONY_PARAM_REG_OFFSET 1 +#define SONY_WRITE_REG_OFFSET 2 +#define SONY_CONTROL_REG_OFFSET 3 +# define SONY_ATTN_CLR_BIT 0x01 +# define SONY_RES_RDY_CLR_BIT 0x02 +# define SONY_DATA_RDY_CLR_BIT 0x04 +# define SONY_ATTN_INT_EN_BIT 0x08 +# define SONY_RES_RDY_INT_EN_BIT 0x10 +# define SONY_DATA_RDY_INT_EN_BIT 0x20 +# define SONY_PARAM_CLR_BIT 0x40 +# define SONY_DRIVE_RESET_BIT 0x80 + +/* + * Offsets (from the base address) and bits for the various read registers + * of the drive. + */ +#define SONY_STATUS_REG_OFFSET 0 +# define SONY_ATTN_BIT 0x01 +# define SONY_RES_RDY_BIT 0x02 +# define SONY_DATA_RDY_BIT 0x04 +# define SONY_ATTN_INT_ST_BIT 0x08 +# define SONY_RES_RDY_INT_ST_BIT 0x10 +# define SONY_DATA_RDY_INT_ST_BIT 0x20 +# define SONY_DATA_REQUEST_BIT 0x40 +# define SONY_BUSY_BIT 0x80 +#define SONY_RESULT_REG_OFFSET 1 +#define SONY_READ_REG_OFFSET 2 +#define SONY_FIFOST_REG_OFFSET 3 +# define SONY_PARAM_WRITE_RDY_BIT 0x01 +# define SONY_PARAM_REG_EMPTY_BIT 0x02 +# define SONY_RES_REG_NOT_EMP_BIT 0x04 +# define SONY_RES_REG_FULL_BIT 0x08 + +#define LOG_START_OFFSET 150 /* Offset of first logical sector */ + +#define SONY_DETECT_TIMEOUT 80 /* Maximum amount of time + that drive detection code + will wait for response + from drive (in 1/100th's + of seconds). */ + +#define SONY_JIFFIES_TIMEOUT 1000 /* Maximum number of times the + drive will wait/try for an + operation */ +#define SONY_RESET_TIMEOUT 100 /* Maximum number of times the + drive will wait/try a reset + operation */ +#define SONY_READY_RETRIES 20000 /* How many times to retry a + spin waiting for a register + to come ready */ + +#define MAX_CDU31A_RETRIES 3 /* How many times to retry an + operation */ + +/* Commands to request or set drive control parameters and disc information */ +#define SONY_REQ_DRIVE_CONFIG_CMD 0x00 /* Returns s_sony_drive_config */ +#define SONY_REQ_DRIVE_MODE_CMD 0x01 +#define SONY_REQ_DRIVE_PARAM_CMD 0x02 +#define SONY_REQ_MECH_STATUS_CMD 0x03 +#define SONY_REQ_AUDIO_STATUS_CMD 0x04 +#define SONY_SET_DRIVE_PARAM_CMD 0x10 +#define SONY_REQ_TOC_DATA_CMD 0x20 /* Returns s_sony_toc */ +#define SONY_REQ_SUBCODE_ADDRESS_CMD 0x21 /* Returns s_sony_subcode */ +#define SONY_REQ_UPC_EAN_CMD 0x22 +#define SONY_REQ_ISRC_CMD 0x23 +#define SONY_REQ_TOC_DATA_SPEC_CMD 0x24 + +/* Commands to request information from the drive */ +#define SONY_READ_TOC_CMD 0x30 +#define SONY_SEEK_CMD 0x31 +#define SONY_READ_CMD 0x32 +#define SONY_READ_BLKERR_STAT_CMD 0x34 +#define SONY_ABORT_CMD 0x35 +#define SONY_READ_TOC_SPEC_CMD 0x36 + +/* Commands to control audio */ +#define SONY_AUDIO_PLAYBACK_CMD 0x40 +#define SONY_AUDIO_STOP_CMD 0x41 +#define SONY_AUDIO_SCAN_CMD 0x42 + +/* Miscellaneous control commands */ +#define SONY_EJECT_CMD 0x50 +#define SONY_SPIN_UP_CMD 0x51 +#define SONY_SPIN_DOWN_CMD 0x52 + +/* Diagnostic commands */ +#define SONY_WRITE_BUFFER_CMD 0x60 +#define SONY_READ_BUFFER_CMD 0x61 +#define SONY_DIAGNOSTICS_CMD 0x62 + + +/* + * The following are command parameters for the set drive parameter command + */ +#define SONY_SD_DECODE_PARAM 0x00 +#define SONY_SD_INTERFACE_PARAM 0x01 +#define SONY_SD_BUFFERING_PARAM 0x02 +#define SONY_SD_AUDIO_PARAM 0x03 +#define SONY_SD_AUDIO_VOLUME 0x04 +#define SONY_SD_MECH_CONTROL 0x05 +#define SONY_SD_AUTO_SPIN_DOWN_TIME 0x06 + +/* + * The following extract information from the drive configuration about + * the drive itself. + */ +#define SONY_HWC_GET_LOAD_MECH(c) (c.hw_config[0] & 0x03) +#define SONY_HWC_EJECT(c) (c.hw_config[0] & 0x04) +#define SONY_HWC_LED_SUPPORT(c) (c.hw_config[0] & 0x08) +#define SONY_HWC_DOUBLE_SPEED(c) (c.hw_config[0] & 0x10) +#define SONY_HWC_GET_BUF_MEM_SIZE(c) ((c.hw_config[0] & 0xc0) >> 6) +#define SONY_HWC_AUDIO_PLAYBACK(c) (c.hw_config[1] & 0x01) +#define SONY_HWC_ELECTRIC_VOLUME(c) (c.hw_config[1] & 0x02) +#define SONY_HWC_ELECTRIC_VOLUME_CTL(c) (c.hw_config[1] & 0x04) + +#define SONY_HWC_CADDY_LOAD_MECH 0x00 +#define SONY_HWC_TRAY_LOAD_MECH 0x01 +#define SONY_HWC_POPUP_LOAD_MECH 0x02 +#define SONY_HWC_UNKWN_LOAD_MECH 0x03 + +#define SONY_HWC_8KB_BUFFER 0x00 +#define SONY_HWC_32KB_BUFFER 0x01 +#define SONY_HWC_64KB_BUFFER 0x02 +#define SONY_HWC_UNKWN_BUFFER 0x03 + +/* + * This is the complete status returned from the drive configuration request + * command. + */ +struct s_sony_drive_config +{ + unsigned char exec_status[2]; + char vendor_id[8]; + char product_id[16]; + char product_rev_level[8]; + unsigned char hw_config[2]; +}; + +/* The following is returned from the request subcode address command */ +struct s_sony_subcode +{ + unsigned char exec_status[2]; + unsigned char address :4; + unsigned char control :4; + unsigned char track_num; + unsigned char index_num; + unsigned char rel_msf[3]; + unsigned char reserved1; + unsigned char abs_msf[3]; +}; + +#define MAX_TRACKS 100 /* The maximum tracks a disk may have. */ +/* + * The following is returned from the request TOC (Table Of Contents) command. + * (last_track_num-first_track_num+1) values are valid in tracks. + */ +struct s_sony_toc +{ + unsigned char exec_status[2]; + unsigned char address0 :4; + unsigned char control0 :4; + unsigned char point0; + unsigned char first_track_num; + unsigned char disk_type; + unsigned char dummy0; + unsigned char address1 :4; + unsigned char control1 :4; + unsigned char point1; + unsigned char last_track_num; + unsigned char dummy1; + unsigned char dummy2; + unsigned char address2 :4; + unsigned char control2 :4; + unsigned char point2; + unsigned char lead_out_start_msf[3]; + struct + { + unsigned char address :4; + unsigned char control :4; + unsigned char track; + unsigned char track_start_msf[3]; + } tracks[MAX_TRACKS]; + + unsigned int lead_out_start_lba; +}; + +struct s_sony_session_toc +{ + unsigned char exec_status[2]; + unsigned char session_number; + unsigned char address0 :4; + unsigned char control0 :4; + unsigned char point0; + unsigned char first_track_num; + unsigned char disk_type; + unsigned char dummy0; + unsigned char address1 :4; + unsigned char control1 :4; + unsigned char point1; + unsigned char last_track_num; + unsigned char dummy1; + unsigned char dummy2; + unsigned char address2 :4; + unsigned char control2 :4; + unsigned char point2; + unsigned char lead_out_start_msf[3]; + unsigned char addressb0 :4; + unsigned char controlb0 :4; + unsigned char pointb0; + unsigned char next_poss_prog_area_msf[3]; + unsigned char num_mode_5_pointers; + unsigned char max_start_outer_leadout_msf[3]; + unsigned char addressb1 :4; + unsigned char controlb1 :4; + unsigned char pointb1; + unsigned char dummyb0_1[4]; + unsigned char num_skip_interval_pointers; + unsigned char num_skip_track_assignments; + unsigned char dummyb0_2; + unsigned char addressb2 :4; + unsigned char controlb2 :4; + unsigned char pointb2; + unsigned char tracksb2[7]; + unsigned char addressb3 :4; + unsigned char controlb3 :4; + unsigned char pointb3; + unsigned char tracksb3[7]; + unsigned char addressb4 :4; + unsigned char controlb4 :4; + unsigned char pointb4; + unsigned char tracksb4[7]; + unsigned char addressc0 :4; + unsigned char controlc0 :4; + unsigned char pointc0; + unsigned char dummyc0[7]; + struct + { + unsigned char address :4; + unsigned char control :4; + unsigned char track; + unsigned char track_start_msf[3]; + } tracks[MAX_TRACKS]; + + unsigned int start_track_lba; + unsigned int lead_out_start_lba; +}; + + +/* + * The following are errors returned from the drive. + */ + +/* Command error group */ +#define SONY_ILL_CMD_ERR 0x10 +#define SONY_ILL_PARAM_ERR 0x11 + +/* Mechanism group */ +#define SONY_NOT_LOAD_ERR 0x20 +#define SONY_NO_DISK_ERR 0x21 +#define SONY_NOT_SPIN_ERR 0x22 +#define SONY_SPIN_ERR 0x23 +#define SONY_SPINDLE_SERVO_ERR 0x25 +#define SONY_FOCUS_SERVO_ERR 0x26 +#define SONY_EJECT_MECH_ERR 0x29 +#define SONY_AUDIO_PLAYING_ERR 0x2a +#define SONY_EMERGENCY_EJECT_ERR 0x2c + +/* Seek error group */ +#define SONY_FOCUS_ERR 0x30 +#define SONY_FRAME_SYNC_ERR 0x31 +#define SONY_SUBCODE_ADDR_ERR 0x32 +#define SONY_BLOCK_SYNC_ERR 0x33 +#define SONY_HEADER_ADDR_ERR 0x34 + +/* Read error group */ +#define SONY_ILL_TRACK_R_ERR 0x40 +#define SONY_MODE_0_R_ERR 0x41 +#define SONY_ILL_MODE_R_ERR 0x42 +#define SONY_ILL_BLOCK_SIZE_R_ERR 0x43 +#define SONY_MODE_R_ERR 0x44 +#define SONY_FORM_R_ERR 0x45 +#define SONY_LEAD_OUT_R_ERR 0x46 +#define SONY_BUFFER_OVERRUN_R_ERR 0x47 + +/* Data error group */ +#define SONY_UNREC_CIRC_ERR 0x53 +#define SONY_UNREC_LECC_ERR 0x57 + +/* Subcode error group */ +#define SONY_NO_TOC_ERR 0x60 +#define SONY_SUBCODE_DATA_NVAL_ERR 0x61 +#define SONY_FOCUS_ON_TOC_READ_ERR 0x63 +#define SONY_FRAME_SYNC_ON_TOC_READ_ERR 0x64 +#define SONY_TOC_DATA_ERR 0x65 + +/* Hardware failure group */ +#define SONY_HW_FAILURE_ERR 0x70 +#define SONY_LEAD_IN_A_ERR 0x91 +#define SONY_LEAD_OUT_A_ERR 0x92 +#define SONY_DATA_TRACK_A_ERR 0x93 + +/* + * The following are returned from the Read With Block Error Status command. + * They are not errors but information (Errors from the 0x5x group above may + * also be returned + */ +#define SONY_NO_CIRC_ERR_BLK_STAT 0x50 +#define SONY_NO_LECC_ERR_BLK_STAT 0x54 +#define SONY_RECOV_LECC_ERR_BLK_STAT 0x55 +#define SONY_NO_ERR_DETECTION_STAT 0x59 + +/* + * The following is not an error returned by the drive, but by the code + * that talks to the drive. It is returned because of a timeout. + */ +#define SONY_TIMEOUT_OP_ERR 0x01 +#define SONY_SIGNAL_OP_ERR 0x02 +#define SONY_BAD_DATA_ERR 0x03 + + +/* + * The following are attention code for asynchronous events from the drive. + */ + +/* Standard attention group */ +#define SONY_EMER_EJECT_ATTN 0x2c +#define SONY_HW_FAILURE_ATTN 0x70 +#define SONY_MECH_LOADED_ATTN 0x80 +#define SONY_EJECT_PUSHED_ATTN 0x81 + +/* Audio attention group */ +#define SONY_AUDIO_PLAY_DONE_ATTN 0x90 +#define SONY_LEAD_IN_ERR_ATTN 0x91 +#define SONY_LEAD_OUT_ERR_ATTN 0x92 +#define SONY_DATA_TRACK_ERR_ATTN 0x93 +#define SONY_AUDIO_PLAYBACK_ERR_ATTN 0x94 + +/* Auto spin up group */ +#define SONY_SPIN_UP_COMPLETE_ATTN 0x24 +#define SONY_SPINDLE_SERVO_ERR_ATTN 0x25 +#define SONY_FOCUS_SERVO_ERR_ATTN 0x26 +#define SONY_TOC_READ_DONE_ATTN 0x62 +#define SONY_FOCUS_ON_TOC_READ_ERR_ATTN 0x63 +#define SONY_SYNC_ON_TOC_READ_ERR_ATTN 0x65 + +/* Auto eject group */ +#define SONY_SPIN_DOWN_COMPLETE_ATTN 0x27 +#define SONY_EJECT_COMPLETE_ATTN 0x28 +#define SONY_EJECT_MECH_ERR_ATTN 0x29 diff --git a/include/linux/coff.h b/include/linux/coff.h new file mode 100644 index 000000000..a1ba46668 --- /dev/null +++ b/include/linux/coff.h @@ -0,0 +1,351 @@ +/* This file is derived from the GAS 2.1.4 assembler control file. + The GAS product is under the GNU Public License, version 2 or later. + As such, this file is also under that license. + + If the file format changes in the COFF object, this file should be + subsequently updated to reflect the changes. + + The actual loader module only uses a few of these structures. The full + set is documented here because I received the full set. If you wish + more information about COFF, then O'Reilly has a very excellent book. +*/ + +#define E_SYMNMLEN 8 /* Number of characters in a symbol name */ +#define E_FILNMLEN 14 /* Number of characters in a file name */ +#define E_DIMNUM 4 /* Number of array dimensions in auxiliary entry */ + +/* + * These defines are byte order independent. There is no alignment of fields + * permitted in the structures. Therefore they are declared as characters + * and the values loaded from the character positions. It also makes it + * nice to have it "endian" independent. + */ + +/* Load a short int from the following tables with little-endian formats */ +#define COFF_SHORT_L(ps) ((short)(((unsigned short)((unsigned char)ps[1])<<8)|\ + ((unsigned short)((unsigned char)ps[0])))) + +/* Load a long int from the following tables with little-endian formats */ +#define COFF_LONG_L(ps) (((long)(((unsigned long)((unsigned char)ps[3])<<24) |\ + ((unsigned long)((unsigned char)ps[2])<<16) |\ + ((unsigned long)((unsigned char)ps[1])<<8) |\ + ((unsigned long)((unsigned char)ps[0]))))) + +/* Load a short int from the following tables with big-endian formats */ +#define COFF_SHORT_H(ps) ((short)(((unsigned short)((unsigned char)ps[0])<<8)|\ + ((unsigned short)((unsigned char)ps[1])))) + +/* Load a long int from the following tables with big-endian formats */ +#define COFF_LONG_H(ps) (((long)(((unsigned long)((unsigned char)ps[0])<<24) |\ + ((unsigned long)((unsigned char)ps[1])<<16) |\ + ((unsigned long)((unsigned char)ps[2])<<8) |\ + ((unsigned long)((unsigned char)ps[3]))))) + +/* These may be overridden later by brain dead implementations which generate + a big-endian header with little-endian data. In that case, generate a + replacement macro which tests a flag and uses either of the two above + as appropriate. */ + +#define COFF_LONG(v) COFF_LONG_L(v) +#define COFF_SHORT(v) COFF_SHORT_L(v) + +/*** coff information for Intel 386/486. */ + +/********************** FILE HEADER **********************/ + +struct COFF_filehdr { + char f_magic[2]; /* magic number */ + char f_nscns[2]; /* number of sections */ + char f_timdat[4]; /* time & date stamp */ + char f_symptr[4]; /* file pointer to symtab */ + char f_nsyms[4]; /* number of symtab entries */ + char f_opthdr[2]; /* sizeof(optional hdr) */ + char f_flags[2]; /* flags */ +}; + +/* + * Bits for f_flags: + * + * F_RELFLG relocation info stripped from file + * F_EXEC file is executable (i.e. no unresolved external + * references) + * F_LNNO line numbers stripped from file + * F_LSYMS local symbols stripped from file + * F_MINMAL this is a minimal object file (".m") output of fextract + * F_UPDATE this is a fully bound update file, output of ogen + * F_SWABD this file has had its bytes swabbed (in names) + * F_AR16WR this file has the byte ordering of an AR16WR + * (e.g. 11/70) machine + * F_AR32WR this file has the byte ordering of an AR32WR machine + * (e.g. vax and iNTEL 386) + * F_AR32W this file has the byte ordering of an AR32W machine + * (e.g. 3b,maxi) + * F_PATCH file contains "patch" list in optional header + * F_NODF (minimal file only) no decision functions for + * replaced functions + */ + +#define COFF_F_RELFLG 0000001 +#define COFF_F_EXEC 0000002 +#define COFF_F_LNNO 0000004 +#define COFF_F_LSYMS 0000010 +#define COFF_F_MINMAL 0000020 +#define COFF_F_UPDATE 0000040 +#define COFF_F_SWABD 0000100 +#define COFF_F_AR16WR 0000200 +#define COFF_F_AR32WR 0000400 +#define COFF_F_AR32W 0001000 +#define COFF_F_PATCH 0002000 +#define COFF_F_NODF 0002000 + +#define COFF_I386MAGIC 0x14c /* Linux's system */ + +#if 0 /* Perhaps, someday, these formats may be used. */ +#define COFF_I386PTXMAGIC 0x154 +#define COFF_I386AIXMAGIC 0x175 /* IBM's AIX system */ +#define COFF_I386BADMAG(x) ((COFF_SHORT((x).f_magic) != COFF_I386MAGIC) \ + && COFF_SHORT((x).f_magic) != COFF_I386PTXMAGIC \ + && COFF_SHORT((x).f_magic) != COFF_I386AIXMAGIC) +#else +#define COFF_I386BADMAG(x) (COFF_SHORT((x).f_magic) != COFF_I386MAGIC) +#endif + +#define COFF_FILHDR struct COFF_filehdr +#define COFF_FILHSZ sizeof(COFF_FILHDR) + +/********************** AOUT "OPTIONAL HEADER" **********************/ + +/* Linux COFF must have this "optional" header. Standard COFF has no entry + location for the "entry" point. They normally would start with the first + location of the .text section. This is not a good idea for linux. So, + the use of this "optional" header is not optional. It is required. + + Do not be tempted to assume that the size of the optional header is + a constant and simply index the next byte by the size of this structure. + Use the 'f_opthdr' field in the main coff header for the size of the + structure actually written to the file!! +*/ + +typedef struct +{ + char magic[2]; /* type of file */ + char vstamp[2]; /* version stamp */ + char tsize[4]; /* text size in bytes, padded to FW bdry */ + char dsize[4]; /* initialized data " " */ + char bsize[4]; /* uninitialized data " " */ + char entry[4]; /* entry pt. */ + char text_start[4]; /* base of text used for this file */ + char data_start[4]; /* base of data used for this file */ +} +COFF_AOUTHDR; + +#define COFF_AOUTSZ (sizeof(COFF_AOUTHDR)) + +#define COFF_STMAGIC 0401 +#define COFF_OMAGIC 0404 +#define COFF_JMAGIC 0407 /* dirty text and data image, can't share */ +#define COFF_DMAGIC 0410 /* dirty text segment, data aligned */ +#define COFF_ZMAGIC 0413 /* The proper magic number for executables */ +#define COFF_SHMAGIC 0443 /* shared library header */ + +/********************** SECTION HEADER **********************/ + +struct COFF_scnhdr { + char s_name[8]; /* section name */ + char s_paddr[4]; /* physical address, aliased s_nlib */ + char s_vaddr[4]; /* virtual address */ + char s_size[4]; /* section size */ + char s_scnptr[4]; /* file ptr to raw data for section */ + char s_relptr[4]; /* file ptr to relocation */ + char s_lnnoptr[4]; /* file ptr to line numbers */ + char s_nreloc[2]; /* number of relocation entries */ + char s_nlnno[2]; /* number of line number entries */ + char s_flags[4]; /* flags */ +}; + +#define COFF_SCNHDR struct COFF_scnhdr +#define COFF_SCNHSZ sizeof(COFF_SCNHDR) + +/* + * names of "special" sections + */ + +#define COFF_TEXT ".text" +#define COFF_DATA ".data" +#define COFF_BSS ".bss" +#define COFF_COMMENT ".comment" +#define COFF_LIB ".lib" + +#define COFF_SECT_TEXT 0 /* Section for instruction code */ +#define COFF_SECT_DATA 1 /* Section for initialized globals */ +#define COFF_SECT_BSS 2 /* Section for un-initialized globals */ +#define COFF_SECT_REQD 3 /* Minimum number of sections for good file */ + +#define COFF_STYP_REG 0x00 /* regular segment */ +#define COFF_STYP_DSECT 0x01 /* dummy segment */ +#define COFF_STYP_NOLOAD 0x02 /* no-load segment */ +#define COFF_STYP_GROUP 0x04 /* group segment */ +#define COFF_STYP_PAD 0x08 /* .pad segment */ +#define COFF_STYP_COPY 0x10 /* copy section */ +#define COFF_STYP_TEXT 0x20 /* .text segment */ +#define COFF_STYP_DATA 0x40 /* .data segment */ +#define COFF_STYP_BSS 0x80 /* .bss segment */ +#define COFF_STYP_INFO 0x200 /* .comment section */ +#define COFF_STYP_OVER 0x400 /* overlay section */ +#define COFF_STYP_LIB 0x800 /* library section */ + +/* + * Shared libraries have the following section header in the data field for + * each library. + */ + +struct COFF_slib { + char sl_entsz[4]; /* Size of this entry */ + char sl_pathndx[4]; /* size of the header field */ +}; + +#define COFF_SLIBHD struct COFF_slib +#define COFF_SLIBSZ sizeof(COFF_SLIBHD) + +/********************** LINE NUMBERS **********************/ + +/* 1 line number entry for every "breakpointable" source line in a section. + * Line numbers are grouped on a per function basis; first entry in a function + * grouping will have l_lnno = 0 and in place of physical address will be the + * symbol table index of the function name. + */ + +struct COFF_lineno { + union { + char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/ + char l_paddr[4]; /* (physical) address of line number */ + } l_addr; + char l_lnno[2]; /* line number */ +}; + +#define COFF_LINENO struct COFF_lineno +#define COFF_LINESZ 6 + +/********************** SYMBOLS **********************/ + +#define COFF_E_SYMNMLEN 8 /* # characters in a short symbol name */ +#define COFF_E_FILNMLEN 14 /* # characters in a file name */ +#define COFF_E_DIMNUM 4 /* # array dimensions in auxiliary entry */ + +/* + * All symbols and sections have the following definition + */ + +struct COFF_syment +{ + union { + char e_name[E_SYMNMLEN]; /* Symbol name (first 8 characters) */ + struct { + char e_zeroes[4]; /* Leading zeros */ + char e_offset[4]; /* Offset if this is a header section */ + } e; + } e; + + char e_value[4]; /* Value (address) of the segment */ + char e_scnum[2]; /* Section number */ + char e_type[2]; /* Type of section */ + char e_sclass[1]; /* Loader class */ + char e_numaux[1]; /* Number of auxiliary entries which follow */ +}; + +#define COFF_N_BTMASK (0xf) /* Mask for important class bits */ +#define COFF_N_TMASK (0x30) /* Mask for important type bits */ +#define COFF_N_BTSHFT (4) /* # bits to shift class field */ +#define COFF_N_TSHIFT (2) /* # bits to shift type field */ + +/* + * Auxiliary entries because the main table is too limiting. + */ + +union COFF_auxent { + +/* + * Debugger information + */ + + struct { + char x_tagndx[4]; /* str, un, or enum tag indx */ + union { + struct { + char x_lnno[2]; /* declaration line number */ + char x_size[2]; /* str/union/array size */ + } x_lnsz; + char x_fsize[4]; /* size of function */ + } x_misc; + + union { + struct { /* if ISFCN, tag, or .bb */ + char x_lnnoptr[4]; /* ptr to fcn line # */ + char x_endndx[4]; /* entry ndx past block end */ + } x_fcn; + + struct { /* if ISARY, up to 4 dimen. */ + char x_dimen[E_DIMNUM][2]; + } x_ary; + } x_fcnary; + + char x_tvndx[2]; /* tv index */ + } x_sym; + +/* + * Source file names (debugger information) + */ + + union { + char x_fname[E_FILNMLEN]; + struct { + char x_zeroes[4]; + char x_offset[4]; + } x_n; + } x_file; + +/* + * Section information + */ + + struct { + char x_scnlen[4]; /* section length */ + char x_nreloc[2]; /* # relocation entries */ + char x_nlinno[2]; /* # line numbers */ + } x_scn; + +/* + * Transfer vector (branch table) + */ + + struct { + char x_tvfill[4]; /* tv fill value */ + char x_tvlen[2]; /* length of .tv */ + char x_tvran[2][2]; /* tv range */ + } x_tv; /* info about .tv section (in auxent of symbol .tv)) */ +}; + +#define COFF_SYMENT struct COFF_syment +#define COFF_SYMESZ 18 +#define COFF_AUXENT union COFF_auxent +#define COFF_AUXESZ 18 + +#define COFF_ETEXT "etext" + +/********************** RELOCATION DIRECTIVES **********************/ + +struct COFF_reloc { + char r_vaddr[4]; /* Virtual address of item */ + char r_symndx[4]; /* Symbol index in the symtab */ + char r_type[2]; /* Relocation type */ +}; + +#define COFF_RELOC struct COFF_reloc +#define COFF_RELSZ 10 + +#define COFF_DEF_DATA_SECTION_ALIGNMENT 4 +#define COFF_DEF_BSS_SECTION_ALIGNMENT 4 +#define COFF_DEF_TEXT_SECTION_ALIGNMENT 4 + +/* For new sections we haven't heard of before */ +#define COFF_DEF_SECTION_ALIGNMENT 4 diff --git a/include/linux/config.h b/include/linux/config.h new file mode 100644 index 000000000..a22241e91 --- /dev/null +++ b/include/linux/config.h @@ -0,0 +1,91 @@ +#ifndef _LINUX_CONFIG_H +#define _LINUX_CONFIG_H + +#include <linux/autoconf.h> + +/* + * Defines for what uname() should return + */ +#ifndef UTS_SYSNAME +#define UTS_SYSNAME "Linux" +#endif +#ifndef UTS_NODENAME +#define UTS_NODENAME "(none)" /* set by sethostname() */ +#endif + +#ifndef UTS_MACHINE +#define UTS_MACHINE "i386" /* hardware type */ +#endif + +#ifndef UTS_DOMAINNAME +#define UTS_DOMAINNAME "(none)" /* set by setdomainname() */ +#endif + +/* + * The definitions for UTS_RELEASE and UTS_VERSION are now defined + * in linux/version.h, and should only be used by linux/version.c + */ + +/* Don't touch these, unless you really know what your doing. */ +#define DEF_INITSEG 0x9000 +#define DEF_SYSSEG 0x1000 +#define DEF_SETUPSEG 0x9020 +#define DEF_SYSSIZE 0x7F00 + +/* internal svga startup constants */ +#define NORMAL_VGA 0xffff /* 80x25 mode */ +#define EXTENDED_VGA 0xfffe /* 80x50 mode */ +#define ASK_VGA 0xfffd /* ask for it at bootup */ + +/* + * The root-device is no longer hard-coded. You can change the default + * root-device by changing the line ROOT_DEV = XXX in boot/bootsect.s + */ + +/* + * The keyboard is now defined in kernel/chr_dev/keyboard.S + */ + +/* + * Normally, Linux can get the drive parameters from the BIOS at + * startup, but if this for some unfathomable reason fails, you'd + * be left stranded. For this case, you can define HD_TYPE, which + * contains all necessary info on your harddisk. + * + * The HD_TYPE macro should look like this: + * + * #define HD_TYPE { head, sect, cyl, wpcom, lzone, ctl} + * + * In case of two harddisks, the info should be separated by + * commas: + * + * #define HD_TYPE { h,s,c,wpcom,lz,ctl },{ h,s,c,wpcom,lz,ctl } + */ +/* + This is an example, two drives, first is type 2, second is type 3: + +#define HD_TYPE { 4,17,615,300,615,8 }, { 6,17,615,300,615,0 } + + NOTE: ctl is 0 for all drives with heads<=8, and ctl=8 for drives + with more than 8 heads. + + If you want the BIOS to tell what kind of drive you have, just + leave HD_TYPE undefined. This is the normal thing to do. +*/ + +#undef HD_TYPE + +/* + File type specific stuff goes into this. +*/ + +#ifdef ASM_SRC +#endif + +#ifdef C_SRC +#endif + +#ifdef MAKE +#endif + +#endif diff --git a/include/linux/ctype.h b/include/linux/ctype.h new file mode 100644 index 000000000..838ef933d --- /dev/null +++ b/include/linux/ctype.h @@ -0,0 +1,34 @@ +#ifndef _LINUX_CTYPE_H +#define _LINUX_CTYPE_H + +#define _U 0x01 /* upper */ +#define _L 0x02 /* lower */ +#define _D 0x04 /* digit */ +#define _C 0x08 /* cntrl */ +#define _P 0x10 /* punct */ +#define _S 0x20 /* white space (space/lf/tab) */ +#define _X 0x40 /* hex digit */ +#define _SP 0x80 /* hard space (0x20) */ + +extern unsigned char _ctype[]; +extern char _ctmp; + +#define isalnum(c) ((_ctype+1)[c]&(_U|_L|_D)) +#define isalpha(c) ((_ctype+1)[c]&(_U|_L)) +#define iscntrl(c) ((_ctype+1)[c]&(_C)) +#define isdigit(c) ((_ctype+1)[c]&(_D)) +#define isgraph(c) ((_ctype+1)[c]&(_P|_U|_L|_D)) +#define islower(c) ((_ctype+1)[c]&(_L)) +#define isprint(c) ((_ctype+1)[c]&(_P|_U|_L|_D|_SP)) +#define ispunct(c) ((_ctype+1)[c]&(_P)) +#define isspace(c) ((_ctype+1)[c]&(_S)) +#define isupper(c) ((_ctype+1)[c]&(_U)) +#define isxdigit(c) ((_ctype+1)[c]&(_D|_X)) + +#define isascii(c) (((unsigned) c)<=0x7f) +#define toascii(c) (((unsigned) c)&0x7f) + +#define tolower(c) (_ctmp=c,isupper(_ctmp)?_ctmp-('A'-'a'):_ctmp) +#define toupper(c) (_ctmp=c,islower(_ctmp)?_ctmp-('a'-'A'):_ctmp) + +#endif diff --git a/include/linux/debugreg.h b/include/linux/debugreg.h new file mode 100644 index 000000000..ba93e10c6 --- /dev/null +++ b/include/linux/debugreg.h @@ -0,0 +1,61 @@ +#ifndef _LINUX_DEBUGREG_H +#define _LINUX_DEBUGREG_H + + +/* Indicate the register numbers for a number of the specific + debug registers. Registers 0-3 contain the addresses we wish to trap on */ +#define DR_FIRSTADDR 0 /* u_debugreg[DR_FIRSTADDR] */ +#define DR_LASTADDR 3 /* u_debugreg[DR_LASTADDR] */ + +#define DR_STATUS 6 /* u_debugreg[DR_STATUS] */ +#define DR_CONTROL 7 /* u_debugreg[DR_CONTROL] */ + +/* Define a few things for the status register. We can use this to determine + which debugging register was responsible for the trap. The other bits + are either reserved or not of interest to us. */ + +#define DR_TRAP0 (0x1) /* Trap due to db0 */ +#define DR_TRAP1 (0x2) /* Trap due to db1 */ +#define DR_TRAP2 (0x4) /* Trap due to db2 */ +#define DR_TRAP3 (0x8) /* Trap due to db3 */ + +/* Now define a bunch of things for manipulating the control register. + The top two bytes of the control register consist of 4 fields of 4 + bytes - each field corresponds to one of the four debug registers, + and indicates what types of access we trap on, and how large the data + field is that we are looking at */ + +#define DR_CONTROL_SHIFT 16 /* Skip this many bits in ctl register */ +#define DR_CONTROL_SIZE 4 /* 4 control bits per register */ + +#define DR_RW_EXECUTE (0x0) /* Settings for the access types to trap on */ +#define DR_RW_WRITE (0x1) +#define DR_RW_READ (0x3) + +#define DR_LEN_1 (0x0) /* Settings for data length to trap on */ +#define DR_LEN_2 (0x4) +#define DR_LEN_4 (0xC) + +/* The low byte to the control register determine which registers are + enabled. There are 4 fields of two bits. One bit is "local", meaning + that the processor will reset the bit after a task switch and the other + is global meaning that we have to explicitly reset the bit. With linux, + you can use either one, since we explicitly zero the register when we enter + kernel mode. */ + +#define DR_LOCAL_ENABLE_SHIFT 0 /* Extra shift to the local enable bit */ +#define DR_GLOBAL_ENABLE_SHIFT 1 /* Extra shift to the global enable bit */ +#define DR_ENABLE_SIZE 2 /* 2 enable bits per register */ + +#define DR_LOCAL_ENABLE_MASK (0x55) /* Set local bits for all 4 regs */ +#define DR_GLOBAL_ENABLE_MASK (0xAA) /* Set global bits for all 4 regs */ + +/* The second byte to the control register has a few special things. + We can slow the instruction pipeline for instructions coming via the + gdt or the ldt if we want to. I am not sure why this is an advantage */ + +#define DR_CONTROL_RESERVED (0xFC00) /* Reserved by Intel */ +#define DR_LOCAL_SLOWDOWN (0x100) /* Local slow the pipeline */ +#define DR_GLOBAL_SLOWDOWN (0x200) /* Global slow the pipeline */ + +#endif diff --git a/include/linux/delay.h b/include/linux/delay.h new file mode 100644 index 000000000..50b5d0b10 --- /dev/null +++ b/include/linux/delay.h @@ -0,0 +1,14 @@ +#ifndef _LINUX_DELAY_H +#define _LINUX_DELAY_H + +/* + * Copyright (C) 1993 Linus Torvalds + * + * Delay routines, using a pre-computed "loops_per_second" value. + */ + +extern unsigned long loops_per_sec; + +#include <asm/delay.h> + +#endif /* defined(_LINUX_DELAY_H) */ diff --git a/include/linux/dirent.h b/include/linux/dirent.h new file mode 100644 index 000000000..219faf1cb --- /dev/null +++ b/include/linux/dirent.h @@ -0,0 +1,13 @@ +#ifndef _LINUX_DIRENT_H +#define _LINUX_DIRENT_H + +#include <linux/limits.h> + +struct dirent { + long d_ino; + off_t d_off; + unsigned short d_reclen; + char d_name[NAME_MAX+1]; +}; + +#endif diff --git a/include/linux/elf.h b/include/linux/elf.h new file mode 100644 index 000000000..cc47c39bd --- /dev/null +++ b/include/linux/elf.h @@ -0,0 +1,153 @@ +#ifndef _ELF_H +#define _ELF_H + +/* These constants are for the segment types stored in the image headers */ +#define PT_NULL 0 +#define PT_LOAD 1 +#define PT_DYNAMIC 2 +#define PT_INTERP 3 +#define PT_NOTE 4 +#define PT_SHLIB 5 +#define PT_PHDR 6 +#define PT_LOPROC 0x70000000 +#define PT_HIPROC 0x7fffffff + +/* These constants define the different elf file types */ +#define ET_NONE 0 +#define ET_REL 1 +#define ET_EXEC 2 +#define ET_DYN 3 +#define ET_CORE 4 +#define ET_LOPROC 5 +#define ET_HIPROC 6 + +/* These constants define the various ELF target machines */ +#define EM_NONE 0 +#define EM_M32 1 +#define EM_SPARC 2 +#define EM_386 3 +#define EM_68K 4 +#define EM_88K 5 +#define EM_486 6 /* Perhaps disused */ +#define EM_860 7 + +/* This is the info that is needed to parse the dynamic section of the file */ +#define DT_NULL 0 +#define DT_NEEDED 1 +#define DT_PLTRELSZ 2 +#define DT_PLTGOT 3 +#define DT_HASH 4 +#define DT_STRTAB 5 +#define DT_SYMTAB 6 +#define DT_RELA 7 +#define DT_RELASZ 8 +#define DT_RELAENT 9 +#define DT_STRSZ 10 +#define DT_SYMENT 11 +#define DT_INIT 12 +#define DT_FINI 13 +#define DT_SONAME 14 +#define DT_RPATH 15 +#define DT_SYMBOLIC 16 +#define DT_REL 17 +#define DT_RELSZ 18 +#define DT_RELENT 19 +#define DT_PLTREL 20 +#define DT_DEBUG 21 +#define DT_TEXTREL 22 +#define DT_JMPREL 23 +#define DT_LOPROC 0x70000000 +#define DT_HIPROC 0x7fffffff + +/* This info is needed when parsing the symbol table */ +#define STB_LOCAL 0 +#define STB_GLOBAL 1 +#define STB_WEAK 2 + +#define STT_NOTYPE 0 +#define STT_OBJECT 1 +#define STT_FUNC 2 +#define STT_SECTION 3 +#define STT_FILE 4 + +#define ELF32_ST_BIND(x) ((x) >> 4) +#define ELF32_ST_TYPE(x) (((unsigned int) x) & 0xf) + + + +typedef struct dynamic{ + int d_tag; + union{ + int d_val; + char * d_ptr; + } d_un; +} Elf32_Dyn; + +/* The following are used with relocations */ +#define ELF32_R_SYM(x) ((x) >> 8) +#define ELF32_R_TYPE(x) ((x) & 0xff) + +#define R_386_NONE 0 +#define R_386_32 1 +#define R_386_PC32 2 +#define R_386_GOT32 3 +#define R_386_PLT32 4 +#define R_386_COPY 5 +#define R_386_GLOB_DAT 6 +#define R_386_JMP_SLOT 7 +#define R_386_RELATIVE 8 +#define R_386_GOTOFF 9 +#define R_386_GOTPC 10 +#define R_386_NUM 11 + +typedef struct elf32_rel { + unsigned int * offset; + int info; +} Elf32_Rel; + +typedef struct elf32_rela{ + unsigned int * offset; + int info; + int addend; +} Elf32_Rela; + +typedef struct elf32_sym{ + int st_name; + unsigned int st_value; + int st_size; + unsigned char st_info; + unsigned char st_other; + short int st_shndx; +} Elf32_Sym; + +typedef struct elfhdr{ + char e_ident[16]; + short int e_type; + short int e_machine; + int e_version; + char *e_entry; /* Entry point */ + int e_phoff; + int e_shoff; + int e_flags; + short int e_ehsize; + short int e_phentsize; + short int e_phnum; + short int e_shentsize; + short int e_shnum; + short int e_shstrndx; +} Elf32_Ehdr; + +typedef struct elf_phdr{ + int p_type; + int p_offset; + int p_vaddr; + int p_paddr; + int p_filesz; + int p_memsz; + int p_flags; + int p_align; +} Elf32_Phdr; + +#define ELF_START_MMAP 0x80000000 + +#endif diff --git a/include/linux/errno.h b/include/linux/errno.h new file mode 100644 index 000000000..3ce3e606d --- /dev/null +++ b/include/linux/errno.h @@ -0,0 +1,133 @@ +#ifndef _LINUX_ERRNO_H +#define _LINUX_ERRNO_H + +#define EPERM 1 /* Operation not permitted */ +#define ENOENT 2 /* No such file or directory */ +#define ESRCH 3 /* No such process */ +#define EINTR 4 /* Interrupted system call */ +#define EIO 5 /* I/O error */ +#define ENXIO 6 /* No such device or address */ +#define E2BIG 7 /* Arg list too long */ +#define ENOEXEC 8 /* Exec format error */ +#define EBADF 9 /* Bad file number */ +#define ECHILD 10 /* No child processes */ +#define EAGAIN 11 /* Try again */ +#define ENOMEM 12 /* Out of memory */ +#define EACCES 13 /* Permission denied */ +#define EFAULT 14 /* Bad address */ +#define ENOTBLK 15 /* Block device required */ +#define EBUSY 16 /* Device or resource busy */ +#define EEXIST 17 /* File exists */ +#define EXDEV 18 /* Cross-device link */ +#define ENODEV 19 /* No such device */ +#define ENOTDIR 20 /* Not a directory */ +#define EISDIR 21 /* Is a directory */ +#define EINVAL 22 /* Invalid argument */ +#define ENFILE 23 /* File table overflow */ +#define EMFILE 24 /* Too many open files */ +#define ENOTTY 25 /* Not a typewriter */ +#define ETXTBSY 26 /* Text file busy */ +#define EFBIG 27 /* File too large */ +#define ENOSPC 28 /* No space left on device */ +#define ESPIPE 29 /* Illegal seek */ +#define EROFS 30 /* Read-only file system */ +#define EMLINK 31 /* Too many links */ +#define EPIPE 32 /* Broken pipe */ +#define EDOM 33 /* Math argument out of domain of func */ +#define ERANGE 34 /* Math result not representable */ +#define EDEADLK 35 /* Resource deadlock would occur */ +#define ENAMETOOLONG 36 /* File name too long */ +#define ENOLCK 37 /* No record locks available */ +#define ENOSYS 38 /* Function not implemented */ +#define ENOTEMPTY 39 /* Directory not empty */ +#define ELOOP 40 /* Too many symbolic links encountered */ +#define EWOULDBLOCK EAGAIN /* Operation would block */ +#define ENOMSG 42 /* No message of desired type */ +#define EIDRM 43 /* Identifier removed */ +#define ECHRNG 44 /* Channel number out of range */ +#define EL2NSYNC 45 /* Level 2 not synchronized */ +#define EL3HLT 46 /* Level 3 halted */ +#define EL3RST 47 /* Level 3 reset */ +#define ELNRNG 48 /* Link number out of range */ +#define EUNATCH 49 /* Protocol driver not attached */ +#define ENOCSI 50 /* No CSI structure available */ +#define EL2HLT 51 /* Level 2 halted */ +#define EBADE 52 /* Invalid exchange */ +#define EBADR 53 /* Invalid request descriptor */ +#define EXFULL 54 /* Exchange full */ +#define ENOANO 55 /* No anode */ +#define EBADRQC 56 /* Invalid request code */ +#define EBADSLT 57 /* Invalid slot */ +#define EDEADLOCK 58 /* File locking deadlock error */ +#define EBFONT 59 /* Bad font file format */ +#define ENOSTR 60 /* Device not a stream */ +#define ENODATA 61 /* No data available */ +#define ETIME 62 /* Timer expired */ +#define ENOSR 63 /* Out of streams resources */ +#define ENONET 64 /* Machine is not on the network */ +#define ENOPKG 65 /* Package not installed */ +#define EREMOTE 66 /* Object is remote */ +#define ENOLINK 67 /* Link has been severed */ +#define EADV 68 /* Advertise error */ +#define ESRMNT 69 /* Srmount error */ +#define ECOMM 70 /* Communication error on send */ +#define EPROTO 71 /* Protocol error */ +#define EMULTIHOP 72 /* Multihop attempted */ +#define EDOTDOT 73 /* RFS specific error */ +#define EBADMSG 74 /* Not a data message */ +#define EOVERFLOW 75 /* Value too large for defined data type */ +#define ENOTUNIQ 76 /* Name not unique on network */ +#define EBADFD 77 /* File descriptor in bad state */ +#define EREMCHG 78 /* Remote address changed */ +#define ELIBACC 79 /* Can not access a needed shared library */ +#define ELIBBAD 80 /* Accessing a corrupted shared library */ +#define ELIBSCN 81 /* .lib section in a.out corrupted */ +#define ELIBMAX 82 /* Attempting to link in too many shared libraries */ +#define ELIBEXEC 83 /* Cannot exec a shared library directly */ +#define EILSEQ 84 /* Illegal byte sequence */ +#define ERESTART 85 /* Interrupted system call should be restarted */ +#define ESTRPIPE 86 /* Streams pipe error */ +#define EUSERS 87 /* Too many users */ +#define ENOTSOCK 88 /* Socket operation on non-socket */ +#define EDESTADDRREQ 89 /* Destination address required */ +#define EMSGSIZE 90 /* Message too long */ +#define EPROTOTYPE 91 /* Protocol wrong type for socket */ +#define ENOPROTOOPT 92 /* Protocol not available */ +#define EPROTONOSUPPORT 93 /* Protocol not supported */ +#define ESOCKTNOSUPPORT 94 /* Socket type not supported */ +#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ +#define EPFNOSUPPORT 96 /* Protocol family not supported */ +#define EAFNOSUPPORT 97 /* Address family not supported by protocol */ +#define EADDRINUSE 98 /* Address already in use */ +#define EADDRNOTAVAIL 99 /* Cannot assign requested address */ +#define ENETDOWN 100 /* Network is down */ +#define ENETUNREACH 101 /* Network is unreachable */ +#define ENETRESET 102 /* Network dropped connection because of reset */ +#define ECONNABORTED 103 /* Software caused connection abort */ +#define ECONNRESET 104 /* Connection reset by peer */ +#define ENOBUFS 105 /* No buffer space available */ +#define EISCONN 106 /* Transport endpoint is already connected */ +#define ENOTCONN 107 /* Transport endpoint is not connected */ +#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */ +#define ETOOMANYREFS 109 /* Too many references: cannot splice */ +#define ETIMEDOUT 110 /* Connection timed out */ +#define ECONNREFUSED 111 /* Connection refused */ +#define EHOSTDOWN 112 /* Host is down */ +#define EHOSTUNREACH 113 /* No route to host */ +#define EALREADY 114 /* Operation already in progress */ +#define EINPROGRESS 115 /* Operation now in progress */ +#define ESTALE 116 /* Stale NFS file handle */ +#define EUCLEAN 117 /* Structure needs cleaning */ +#define ENOTNAM 118 /* Not a XENIX named type file */ +#define ENAVAIL 119 /* No XENIX semaphores available */ +#define EISNAM 120 /* Is a named type file */ +#define EREMOTEIO 121 /* Remote I/O error */ +#define EDQUOT 122 /* Quota exceeded */ + +/* Should never be seen by user programs */ +#define ERESTARTSYS 512 +#define ERESTARTNOINTR 513 +#define ERESTARTNOHAND 514 /* restart if no handler.. */ +#define ENOIOCTLCMD 515 /* No ioctl command */ + +#endif diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h new file mode 100644 index 000000000..41073fcba --- /dev/null +++ b/include/linux/etherdevice.h @@ -0,0 +1,41 @@ +/* + * INET An implementation of the TCP/IP protocol suite for the LINUX + * operating system. NET is implemented using the BSD Socket + * interface as the means of communication with the user level. + * + * Definitions for the Ethernet handlers. + * + * Version: @(#)eth.h 1.0.4 05/13/93 + * + * Authors: Ross Biro, <bir7@leland.Stanford.Edu> + * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> + * + * Relocated to include/linux where it belongs by Alan Cox + * <gw4pts@gw4pts.ampr.org> + * + * 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. + * + * WARNING: This move may well be temporary. This file will get merged with others RSN. + * + */ +#ifndef _LINUX_ETHERDEVICE_H +#define _LINUX_ETHERDEVICE_H + + +#include <linux/if_ether.h> + +#ifdef __KERNEL__ +extern int eth_header(unsigned char *buff, struct device *dev, + unsigned short type, void *daddr, + void *saddr, unsigned len, + struct sk_buff *skb); +extern int eth_rebuild_header(void *buff, struct device *dev, + unsigned long raddr, struct sk_buff *skb); +extern unsigned short eth_type_trans(struct sk_buff *skb, struct device *dev); + +#endif + +#endif /* _LINUX_ETHERDEVICE_H */ diff --git a/include/linux/ext2_fs.h b/include/linux/ext2_fs.h new file mode 100644 index 000000000..8a01bf234 --- /dev/null +++ b/include/linux/ext2_fs.h @@ -0,0 +1,502 @@ +/* + * linux/include/linux/ext2_fs.h + * + * Copyright (C) 1992, 1993, 1994 Remy Card (card@masi.ibp.fr) + * Laboratoire MASI - Institut Blaise Pascal + * Universite Pierre et Marie Curie (Paris VI) + * + * from + * + * linux/include/linux/minix_fs.h + * + * Copyright (C) 1991, 1992 Linus Torvalds + */ + +#ifndef _LINUX_EXT2_FS_H +#define _LINUX_EXT2_FS_H + +/* + * The second extended filesystem constants/structures + */ + +/* + * Define EXT2FS_DEBUG to produce debug messages + */ +#undef EXT2FS_DEBUG + +/* + * Define EXT2FS_DEBUG_CACHE to produce cache debug messages + */ +#undef EXT2FS_DEBUG_CACHE + +/* + * Define EXT2FS_CHECK_CACHE to add some checks to the name cache code + */ +#undef EXT2FS_CHECK_CACHE + +/* + * Define EXT2FS_PRE_02B_COMPAT to convert ext 2 fs prior to 0.2b + */ +#undef EXT2FS_PRE_02B_COMPAT + +/* + * Define EXT2_PREALLOCATE to preallocate data blocks for expanding files + */ +#define EXT2_PREALLOCATE + +/* + * The second extended file system version + */ +#define EXT2FS_DATE "94/10/23" +#define EXT2FS_VERSION "0.5a" + +/* + * Debug code + */ +#ifdef EXT2FS_DEBUG +# define ext2_debug(f, a...) { \ + printk ("EXT2-fs DEBUG (%s, %d): %s:", \ + __FILE__, __LINE__, __FUNCTION__); \ + printk (f, ## a); \ + } +#else +# define ext2_debug(f, a...) /**/ +#endif + +/* + * Special inodes numbers + */ +#define EXT2_BAD_INO 1 /* Bad blocks inode */ +#define EXT2_ROOT_INO 2 /* Root inode */ +#define EXT2_ACL_IDX_INO 3 /* ACL inode */ +#define EXT2_ACL_DATA_INO 4 /* ACL inode */ +#define EXT2_BOOT_LOADER_INO 5 /* Boot loader inode */ +#define EXT2_UNDEL_DIR_INO 6 /* Undelete directory inode */ +#define EXT2_FIRST_INO 11 /* First non reserved inode */ + +/* + * The second extended file system magic number + */ +#define EXT2_PRE_02B_MAGIC 0xEF51 +#define EXT2_SUPER_MAGIC 0xEF53 + +/* + * Maximal count of links to a file + */ +#define EXT2_LINK_MAX 32000 + +/* + * Macro-instructions used to manage several block sizes + */ +#define EXT2_MIN_BLOCK_SIZE 1024 +#define EXT2_MAX_BLOCK_SIZE 4096 +#define EXT2_MIN_BLOCK_LOG_SIZE 10 +#ifdef __KERNEL__ +# define EXT2_BLOCK_SIZE(s) ((s)->s_blocksize) +#else +# define EXT2_BLOCK_SIZE(s) (EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size) +#endif +#define EXT2_ACLE_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_acl_entry)) +#define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (unsigned long)) +#ifdef __KERNEL__ +# define EXT2_BLOCK_SIZE_BITS(s) ((s)->u.ext2_sb.s_es->s_log_block_size + 10) +#else +# define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10) +#endif +#define EXT2_INODES_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_inode)) + +/* + * Macro-instructions used to manage fragments + */ +#define EXT2_MIN_FRAG_SIZE 1024 +#define EXT2_MAX_FRAG_SIZE 4096 +#define EXT2_MIN_FRAG_LOG_SIZE 10 +#ifdef __KERNEL__ +# define EXT2_FRAG_SIZE(s) ((s)->u.ext2_sb.s_frag_size) +# define EXT2_FRAGS_PER_BLOCK(s) ((s)->u.ext2_sb.s_frags_per_block) +#else +# define EXT2_FRAG_SIZE(s) (EXT2_MIN_FRAG_SIZE << (s)->s_log_frag_size) +# define EXT2_FRAGS_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / EXT2_FRAG_SIZE(s)) +#endif + +/* + * ACL structures + */ +struct ext2_acl_header /* Header of Access Control Lists */ +{ + unsigned long aclh_size; + unsigned long aclh_file_count; + unsigned long aclh_acle_count; + unsigned long aclh_first_acle; +}; + +struct ext2_acl_entry /* Access Control List Entry */ +{ + unsigned long acle_size; + unsigned short acle_perms; /* Access permissions */ + unsigned short acle_type; /* Type of entry */ + unsigned short acle_tag; /* User or group identity */ + unsigned short acle_pad1; + unsigned long acle_next; /* Pointer on next entry for the */ + /* same inode or on next free entry */ +}; + +/* + * Structure of a blocks group descriptor + */ +struct ext2_old_group_desc +{ + unsigned long bg_block_bitmap; /* Blocks bitmap block */ + unsigned long bg_inode_bitmap; /* Inodes bitmap block */ + unsigned long bg_inode_table; /* Inodes table block */ + unsigned short bg_free_blocks_count; /* Free blocks count */ + unsigned short bg_free_inodes_count; /* Free inodes count */ +}; + +struct ext2_group_desc +{ + unsigned long bg_block_bitmap; /* Blocks bitmap block */ + unsigned long bg_inode_bitmap; /* Inodes bitmap block */ + unsigned long bg_inode_table; /* Inodes table block */ + unsigned short bg_free_blocks_count; /* Free blocks count */ + unsigned short bg_free_inodes_count; /* Free inodes count */ + unsigned short bg_used_dirs_count; /* Directories count */ + unsigned short bg_pad; + unsigned long bg_reserved[3]; +}; + +/* + * Macro-instructions used to manage group descriptors + */ +#ifdef __KERNEL__ +# define EXT2_BLOCKS_PER_GROUP(s) ((s)->u.ext2_sb.s_blocks_per_group) +# define EXT2_DESC_PER_BLOCK(s) ((s)->u.ext2_sb.s_desc_per_block) +# define EXT2_INODES_PER_GROUP(s) ((s)->u.ext2_sb.s_inodes_per_group) +#else +# define EXT2_BLOCKS_PER_GROUP(s) ((s)->s_blocks_per_group) +# define EXT2_DESC_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_group_desc)) +# define EXT2_INODES_PER_GROUP(s) ((s)->s_inodes_per_group) +#endif + +/* + * Constants relative to the data blocks + */ +#define EXT2_NDIR_BLOCKS 12 +#define EXT2_IND_BLOCK EXT2_NDIR_BLOCKS +#define EXT2_DIND_BLOCK (EXT2_IND_BLOCK + 1) +#define EXT2_TIND_BLOCK (EXT2_DIND_BLOCK + 1) +#define EXT2_N_BLOCKS (EXT2_TIND_BLOCK + 1) + +/* + * Inode flags + */ +#define EXT2_SECRM_FL 0x00000001 /* Secure deletion */ +#define EXT2_UNRM_FL 0x00000002 /* Undelete */ +#define EXT2_COMPR_FL 0x00000004 /* Compress file */ +#define EXT2_SYNC_FL 0x00000008 /* Synchronous updates */ +#define EXT2_IMMUTABLE_FL 0x00000010 /* Immutable file */ +#define EXT2_APPEND_FL 0x00000020 /* writes to file may only append */ +#define EXT2_NODUMP_FL 0x00000040 /* do not dump file */ + +/* + * ioctl commands + */ +#define EXT2_IOC_GETFLAGS _IOR('f', 1, long) +#define EXT2_IOC_SETFLAGS _IOW('f', 2, long) +#define EXT2_IOC_GETVERSION _IOR('v', 1, long) +#define EXT2_IOC_SETVERSION _IOW('v', 2, long) + +/* + * Structure of an inode on the disk + */ +struct ext2_inode { + unsigned short i_mode; /* File mode */ + unsigned short i_uid; /* Owner Uid */ + unsigned long i_size; /* Size in bytes */ + unsigned long i_atime; /* Access time */ + unsigned long i_ctime; /* Creation time */ + unsigned long i_mtime; /* Modification time */ + unsigned long i_dtime; /* Deletion Time */ + unsigned short i_gid; /* Group Id */ + unsigned short i_links_count; /* Links count */ + unsigned long i_blocks; /* Blocks count */ + unsigned long i_flags; /* File flags */ + union { + struct { + unsigned long l_i_reserved1; + } linux1; + struct { + unsigned long h_i_translator; + } hurd1; + struct { + unsigned long m_i_reserved1; + } masix1; + } osd1; /* OS dependent 1 */ + unsigned long i_block[EXT2_N_BLOCKS];/* Pointers to blocks */ + unsigned long i_version; /* File version (for NFS) */ + unsigned long i_file_acl; /* File ACL */ + unsigned long i_dir_acl; /* Directory ACL */ + unsigned long i_faddr; /* Fragment address */ + union { + struct { + unsigned char l_i_frag; /* Fragment number */ + unsigned char l_i_fsize; /* Fragment size */ + unsigned short i_pad1; + unsigned long l_i_reserved2[2]; + } linux2; + struct { + unsigned char h_i_frag; /* Fragment number */ + unsigned char h_i_fsize; /* Fragment size */ + unsigned short h_i_mode_high; + unsigned short h_i_uid_high; + unsigned short h_i_gid_high; + unsigned long h_i_author; + } hurd2; + struct { + unsigned char m_i_frag; /* Fragment number */ + unsigned char m_i_fsize; /* Fragment size */ + unsigned short m_pad1; + unsigned long m_i_reserved2[2]; + } masix2; + } osd2; /* OS dependent 2 */ +}; + +#ifdef __linux__ +#define i_reserved1 osd1.linux1.l_i_reserved1 +#define i_frag osd2.linux2.l_i_frag +#define i_fsize osd2.linux2.l_i_fsize +#define i_reserved2 osd2.linux2.l_i_reserved2 +#endif + +#ifdef __hurd__ +#define i_translator osd1.hurd1.h_i_translator +#define i_frag osd2.hurd2.h_i_frag; +#define i_fsize osd2.hurd2.h_i_fsize; +#define i_uid_high osd2.hurd2.h_i_uid_high +#define i_gid_high osd2.hurd2.h_i_gid_high +#define i_author osd2.hurd2.h_i_author +#endif + +#ifdef __masix__ +#define i_reserved1 osd1.masix1.m_i_reserved1 +#define i_frag osd2.masix2.m_i_frag +#define i_fsize osd2.masix2.m_i_fsize +#define i_reserved2 osd2.masix2.m_i_reserved2 +#endif + +/* + * File system states + */ +#define EXT2_VALID_FS 0x0001 /* Unmounted cleanly */ +#define EXT2_ERROR_FS 0x0002 /* Errors detected */ + +/* + * Mount flags + */ +#define EXT2_MOUNT_CHECK_NORMAL 0x0001 /* Do some more checks */ +#define EXT2_MOUNT_CHECK_STRICT 0x0002 /* Do again more checks */ +#define EXT2_MOUNT_CHECK (EXT2_MOUNT_CHECK_NORMAL | \ + EXT2_MOUNT_CHECK_STRICT) +#define EXT2_MOUNT_GRPID 0x0004 /* Create files with directory's group */ +#define EXT2_MOUNT_DEBUG 0x0008 /* Some debugging messages */ +#define EXT2_MOUNT_ERRORS_CONT 0x0010 /* Continue on errors */ +#define EXT2_MOUNT_ERRORS_RO 0x0020 /* Remount fs ro on errors */ +#define EXT2_MOUNT_ERRORS_PANIC 0x0040 /* Panic on errors */ +#define EXT2_MOUNT_MINIX_DF 0x0080 /* Mimics the Minix statfs */ + +#define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt +#define set_opt(o, opt) o |= EXT2_MOUNT_##opt +#define test_opt(sb, opt) ((sb)->u.ext2_sb.s_mount_opt & \ + EXT2_MOUNT_##opt) +/* + * Maximal mount counts between two filesystem checks + */ +#define EXT2_DFL_MAX_MNT_COUNT 20 /* Allow 20 mounts */ +#define EXT2_DFL_CHECKINTERVAL 0 /* Don't use interval check */ + +/* + * Behaviour when detecting errors + */ +#define EXT2_ERRORS_CONTINUE 1 /* Continue execution */ +#define EXT2_ERRORS_RO 2 /* Remount fs read-only */ +#define EXT2_ERRORS_PANIC 3 /* Panic */ +#define EXT2_ERRORS_DEFAULT EXT2_ERRORS_CONTINUE + +/* + * Structure of the super block + */ +struct ext2_super_block { + unsigned long s_inodes_count; /* Inodes count */ + unsigned long s_blocks_count; /* Blocks count */ + unsigned long s_r_blocks_count;/* Reserved blocks count */ + unsigned long s_free_blocks_count;/* Free blocks count */ + unsigned long s_free_inodes_count;/* Free inodes count */ + unsigned long s_first_data_block;/* First Data Block */ + unsigned long s_log_block_size;/* Block size */ + long s_log_frag_size; /* Fragment size */ + unsigned long s_blocks_per_group;/* # Blocks per group */ + unsigned long s_frags_per_group;/* # Fragments per group */ + unsigned long s_inodes_per_group;/* # Inodes per group */ + unsigned long s_mtime; /* Mount time */ + unsigned long s_wtime; /* Write time */ + unsigned short s_mnt_count; /* Mount count */ + short s_max_mnt_count; /* Maximal mount count */ + unsigned short s_magic; /* Magic signature */ + unsigned short s_state; /* File system state */ + unsigned short s_errors; /* Behaviour when detecting errors */ + unsigned short s_pad; + unsigned long s_lastcheck; /* time of last check */ + unsigned long s_checkinterval; /* max. time between checks */ + unsigned long s_creator_os; /* OS */ + unsigned long s_rev_level; /* Revision level */ + unsigned short s_def_resuid; /* Default uid for reserved blocks */ + unsigned short s_def_resgid; /* Default gid for reserved blocks */ + unsigned long s_reserved[235]; /* Padding to the end of the block */ +}; + +#define EXT2_OS_LINUX 0 +#define EXT2_OS_HURD 1 +#define EXT2_OS_MASIX 2 + +#define EXT2_CURRENT_REV 0 + +#define EXT2_DEF_RESUID 0 +#define EXT2_DEF_RESGID 0 + +/* + * Structure of a directory entry + */ +#define EXT2_NAME_LEN 255 + +struct ext2_dir_entry { + unsigned long inode; /* Inode number */ + unsigned short rec_len; /* Directory entry length */ + unsigned short name_len; /* Name length */ + char name[EXT2_NAME_LEN]; /* File name */ +}; + +/* + * EXT2_DIR_PAD defines the directory entries boundaries + * + * NOTE: It must be a multiple of 4 + */ +#define EXT2_DIR_PAD 4 +#define EXT2_DIR_ROUND (EXT2_DIR_PAD - 1) +#define EXT2_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT2_DIR_ROUND) & \ + ~EXT2_DIR_ROUND) + +#ifdef __KERNEL__ +/* + * Function prototypes + */ + +/* + * Ok, these declarations are also in <linux/kernel.h> but none of the + * ext2 source programs needs to include it so they are duplicated here. + */ +#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) +# define NORET_TYPE __volatile__ +# define ATTRIB_NORET /**/ +# define NORET_AND /**/ +#else +# define NORET_TYPE /**/ +# define ATTRIB_NORET __attribute__((noreturn)) +# define NORET_AND noreturn, +#endif + +/* acl.c */ +extern int ext2_permission (struct inode *, int); + +/* balloc.c */ +extern int ext2_new_block (struct super_block *, unsigned long, + unsigned long *, unsigned long *); +extern void ext2_free_blocks (struct super_block *, unsigned long, + unsigned long); +extern unsigned long ext2_count_free_blocks (struct super_block *); +extern void ext2_check_blocks_bitmap (struct super_block *); + +/* bitmap.c */ +extern unsigned long ext2_count_free (struct buffer_head *, unsigned); + +/* dir.c */ +extern int ext2_check_dir_entry (char *, struct inode *, + struct ext2_dir_entry *, struct buffer_head *, + unsigned long); + +/* file.c */ +extern int ext2_read (struct inode *, struct file *, char *, int); +extern int ext2_write (struct inode *, struct file *, char *, int); + +/* fsync.c */ +extern int ext2_sync_file (struct inode *, struct file *); + +/* ialloc.c */ +extern struct inode * ext2_new_inode (const struct inode *, int); +extern void ext2_free_inode (struct inode *); +extern unsigned long ext2_count_free_inodes (struct super_block *); +extern void ext2_check_inodes_bitmap (struct super_block *); + +/* inode.c */ +extern int ext2_bmap (struct inode *, int); + +extern struct buffer_head * ext2_getblk (struct inode *, long, int, int *); +extern struct buffer_head * ext2_bread (struct inode *, int, int, int *); + +extern int ext2_getcluster (struct inode * inode, long block); +extern void ext2_read_inode (struct inode *); +extern void ext2_write_inode (struct inode *); +extern void ext2_put_inode (struct inode *); +extern int ext2_sync_inode (struct inode *); +extern void ext2_discard_prealloc (struct inode *); + +/* ioctl.c */ +extern int ext2_ioctl (struct inode *, struct file *, unsigned int, + unsigned long); + +/* namei.c */ +extern void ext2_release (struct inode *, struct file *); +extern int ext2_lookup (struct inode *,const char *, int, struct inode **); +extern int ext2_create (struct inode *,const char *, int, int, + struct inode **); +extern int ext2_mkdir (struct inode *, const char *, int, int); +extern int ext2_rmdir (struct inode *, const char *, int); +extern int ext2_unlink (struct inode *, const char *, int); +extern int ext2_symlink (struct inode *, const char *, int, const char *); +extern int ext2_link (struct inode *, struct inode *, const char *, int); +extern int ext2_mknod (struct inode *, const char *, int, int, int); +extern int ext2_rename (struct inode *, const char *, int, + struct inode *, const char *, int); + +/* super.c */ +extern void ext2_error (struct super_block *, const char *, const char *, ...) + __attribute__ ((format (printf, 3, 4))); +extern NORET_TYPE void ext2_panic (struct super_block *, const char *, + const char *, ...) + __attribute__ ((NORET_AND format (printf, 3, 4))); +extern void ext2_warning (struct super_block *, const char *, const char *, ...) + __attribute__ ((format (printf, 3, 4))); +extern void ext2_put_super (struct super_block *); +extern void ext2_write_super (struct super_block *); +extern int ext2_remount (struct super_block *, int *, char *); +extern struct super_block * ext2_read_super (struct super_block *,void *,int); +extern void ext2_statfs (struct super_block *, struct statfs *); + +/* truncate.c */ +extern void ext2_truncate (struct inode *); + +/* + * Inodes and files operations + */ + +/* dir.c */ +extern struct inode_operations ext2_dir_inode_operations; + +/* file.c */ +extern struct inode_operations ext2_file_inode_operations; + +/* symlink.c */ +extern struct inode_operations ext2_symlink_inode_operations; + +#endif /* __KERNEL__ */ + +#endif /* _LINUX_EXT2_FS_H */ diff --git a/include/linux/ext2_fs_i.h b/include/linux/ext2_fs_i.h new file mode 100644 index 000000000..103e36087 --- /dev/null +++ b/include/linux/ext2_fs_i.h @@ -0,0 +1,39 @@ +/* + * linux/include/linux/ext2_fs_i.h + * + * Copyright (C) 1992, 1993, 1994 Remy Card (card@masi.ibp.fr) + * Laboratoire MASI - Institut Blaise Pascal + * Universite Pierre et Marie Curie (Paris VI) + * + * from + * + * linux/include/linux/minix_fs_i.h + * + * Copyright (C) 1991, 1992 Linus Torvalds + */ + +#ifndef _LINUX_EXT2_FS_I +#define _LINUX_EXT2_FS_I + +/* + * second extended file system inode data in memory + */ +struct ext2_inode_info { + unsigned long i_data[15]; + unsigned long i_flags; + unsigned long i_faddr; + unsigned char i_frag_no; + unsigned char i_frag_size; + unsigned short i_osync; + unsigned long i_file_acl; + unsigned long i_dir_acl; + unsigned long i_dtime; + unsigned long i_version; + unsigned long i_block_group; + unsigned long i_next_alloc_block; + unsigned long i_next_alloc_goal; + unsigned long i_prealloc_block; + unsigned long i_prealloc_count; +}; + +#endif /* _LINUX_EXT2_FS_I */ diff --git a/include/linux/ext2_fs_sb.h b/include/linux/ext2_fs_sb.h new file mode 100644 index 000000000..2a05a98be --- /dev/null +++ b/include/linux/ext2_fs_sb.h @@ -0,0 +1,57 @@ +/* + * linux/include/linux/ext2_fs_sb.h + * + * Copyright (C) 1992, 1993, 1994 Remy Card (card@masi.ibp.fr) + * Laboratoire MASI - Institut Blaise Pascal + * Universite Pierre et Marie Curie (Paris VI) + * + * from + * + * linux/include/linux/minix_fs_sb.h + * + * Copyright (C) 1991, 1992 Linus Torvalds + */ + +#ifndef _LINUX_EXT2_FS_SB +#define _LINUX_EXT2_FS_SB + +/* + * The following is not needed anymore since the descriptors buffer + * heads are now dynamically allocated + */ +/* #define EXT2_MAX_GROUP_DESC 8 */ + +#define EXT2_MAX_GROUP_LOADED 8 + +/* + * second extended-fs super-block data in memory + */ +struct ext2_sb_info { + unsigned long s_frag_size; /* Size of a fragment in bytes */ + unsigned long s_frags_per_block;/* Number of fragments per block */ + unsigned long s_inodes_per_block;/* Number of inodes per block */ + unsigned long s_frags_per_group;/* Number of fragments in a group */ + unsigned long s_blocks_per_group;/* Number of blocks in a group */ + unsigned long s_inodes_per_group;/* Number of inodes in a group */ + unsigned long s_itb_per_group; /* Number of inode table blocks per group */ + unsigned long s_db_per_group; /* Number of descriptor blocks per group */ + unsigned long s_desc_per_block; /* Number of group descriptors per block */ + unsigned long s_groups_count; /* Number of groups in the fs */ + struct buffer_head * s_sbh; /* Buffer containing the super block */ + struct ext2_super_block * s_es; /* Pointer to the super block in the buffer */ + struct buffer_head ** s_group_desc; + unsigned short s_loaded_inode_bitmaps; + unsigned short s_loaded_block_bitmaps; + unsigned long s_inode_bitmap_number[EXT2_MAX_GROUP_LOADED]; + struct buffer_head * s_inode_bitmap[EXT2_MAX_GROUP_LOADED]; + unsigned long s_block_bitmap_number[EXT2_MAX_GROUP_LOADED]; + struct buffer_head * s_block_bitmap[EXT2_MAX_GROUP_LOADED]; + int s_rename_lock; + struct wait_queue * s_rename_wait; + unsigned long s_mount_opt; + unsigned short s_resuid; + unsigned short s_resgid; + unsigned short s_mount_state; +}; + +#endif /* _LINUX_EXT2_FS_SB */ diff --git a/include/linux/ext_fs.h b/include/linux/ext_fs.h new file mode 100644 index 000000000..58eae0b0a --- /dev/null +++ b/include/linux/ext_fs.h @@ -0,0 +1,110 @@ +#ifndef _LINUX_EXT_FS_H +#define _LINUX_EXT_FS_H + +/* + * The ext filesystem constants/structures + */ + +#define EXT_NAME_LEN 255 +#define EXT_ROOT_INO 1 + +#define EXT_SUPER_MAGIC 0x137D + +#define EXT_INODES_PER_BLOCK ((BLOCK_SIZE)/(sizeof (struct ext_inode))) + +struct ext_inode { + unsigned short i_mode; + unsigned short i_uid; + unsigned long i_size; + unsigned long i_time; + unsigned short i_gid; + unsigned short i_nlinks; + unsigned long i_zone[12]; +}; + +struct ext_free_inode { + unsigned long count; + unsigned long free[14]; + unsigned long next; +}; + +struct ext_free_block { + unsigned long count; + unsigned long free[254]; + unsigned long next; +}; + +struct ext_super_block { + unsigned long s_ninodes; + unsigned long s_nzones; + unsigned long s_firstfreeblock; + unsigned long s_freeblockscount; + unsigned long s_firstfreeinode; + unsigned long s_freeinodescount; + unsigned long s_firstdatazone; + unsigned long s_log_zone_size; + unsigned long s_max_size; + unsigned long s_reserved1; + unsigned long s_reserved2; + unsigned long s_reserved3; + unsigned long s_reserved4; + unsigned long s_reserved5; + unsigned short s_magic; +}; + +struct ext_dir_entry { + unsigned long inode; + unsigned short rec_len; + unsigned short name_len; + char name[EXT_NAME_LEN]; +}; + +#ifdef __KERNEL__ +extern int ext_open(struct inode * inode, struct file * filp); +extern void ext_release(struct inode * inode, struct file * filp); +extern int ext_lookup(struct inode * dir,const char * name, int len, + struct inode ** result); +extern int ext_create(struct inode * dir,const char * name, int len, int mode, + struct inode ** result); +extern int ext_mkdir(struct inode * dir, const char * name, int len, int mode); +extern int ext_rmdir(struct inode * dir, const char * name, int len); +extern int ext_unlink(struct inode * dir, const char * name, int len); +extern int ext_symlink(struct inode * inode, const char * name, int len, + const char * symname); +extern int ext_link(struct inode * oldinode, struct inode * dir, const char * name, int len); +extern int ext_mknod(struct inode * dir, const char * name, int len, int mode, int rdev); +extern int ext_rename(struct inode * old_dir, const char * old_name, int old_len, + struct inode * new_dir, const char * new_name, int new_len); +extern struct inode * ext_new_inode(const struct inode * dir); +extern void ext_free_inode(struct inode * inode); +extern unsigned long ext_count_free_inodes(struct super_block *sb); +extern int ext_new_block(struct super_block * sb); +extern void ext_free_block(struct super_block * sb, int block); +extern unsigned long ext_count_free_blocks(struct super_block *sb); + +extern int ext_bmap(struct inode *,int); + +extern struct buffer_head * ext_getblk(struct inode *, int, int); +extern struct buffer_head * ext_bread(struct inode *, int, int); + +extern void ext_truncate(struct inode *); +extern void ext_put_super(struct super_block *); +extern void ext_write_super(struct super_block *); +extern struct super_block *ext_read_super(struct super_block *,void *,int); +extern void ext_read_inode(struct inode *); +extern void ext_write_inode(struct inode *); +extern void ext_put_inode(struct inode *); +extern void ext_statfs(struct super_block *, struct statfs *); +extern int ext_sync_inode(struct inode *); +extern int ext_sync_file(struct inode *, struct file *); + +extern int ext_lseek(struct inode *, struct file *, off_t, int); +extern int ext_read(struct inode *, struct file *, char *, int); +extern int ext_write(struct inode *, struct file *, char *, int); + +extern struct inode_operations ext_file_inode_operations; +extern struct inode_operations ext_dir_inode_operations; +extern struct inode_operations ext_symlink_inode_operations; + +#endif /*__KERNEL__ */ +#endif diff --git a/include/linux/ext_fs_i.h b/include/linux/ext_fs_i.h new file mode 100644 index 000000000..32734f95f --- /dev/null +++ b/include/linux/ext_fs_i.h @@ -0,0 +1,11 @@ +#ifndef _EXT_FS_I +#define _EXT_FS_I + +/* + * extended file system inode data in memory + */ +struct ext_inode_info { + unsigned long i_data[16]; +}; + +#endif diff --git a/include/linux/ext_fs_sb.h b/include/linux/ext_fs_sb.h new file mode 100644 index 000000000..19004d80f --- /dev/null +++ b/include/linux/ext_fs_sb.h @@ -0,0 +1,21 @@ +#ifndef _EXT_FS_SB +#define _EXT_FS_SB + +/* + * extended-fs super-block data in memory + */ +struct ext_sb_info { + unsigned long s_ninodes; + unsigned long s_nzones; + unsigned long s_firstdatazone; + unsigned long s_log_zone_size; + unsigned long s_max_size; + unsigned long s_firstfreeblocknumber; + unsigned long s_freeblockscount; + struct buffer_head * s_firstfreeblock; + unsigned long s_firstfreeinodenumber; + unsigned long s_freeinodescount; + struct buffer_head * s_firstfreeinodeblock; +}; + +#endif diff --git a/include/linux/fcntl.h b/include/linux/fcntl.h new file mode 100644 index 000000000..b98266268 --- /dev/null +++ b/include/linux/fcntl.h @@ -0,0 +1,51 @@ +#ifndef _LINUX_FCNTL_H +#define _LINUX_FCNTL_H + +/* open/fcntl - O_SYNC is only implemented on blocks devices and on files + located on an ext2 file system */ +#define O_ACCMODE 0003 +#define O_RDONLY 00 +#define O_WRONLY 01 +#define O_RDWR 02 +#define O_CREAT 0100 /* not fcntl */ +#define O_EXCL 0200 /* not fcntl */ +#define O_NOCTTY 0400 /* not fcntl */ +#define O_TRUNC 01000 /* not fcntl */ +#define O_APPEND 02000 +#define O_NONBLOCK 04000 +#define O_NDELAY O_NONBLOCK +#define O_SYNC 010000 +#define FASYNC 020000 /* fcntl, for BSD compatibility */ + +#define F_DUPFD 0 /* dup */ +#define F_GETFD 1 /* get f_flags */ +#define F_SETFD 2 /* set f_flags */ +#define F_GETFL 3 /* more flags (cloexec) */ +#define F_SETFL 4 +#define F_GETLK 5 +#define F_SETLK 6 +#define F_SETLKW 7 + +#define F_SETOWN 8 /* for sockets. */ +#define F_GETOWN 9 /* for sockets. */ + +/* for F_[GET|SET]FL */ +#define FD_CLOEXEC 1 /* actually anything with low bit set goes */ + +#define F_RDLCK 0 +#define F_WRLCK 1 +#define F_UNLCK 2 + +/* For bsd flock () */ +#define F_EXLCK 4 /* or 3 */ +#define F_SHLCK 8 /* or 4 */ + +struct flock { + short l_type; + short l_whence; + off_t l_start; + off_t l_len; + pid_t l_pid; +}; + +#endif diff --git a/include/linux/fd.h b/include/linux/fd.h new file mode 100644 index 000000000..42ec48cf8 --- /dev/null +++ b/include/linux/fd.h @@ -0,0 +1,250 @@ +#ifndef _LINUX_FD_H +#define _LINUX_FD_H + +#define FDCLRPRM 0 /* clear user-defined parameters */ +#define FDSETPRM 1 /* set user-defined parameters for current media */ +#define FDSETMEDIAPRM 1 +#define FDDEFPRM 2 /* set user-defined parameters until explicitly cleared */ +#define FDDEFMEDIAPRM 2 +#define FDGETPRM 3 /* get disk parameters */ +#define FDGETMEDIAPRM 3 +#define FDMSGON 4 /* issue kernel messages on media type change */ +#define FDMSGOFF 5 /* don't issue kernel messages on media type change */ +#define FDFMTBEG 6 /* begin formatting a disk */ +#define FDFMTTRK 7 /* format the specified track */ +#define FDFMTEND 8 /* end formatting a disk */ +#define FDSETEMSGTRESH 10 /* set fdc error reporting threshold */ +#define FDFLUSH 11 /* flush buffers for media; either for verifying media, or for + handling a media change without closing the file + descriptor */ +#define FDSETMAXERRS 12 /* set abortion and read_track threshold */ +#define FDGETMAXERRS 14 /* get abortion and read_track threshold */ +#define FDGETDRVTYP 16 /* get drive type: 5 1/4 or 3 1/2 */ + +#define FDSETDRVPRM 20 /* set drive parameters */ +#define FDGETDRVPRM 21 /* get drive parameters */ +#define FDGETDRVSTAT 22 /* get drive state */ +#define FDPOLLDRVSTAT 23 /* get drive state */ +#define FDRESET 24 /* reset FDC */ + +#define FD_RESET_IF_NEEDED 0 +#define FD_RESET_IF_RAWCMD 1 +#define FD_RESET_ALWAYS 2 + +#define FDGETFDCSTAT 25 /* get fdc state */ +#define FDWERRORCLR 27 /* clear write error and badness information */ +#define FDWERRORGET 28 /* get write error and badness information */ + +#define FDRAWCMD 30 /* send a raw command to the fdc */ + +#define FDTWADDLE 40 /* flicker motor-on bit before reading a sector */ + +/* + * Maximum number of sectors in a track buffer. Track buffering is disabled + * if tracks are bigger. + */ +#define MAX_BUFFER_SECTORS 24 /* was 18 -bb */ + +#define FD_FILL_BYTE 0xF6 /* format fill byte */ + +#define FD_2M 0x4 +#define FD_SIZECODEMASK 0x38 +#define FD_SIZECODE(floppy) (((((floppy)->rate&FD_SIZECODEMASK)>> 3)+ 2) %8) +#define FD_SECTSIZE(floppy) ( (floppy)->rate & FD_2M ? \ + 512 : 128 << FD_SIZECODE(floppy) ) +#define FD_PERP 0x40 + +#ifndef __ASSEMBLY__ +/* the following structure is used by FDSETPRM, FDDEFPRM and FDGETPRM */ +struct floppy_struct { + unsigned int size, /* nr of sectors total */ + sect, /* sectors per track */ + head, /* nr of heads */ + track, /* nr of tracks */ + stretch; /* !=0 means double track steps */ + unsigned char gap, /* gap1 size */ + rate, /* data rate. |= 0x40 for perpendicular */ + spec1, /* stepping rate, head unload time */ + fmt_gap; /* gap2 size */ + char * name; /* used only for predefined formats */ +}; + +struct format_descr { + unsigned int device,head,track; +}; + +struct floppy_max_errors { + unsigned int + abort, /* number of errors to be reached before aborting */ + read_track, /* maximal number of errors permitted to read an + * entire track at once */ + reset, /* maximal number of errors before a reset is tried */ + recal, /* maximal number of errors before a recalibrate is + * tried */ + + /* + * Threshold for reporting FDC errors to the console. + * Setting this to zero may flood your screen when using + * ultra cheap floppies ;-) + */ + reporting; + +}; + +/* the following structure is used by FDSETDRVPRM and FDGETDRVPRM */ +struct floppy_drive_params { + char cmos; /* cmos type */ + + /* Spec2 is (HLD<<1 | ND), where HLD is head load time (1=2ms, 2=4 ms etc) + * and ND is set means no DMA. Hardcoded to 6 (HLD=6ms, use DMA). + */ + unsigned long max_dtr; /* Step rate, usec */ + unsigned long hlt; /* Head load/settle time, msec */ + unsigned long hut; /* Head unload time (remnant of 8" drives) */ + unsigned long srt; /* Step rate, usec */ + + unsigned long spinup; /* time needed for spinup ( in jiffies) */ + unsigned long spindown; /* timeout needed for spindown */ + unsigned char spindown_offset;/* decides in which position the disk + * will stop */ + unsigned char select_delay; /* delay to wait after select */ + unsigned char rps; /* rotations per second */ + unsigned char tracks; /* maximum number of tracks */ + unsigned long timeout; /* timeout for interrupt requests */ + + unsigned char interleave_sect;/* if there are more sectors, use interleave */ + + struct floppy_max_errors max_errors; + + char flags; /* various flags, including ftd_msg */ +/* + * Announce successful media type detection and media information loss after + * disk changes. + * Also used to enable/disable printing of overrun warnings. + */ + +#define FTD_MSG 0x10 +#define FD_BROKEN_DCL 0x20 +#define FD_DEBUG 0x02 +#define FD_SILENT_DCL_CLEAR 0x4 + + char read_track; /* use readtrack during probing? */ + +/* + * Auto-detection. Each drive type has eight formats which are + * used in succession to try to read the disk. If the FDC cannot lock onto + * the disk, the next format is tried. This uses the variable 'probing'. + */ + short autodetect[8]; /* autodetected formats */ + + int checkfreq; /* how often should the drive be checked for disk changes */ + int native_format; /* native format of this drive */ +}; + +enum { +FD_NEED_TWADDLE_BIT, /* more magic */ +FD_VERIFY_BIT, /* inquire for write protection */ +FD_DISK_NEWCHANGE_BIT, /* change detected, and no action undertaken yet to + clear media change status */ +FD_UNUSED_BIT, +FD_DISK_CHANGED_BIT, /* disk has been changed since last i/o */ +FD_DISK_WRITABLE_BIT /* disk is writable */ +}; + +/* values for these flags */ +#define FD_NEED_TWADDLE (1 << FD_NEED_TWADDLE_BIT) +#define FD_VERIFY (1 << FD_VERIFY_BIT) +#define FD_DISK_NEWCHANGE (1 << FD_DISK_NEWCHANGE_BIT) +#define FD_DISK_CHANGED (1 << FD_DISK_CHANGED_BIT) +#define FD_DISK_WRITABLE (1 << FD_DISK_WRITABLE_BIT) + +#define FD_DRIVE_PRESENT 0 /* keep fdpatch utils compiling */ + +struct floppy_drive_struct { + signed char flags; + unsigned long spinup_date; + unsigned long select_date; + unsigned long first_read_date; + short probed_format; + short track; /* current track */ + short maxblock; /* id of highest block read */ + short maxtrack; /* id of highest half track read */ + int generation; /* how many diskchanges? */ + +/* + * (User-provided) media information is _not_ discarded after a media change + * if the corresponding keep_data flag is non-zero. Positive values are + * decremented after each probe. + */ + int keep_data; + + /* Prevent "aliased" accesses. */ + int fd_ref; + int fd_device; + int last_checked; /* when was the drive last checked for a disk change? */ + + +}; + +struct floppy_write_errors { + /* Write error logging. + * + * These fields can be cleared with the FDWERRORCLR ioctl. + * Only writes that were attempted but failed due to a physical media + * error are logged. write(2) calls that fail and return an error code + * to the user process are not counted. + */ + + unsigned int write_errors; /* number of physical write errors encountered */ + + /* position of first and last write errors */ + unsigned long first_error_sector; + int first_error_generation; + unsigned long last_error_sector; + int last_error_generation; + + unsigned int badness; /* highest retry count for a read or write operation */ +}; + +struct floppy_fdc_state { + int spec1; /* spec1 value last used */ + int spec2; /* spec2 value last used */ + int dtr; + unsigned char version; /* FDC version code */ + unsigned char dor; + int address; /* io address */ + unsigned int rawcmd:2; + unsigned int reset:1; + unsigned int need_configure:1; + unsigned int perp_mode:2; + unsigned int has_fifo:1; +}; + +struct floppy_raw_cmd { + void *data; + long length; + + unsigned char rate; + unsigned char flags; + unsigned char cmd_count; + unsigned char cmd[9]; + unsigned char reply_count; + unsigned char reply[7]; + int track; +}; +#endif + +/* meaning of the various bytes */ + +/* flags */ +#define FD_RAW_READ 1 +#define FD_RAW_WRITE 2 +#define FD_RAW_NO_MOTOR 4 +#define FD_RAW_DISK_CHANGE 4 +#define FD_RAW_INTR 8 +#define FD_RAW_SPIN 16 +#define FD_RAW_NO_MOTOR_AFTER 32 +#define FD_RAW_NEED_DISK 64 +#define FD_RAW_NEED_SEEK 128 + +#endif diff --git a/include/linux/fdreg.h b/include/linux/fdreg.h new file mode 100644 index 000000000..245647bbf --- /dev/null +++ b/include/linux/fdreg.h @@ -0,0 +1,109 @@ +#ifndef _LINUX_FDREG_H +#define _LINUX_FDREG_H +/* + * This file contains some defines for the floppy disk controller. + * Various sources. Mostly "IBM Microcomputers: A Programmers + * Handbook", Sanches and Canton. + */ + +#ifdef FDPATCHES + +#define FD_IOPORT fdc_state[fdc].address + +/* Fd controller regs. S&C, about page 340 */ +#define FD_STATUS (4 + FD_IOPORT ) +#define FD_DATA (5 + FD_IOPORT ) + +/* Digital Output Register */ +#define FD_DOR (2 + FD_IOPORT ) + +/* Digital Input Register (read) */ +#define FD_DIR (7 + FD_IOPORT ) + +/* Diskette Control Register (write)*/ +#define FD_DCR (7 + FD_IOPORT ) + +#else + +#define FD_STATUS 0x3f4 +#define FD_DATA 0x3f5 +#define FD_DOR 0x3f2 /* Digital Output Register */ +#define FD_DIR 0x3f7 /* Digital Input Register (read) */ +#define FD_DCR 0x3f7 /* Diskette Control Register (write)*/ + +#endif + +/* Bits of main status register */ +#define STATUS_BUSYMASK 0x0F /* drive busy mask */ +#define STATUS_BUSY 0x10 /* FDC busy */ +#define STATUS_DMA 0x20 /* 0- DMA mode */ +#define STATUS_DIR 0x40 /* 0- cpu->fdc */ +#define STATUS_READY 0x80 /* Data reg ready */ + +/* Bits of FD_ST0 */ +#define ST0_DS 0x03 /* drive select mask */ +#define ST0_HA 0x04 /* Head (Address) */ +#define ST0_NR 0x08 /* Not Ready */ +#define ST0_ECE 0x10 /* Equipment chech error */ +#define ST0_SE 0x20 /* Seek end */ +#define ST0_INTR 0xC0 /* Interrupt code mask */ + +/* Bits of FD_ST1 */ +#define ST1_MAM 0x01 /* Missing Address Mark */ +#define ST1_WP 0x02 /* Write Protect */ +#define ST1_ND 0x04 /* No Data - unreadable */ +#define ST1_OR 0x10 /* OverRun */ +#define ST1_CRC 0x20 /* CRC error in data or addr */ +#define ST1_EOC 0x80 /* End Of Cylinder */ + +/* Bits of FD_ST2 */ +#define ST2_MAM 0x01 /* Missing Address Mark (again) */ +#define ST2_BC 0x02 /* Bad Cylinder */ +#define ST2_SNS 0x04 /* Scan Not Satisfied */ +#define ST2_SEH 0x08 /* Scan Equal Hit */ +#define ST2_WC 0x10 /* Wrong Cylinder */ +#define ST2_CRC 0x20 /* CRC error in data field */ +#define ST2_CM 0x40 /* Control Mark = deleted */ + +/* Bits of FD_ST3 */ +#define ST3_HA 0x04 /* Head (Address) */ +#define ST3_DS 0x08 /* drive is double-sided */ +#define ST3_TZ 0x10 /* Track Zero signal (1=track 0) */ +#define ST3_RY 0x20 /* drive is ready */ +#define ST3_WP 0x40 /* Write Protect */ +#define ST3_FT 0x80 /* Drive Fault */ + +/* Values for FD_COMMAND */ +#define FD_RECALIBRATE 0x07 /* move to track 0 */ +#define FD_SEEK 0x0F /* seek track */ +#define FD_READ 0xE6 /* read with MT, MFM, SKip deleted */ +#define FD_WRITE 0xC5 /* write with MT, MFM */ +#define FD_SENSEI 0x08 /* Sense Interrupt Status */ +#define FD_SPECIFY 0x03 /* specify HUT etc */ +#define FD_FORMAT 0x4D /* format one track */ +#define FD_VERSION 0x10 /* get version code */ +#define FD_CONFIGURE 0x13 /* configure FIFO operation */ +#define FD_PERPENDICULAR 0x12 /* perpendicular r/w mode */ +#define FD_GETSTATUS 0x04 /* read ST3 */ +#define FD_DUMPREGS 0x0E /* dump the contents of the fdc regs */ +#define FD_READID 0xEA /* prints the header of a sector */ +#define FD_UNLOCK 0x14 /* Fifo config unlock */ +#define FD_LOCK 0x94 /* Fifo config lock */ +#define FD_RSEEK_OUT 0x8f /* seek out (i.e. to lower tracks) */ +#define FD_RSEEK_IN 0xcf /* seek in (i.e. to higher tracks) */ + +/* DMA commands */ +#define DMA_READ 0x46 +#define DMA_WRITE 0x4A + +/* FDC version return types */ +#define FDC_NONE 0x00 +#define FDC_UNKNOWN 0x10 +#define FDC_8272A 0x20 /* Intel 8272a, NEC 765 */ +#define FDC_765ED 0x30 /* Non-Intel 1MB-compatible FDC, can't detect */ +#define FDC_82072 0x40 /* Intel 82072; 8272a + FIFO + DUMPREGS */ +#define FDC_82077_ORIG 0x50 /* Original version of 82077AA, sans LOCK */ +#define FDC_82077 0x52 /* 82077AA-1 */ + +#define FD_RESET_DELAY 20 +#endif diff --git a/include/linux/fs.h b/include/linux/fs.h new file mode 100644 index 000000000..c2bb6e835 --- /dev/null +++ b/include/linux/fs.h @@ -0,0 +1,526 @@ +#ifndef _LINUX_FS_H +#define _LINUX_FS_H + +/* + * This file has definitions for some important file table + * structures etc. + */ + +#include <linux/linkage.h> +#include <linux/limits.h> +#include <linux/wait.h> +#include <linux/types.h> +#include <linux/dirent.h> +#include <linux/vfs.h> +#include <linux/net.h> + +/* + * It's silly to have NR_OPEN bigger than NR_FILE, but I'll fix + * that later. Anyway, now the file code is no longer dependent + * on bitmaps in unsigned longs, but uses the new fd_set structure.. + * + * Some programs (notably those using select()) may have to be + * recompiled to take full advantage of the new limits.. + */ +#undef NR_OPEN +#define NR_OPEN 256 + +#define NR_INODE 2048 /* this should be bigger than NR_FILE */ +#define NR_FILE 1024 /* this can well be larger on a larger system */ +#define NR_SUPER 32 +#define NR_IHASH 131 +#define BLOCK_SIZE 1024 +#define BLOCK_SIZE_BITS 10 + +#define MAY_EXEC 1 +#define MAY_WRITE 2 +#define MAY_READ 4 + +#define READ 0 +#define WRITE 1 +#define READA 2 /* read-ahead - don't pause */ +#define WRITEA 3 /* "write-ahead" - silly, but somewhat useful */ + +extern void buffer_init(void); +extern unsigned long inode_init(unsigned long start, unsigned long end); +extern unsigned long file_table_init(unsigned long start, unsigned long end); +extern unsigned long name_cache_init(unsigned long start, unsigned long end); + +#define MAJOR(a) (int)((unsigned short)(a) >> 8) +#define MINOR(a) (int)((unsigned short)(a) & 0xFF) +#define MKDEV(a,b) ((int)((((a) & 0xff) << 8) | ((b) & 0xff))) +#define NODEV MKDEV(0,0) + +#ifndef NULL +#define NULL ((void *) 0) +#endif + +#define NIL_FILP ((struct file *)0) +#define SEL_IN 1 +#define SEL_OUT 2 +#define SEL_EX 4 + +/* + * These are the fs-independent mount-flags: up to 16 flags are supported + */ +#define MS_RDONLY 1 /* mount read-only */ +#define MS_NOSUID 2 /* ignore suid and sgid bits */ +#define MS_NODEV 4 /* disallow access to device special files */ +#define MS_NOEXEC 8 /* disallow program execution */ +#define MS_SYNC 16 /* writes are synced at once */ +#define MS_REMOUNT 32 /* alter flags of a mounted FS */ + +#define S_APPEND 256 /* append-only file */ +#define S_IMMUTABLE 512 /* immutable file */ + +/* + * Flags that can be altered by MS_REMOUNT + */ +#define MS_RMT_MASK (MS_RDONLY) + +/* + * Magic mount flag number. Has to be or-ed to the flag values. + */ +#define MS_MGC_VAL 0xC0ED0000 /* magic flag number to indicate "new" flags */ +#define MS_MGC_MSK 0xffff0000 /* magic flag number mask */ + +/* + * Note that read-only etc flags are inode-specific: setting some file-system + * flags just means all the inodes inherit those flags by default. It might be + * possible to override it selectively if you really wanted to with some + * ioctl() that is not currently implemented. + * + * Exception: MS_RDONLY is always applied to the entire file system. + */ +#define IS_RDONLY(inode) (((inode)->i_sb) && ((inode)->i_sb->s_flags & MS_RDONLY)) +#define IS_NOSUID(inode) ((inode)->i_flags & MS_NOSUID) +#define IS_NODEV(inode) ((inode)->i_flags & MS_NODEV) +#define IS_NOEXEC(inode) ((inode)->i_flags & MS_NOEXEC) +#define IS_SYNC(inode) ((inode)->i_flags & MS_SYNC) + +#define IS_APPEND(inode) ((inode)->i_flags & S_APPEND) +#define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE) + +/* the read-only stuff doesn't really belong here, but any other place is + probably as bad and I don't want to create yet another include file. */ + +#define BLKROSET 4701 /* set device read-only (0 = read-write) */ +#define BLKROGET 4702 /* get read-only status (0 = read_write) */ +#define BLKRRPART 4703 /* re-read partition table */ +#define BLKGETSIZE 4704 /* return device size */ +#define BLKFLSBUF 4705 /* flush buffer cache */ +#define BLKRASET 4706 /* Set read ahead for block device */ +#define BLKRAGET 4707 /* get current read ahead setting */ + +/* These are a few other constants only used by scsi devices */ + +#define SCSI_IOCTL_GET_IDLUN 0x5382 + +/* Used to turn on and off tagged queuing for scsi devices */ + +#define SCSI_IOCTL_TAGGED_ENABLE 0x5383 +#define SCSI_IOCTL_TAGGED_DISABLE 0x5384 + + +#define BMAP_IOCTL 1 /* obsolete - kept for compatibility */ +#define FIBMAP 1 /* bmap access */ +#define FIGETBSZ 2 /* get the block size used for bmap */ + +typedef char buffer_block[BLOCK_SIZE]; + +struct buffer_head { + char * b_data; /* pointer to data block (1024 bytes) */ + unsigned long b_size; /* block size */ + unsigned long b_blocknr; /* block number */ + dev_t b_dev; /* device (0 = free) */ + unsigned short b_count; /* users using this block */ + unsigned char b_uptodate; + unsigned char b_dirt; /* 0-clean,1-dirty */ + unsigned char b_lock; /* 0 - ok, 1 -locked */ + unsigned char b_req; /* 0 if the buffer has been invalidated */ + unsigned char b_list; /* List that this buffer appears */ + unsigned char b_retain; /* Expected number of times this will + be used. Put on freelist when 0 */ + unsigned long b_flushtime; /* Time when this (dirty) buffer should be written */ + unsigned long b_lru_time; /* Time when this buffer was last used. */ + struct wait_queue * b_wait; + struct buffer_head * b_prev; /* doubly linked list of hash-queue */ + struct buffer_head * b_next; + struct buffer_head * b_prev_free; /* doubly linked list of buffers */ + struct buffer_head * b_next_free; + struct buffer_head * b_this_page; /* circular list of buffers in one page */ + struct buffer_head * b_reqnext; /* request queue */ +}; + +#include <linux/pipe_fs_i.h> +#include <linux/minix_fs_i.h> +#include <linux/ext_fs_i.h> +#include <linux/ext2_fs_i.h> +#include <linux/hpfs_fs_i.h> +#include <linux/msdos_fs_i.h> +#include <linux/umsdos_fs_i.h> +#include <linux/iso_fs_i.h> +#include <linux/nfs_fs_i.h> +#include <linux/xia_fs_i.h> +#include <linux/sysv_fs_i.h> + +#ifdef __KERNEL__ + +/* + * Attribute flags. These should be or-ed together to figure out what + * has been changed! + */ +#define ATTR_MODE 1 +#define ATTR_UID 2 +#define ATTR_GID 4 +#define ATTR_SIZE 8 +#define ATTR_ATIME 16 +#define ATTR_MTIME 32 +#define ATTR_CTIME 64 +#define ATTR_ATIME_SET 128 +#define ATTR_MTIME_SET 256 + +/* + * This is the Inode Attributes structure, used for notify_change(). It + * uses the above definitions as flags, to know which values have changed. + * Also, in this manner, a Filesystem can look at only the values it cares + * about. Basically, these are the attributes that the VFS layer can + * request to change from the FS layer. + * + * Derek Atkins <warlord@MIT.EDU> 94-10-20 + */ +struct iattr { + unsigned int ia_valid; + umode_t ia_mode; + uid_t ia_uid; + gid_t ia_gid; + off_t ia_size; + time_t ia_atime; + time_t ia_mtime; + time_t ia_ctime; +}; + +struct inode { + dev_t i_dev; + unsigned long i_ino; + umode_t i_mode; + nlink_t i_nlink; + uid_t i_uid; + gid_t i_gid; + dev_t i_rdev; + off_t i_size; + time_t i_atime; + time_t i_mtime; + time_t i_ctime; + unsigned long i_blksize; + unsigned long i_blocks; + unsigned long i_version; + struct semaphore i_sem; + struct inode_operations * i_op; + struct super_block * i_sb; + struct wait_queue * i_wait; + struct file_lock * i_flock; + struct vm_area_struct * i_mmap; + struct inode * i_next, * i_prev; + struct inode * i_hash_next, * i_hash_prev; + struct inode * i_bound_to, * i_bound_by; + struct inode * i_mount; + struct socket * i_socket; + unsigned short i_count; + unsigned short i_wcount; + unsigned short i_flags; + unsigned char i_lock; + unsigned char i_dirt; + unsigned char i_pipe; + unsigned char i_seek; + unsigned char i_update; + union { + struct pipe_inode_info pipe_i; + struct minix_inode_info minix_i; + struct ext_inode_info ext_i; + struct ext2_inode_info ext2_i; + struct hpfs_inode_info hpfs_i; + struct msdos_inode_info msdos_i; + struct umsdos_inode_info umsdos_i; + struct iso_inode_info isofs_i; + struct nfs_inode_info nfs_i; + struct xiafs_inode_info xiafs_i; + struct sysv_inode_info sysv_i; + void * generic_ip; + } u; +}; + +struct file { + mode_t f_mode; + loff_t f_pos; + unsigned short f_flags; + unsigned short f_count; + off_t f_reada; + struct file *f_next, *f_prev; + int f_owner; /* pid or -pgrp where SIGIO should be sent */ + struct inode * f_inode; + struct file_operations * f_op; + unsigned long f_version; + void *private_data; /* needed for tty driver, and maybe others */ +}; + +struct file_lock { + struct file_lock *fl_next; /* singly linked list */ + struct file_lock *fl_nextlink; + struct task_struct *fl_owner; /* NULL if on free list, for sanity checks */ + unsigned int fl_fd; /* File descriptor for this lock */ + struct wait_queue *fl_wait; + char fl_type; + char fl_whence; + off_t fl_start; + off_t fl_end; +}; + +struct fasync_struct { + int magic; + struct fasync_struct *fa_next; /* singly linked list */ + struct file *fa_file; +}; + +#define FASYNC_MAGIC 0x4601 + +#include <linux/minix_fs_sb.h> +#include <linux/ext_fs_sb.h> +#include <linux/ext2_fs_sb.h> +#include <linux/hpfs_fs_sb.h> +#include <linux/msdos_fs_sb.h> +#include <linux/iso_fs_sb.h> +#include <linux/nfs_fs_sb.h> +#include <linux/xia_fs_sb.h> +#include <linux/sysv_fs_sb.h> + +struct super_block { + dev_t s_dev; + unsigned long s_blocksize; + unsigned char s_blocksize_bits; + unsigned char s_lock; + unsigned char s_rd_only; + unsigned char s_dirt; + struct super_operations *s_op; + unsigned long s_flags; + unsigned long s_magic; + unsigned long s_time; + struct inode * s_covered; + struct inode * s_mounted; + struct wait_queue * s_wait; + union { + struct minix_sb_info minix_sb; + struct ext_sb_info ext_sb; + struct ext2_sb_info ext2_sb; + struct hpfs_sb_info hpfs_sb; + struct msdos_sb_info msdos_sb; + struct isofs_sb_info isofs_sb; + struct nfs_sb_info nfs_sb; + struct xiafs_sb_info xiafs_sb; + struct sysv_sb_info sysv_sb; + void *generic_sbp; + } u; +}; + +struct file_operations { + int (*lseek) (struct inode *, struct file *, off_t, int); + int (*read) (struct inode *, struct file *, char *, int); + int (*write) (struct inode *, struct file *, char *, int); + int (*readdir) (struct inode *, struct file *, struct dirent *, int); + int (*select) (struct inode *, struct file *, int, select_table *); + int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long); + int (*mmap) (struct inode *, struct file *, struct vm_area_struct *); + int (*open) (struct inode *, struct file *); + void (*release) (struct inode *, struct file *); + int (*fsync) (struct inode *, struct file *); + int (*fasync) (struct inode *, struct file *, int); + int (*check_media_change) (dev_t dev); + int (*revalidate) (dev_t dev); +}; + +struct inode_operations { + struct file_operations * default_file_ops; + int (*create) (struct inode *,const char *,int,int,struct inode **); + int (*lookup) (struct inode *,const char *,int,struct inode **); + int (*link) (struct inode *,struct inode *,const char *,int); + int (*unlink) (struct inode *,const char *,int); + int (*symlink) (struct inode *,const char *,int,const char *); + int (*mkdir) (struct inode *,const char *,int,int); + int (*rmdir) (struct inode *,const char *,int); + int (*mknod) (struct inode *,const char *,int,int,int); + int (*rename) (struct inode *,const char *,int,struct inode *,const char *,int); + int (*readlink) (struct inode *,char *,int); + int (*follow_link) (struct inode *,struct inode *,int,int,struct inode **); + int (*bmap) (struct inode *,int); + void (*truncate) (struct inode *); + int (*permission) (struct inode *, int); + int (*smap) (struct inode *,int); +}; + +struct super_operations { + void (*read_inode) (struct inode *); + int (*notify_change) (struct inode *, struct iattr *); + void (*write_inode) (struct inode *); + void (*put_inode) (struct inode *); + void (*put_super) (struct super_block *); + void (*write_super) (struct super_block *); + void (*statfs) (struct super_block *, struct statfs *); + int (*remount_fs) (struct super_block *, int *, char *); +}; + +struct file_system_type { + struct super_block *(*read_super) (struct super_block *, void *, int); + char *name; + int requires_dev; + struct file_system_type * next; +}; + +extern int register_filesystem(struct file_system_type *); +extern int unregister_filesystem(struct file_system_type *); + +asmlinkage int sys_open(const char *, int, int); +asmlinkage int sys_close(unsigned int); /* yes, it's really unsigned */ + +extern void kill_fasync(struct fasync_struct *fa, int sig); + +extern int getname(const char * filename, char **result); +extern void putname(char * name); + +extern int register_blkdev(unsigned int, const char *, struct file_operations *); +extern int unregister_blkdev(unsigned int major, const char * name); +extern int blkdev_open(struct inode * inode, struct file * filp); +extern struct file_operations def_blk_fops; +extern struct inode_operations blkdev_inode_operations; + +extern int register_chrdev(unsigned int, const char *, struct file_operations *); +extern int unregister_chrdev(unsigned int major, const char * name); +extern int chrdev_open(struct inode * inode, struct file * filp); +extern struct file_operations def_chr_fops; +extern struct inode_operations chrdev_inode_operations; + +extern void init_fifo(struct inode * inode); + +extern struct file_operations connecting_fifo_fops; +extern struct file_operations read_fifo_fops; +extern struct file_operations write_fifo_fops; +extern struct file_operations rdwr_fifo_fops; +extern struct file_operations read_pipe_fops; +extern struct file_operations write_pipe_fops; +extern struct file_operations rdwr_pipe_fops; + +extern struct file_system_type *get_fs_type(char *name); + +extern int fs_may_mount(dev_t dev); +extern int fs_may_umount(dev_t dev, struct inode * mount_root); +extern int fs_may_remount_ro(dev_t dev); + +extern struct file *first_file; +extern int nr_files; +extern struct super_block super_blocks[NR_SUPER]; + +extern int shrink_buffers(unsigned int priority); +extern void refile_buffer(struct buffer_head * buf); +extern void set_writetime(struct buffer_head * buf, int flag); +extern void refill_freelist(int size); + +extern struct buffer_head ** buffer_pages; +extern int nr_buffers; +extern int buffermem; +extern int nr_buffer_heads; + +#define BUF_CLEAN 0 +#define BUF_UNSHARED 1 /* Buffers that were shared but are not any more */ +#define BUF_LOCKED 2 /* Buffers scheduled for write */ +#define BUF_LOCKED1 3 /* Supers, inodes */ +#define BUF_DIRTY 4 /* Dirty buffers, not yet scheduled for write */ +#define BUF_SHARED 5 /* Buffers shared */ +#define NR_LIST 6 + +extern inline void mark_buffer_clean(struct buffer_head * bh) +{ + if(bh->b_dirt) { + bh->b_dirt = 0; + if(bh->b_list == BUF_DIRTY) refile_buffer(bh); + } +} + +extern inline void mark_buffer_dirty(struct buffer_head * bh, int flag) +{ + if(!bh->b_dirt) { + bh->b_dirt = 1; + set_writetime(bh, flag); + if(bh->b_list != BUF_DIRTY) refile_buffer(bh); + } +} + + +extern int check_disk_change(dev_t dev); +extern void invalidate_inodes(dev_t dev); +extern void invalidate_buffers(dev_t dev); +extern int floppy_is_wp(int minor); +extern void sync_inodes(dev_t dev); +extern void sync_dev(dev_t dev); +extern int fsync_dev(dev_t dev); +extern void sync_supers(dev_t dev); +extern int bmap(struct inode * inode,int block); +extern int notify_change(struct inode *, struct iattr *); +extern int namei(const char * pathname, struct inode ** res_inode); +extern int lnamei(const char * pathname, struct inode ** res_inode); +extern int permission(struct inode * inode,int mask); +extern int get_write_access(struct inode * inode); +extern void put_write_access(struct inode * inode); +extern int open_namei(const char * pathname, int flag, int mode, + struct inode ** res_inode, struct inode * base); +extern int do_mknod(const char * filename, int mode, dev_t dev); +extern void iput(struct inode * inode); +extern struct inode * __iget(struct super_block * sb,int nr,int crsmnt); +extern struct inode * get_empty_inode(void); +extern void insert_inode_hash(struct inode *); +extern void clear_inode(struct inode *); +extern struct inode * get_pipe_inode(void); +extern struct file * get_empty_filp(void); +extern struct buffer_head * get_hash_table(dev_t dev, int block, int size); +extern struct buffer_head * getblk(dev_t dev, int block, int size); +extern void ll_rw_block(int rw, int nr, struct buffer_head * bh[]); +extern void ll_rw_page(int rw, int dev, int nr, char * buffer); +extern void ll_rw_swap_file(int rw, int dev, unsigned int *b, int nb, char *buffer); +extern int is_read_only(int dev); +extern void brelse(struct buffer_head * buf); +extern void set_blocksize(dev_t dev, int size); +extern struct buffer_head * bread(dev_t dev, int block, int size); +extern unsigned long bread_page(unsigned long addr,dev_t dev,int b[],int size,int no_share); +extern struct buffer_head * breada(dev_t dev,int block, int size, + unsigned int pos, unsigned int filesize); +extern void put_super(dev_t dev); +unsigned long generate_cluster(dev_t dev, int b[], int size); +extern dev_t ROOT_DEV; + +extern void show_buffers(void); +extern void mount_root(void); + +extern int char_read(struct inode *, struct file *, char *, int); +extern int block_read(struct inode *, struct file *, char *, int); +extern int read_ahead[]; + +extern int char_write(struct inode *, struct file *, char *, int); +extern int block_write(struct inode *, struct file *, char *, int); + +extern int generic_mmap(struct inode *, struct file *, struct vm_area_struct *); + +extern int block_fsync(struct inode *, struct file *); +extern int file_fsync(struct inode *, struct file *); + +extern void dcache_add(struct inode *, const char *, int, unsigned long); +extern int dcache_lookup(struct inode *, const char *, int, unsigned long *); + +extern int inode_change_ok(struct inode *, struct iattr *); +extern void inode_setattr(struct inode *, struct iattr *); + +extern inline struct inode * iget(struct super_block * sb,int nr) +{ + return __iget(sb,nr,1); +} + +#endif /* __KERNEL__ */ + +#endif diff --git a/include/linux/genhd.h b/include/linux/genhd.h new file mode 100644 index 000000000..8ff890e48 --- /dev/null +++ b/include/linux/genhd.h @@ -0,0 +1,52 @@ +#ifndef _LINUX_GENHD_H +#define _LINUX_GENHD_H + +/* + * genhd.h Copyright (C) 1992 Drew Eckhardt + * Generic hard disk header file by + * Drew Eckhardt + * + * <drew@colorado.edu> + */ + +#define EXTENDED_PARTITION 5 + +struct partition { + unsigned char boot_ind; /* 0x80 - active */ + unsigned char head; /* starting head */ + unsigned char sector; /* starting sector */ + unsigned char cyl; /* starting cylinder */ + unsigned char sys_ind; /* What partition type */ + unsigned char end_head; /* end head */ + unsigned char end_sector; /* end sector */ + unsigned char end_cyl; /* end cylinder */ + unsigned int start_sect; /* starting sector counting from 0 */ + unsigned int nr_sects; /* nr of sectors in partition */ +}; + +struct hd_struct { + long start_sect; + long nr_sects; +}; + +struct gendisk { + int major; /* major number of driver */ + char *major_name; /* name of major driver */ + int minor_shift; /* number of times minor is shifted to + get real minor */ + int max_p; /* maximum partitions per device */ + int max_nr; /* maximum number of real devices */ + + void (*init)(void); /* Initialization called before we do our thing */ + struct hd_struct *part; /* partition table */ + int *sizes; /* size of device in blocks */ + int nr_real; /* number of real devices */ + + void *real_devices; /* internal use */ + struct gendisk *next; +}; + +extern int NR_GENDISKS; /* total */ +extern struct gendisk *gendisk_head; /* linked list of disks */ + +#endif diff --git a/include/linux/hdreg.h b/include/linux/hdreg.h new file mode 100644 index 000000000..df88b8720 --- /dev/null +++ b/include/linux/hdreg.h @@ -0,0 +1,136 @@ +#ifndef _LINUX_HDREG_H +#define _LINUX_HDREG_H + +/* + * This file contains some defines for the AT-hd-controller. + * Various sources. Check out some definitions (see comments with + * a ques). + */ + +/* Hd controller regs. Ref: IBM AT Bios-listing */ +/* For a second IDE interface, xor all addresses with 0x80 */ +#define HD_DATA 0x1f0 /* _CTL when writing */ +#define HD_ERROR 0x1f1 /* see err-bits */ +#define HD_NSECTOR 0x1f2 /* nr of sectors to read/write */ +#define HD_SECTOR 0x1f3 /* starting sector */ +#define HD_LCYL 0x1f4 /* starting cylinder */ +#define HD_HCYL 0x1f5 /* high byte of starting cyl */ +#define HD_CURRENT 0x1f6 /* 101dhhhh , d=drive, hhhh=head */ +#define HD_STATUS 0x1f7 /* see status-bits */ +#define HD_FEATURE HD_ERROR /* same io address, read=error, write=feature */ +#define HD_PRECOMP HD_FEATURE /* obsolete use of this port - predates IDE */ +#define HD_COMMAND HD_STATUS /* same io address, read=status, write=cmd */ + +#define HD_CMD 0x3f6 /* used for resets */ +#define HD_ALTSTATUS 0x3f6 /* same as HD_STATUS but doesn't clear irq */ + +/* Bits of HD_STATUS */ +#define ERR_STAT 0x01 +#define INDEX_STAT 0x02 +#define ECC_STAT 0x04 /* Corrected error */ +#define DRQ_STAT 0x08 +#define SEEK_STAT 0x10 +#define WRERR_STAT 0x20 +#define READY_STAT 0x40 +#define BUSY_STAT 0x80 + +/* Values for HD_COMMAND */ +#define WIN_RESTORE 0x10 +#define WIN_READ 0x20 +#define WIN_WRITE 0x30 +#define WIN_VERIFY 0x40 +#define WIN_FORMAT 0x50 +#define WIN_INIT 0x60 +#define WIN_SEEK 0x70 +#define WIN_DIAGNOSE 0x90 +#define WIN_SPECIFY 0x91 +#define WIN_SETIDLE 0x97 + +#define WIN_PIDENTIFY 0xA1 /* identify ATA-PI device */ +#define WIN_MULTREAD 0xC4 /* read multiple sectors */ +#define WIN_MULTWRITE 0xC5 /* write multiple sectors */ +#define WIN_SETMULT 0xC6 /* enable read multiple */ +#define WIN_IDENTIFY 0xEC /* ask drive to identify itself */ +#define WIN_SETFEATURES 0xEF /* set special drive features */ + +/* Bits for HD_ERROR */ +#define MARK_ERR 0x01 /* Bad address mark */ +#define TRK0_ERR 0x02 /* couldn't find track 0 */ +#define ABRT_ERR 0x04 /* Command aborted */ +#define ID_ERR 0x10 /* ID field not found */ +#define ECC_ERR 0x40 /* Uncorrectable ECC error */ +#define BBD_ERR 0x80 /* block marked bad */ + +struct hd_geometry { + unsigned char heads; + unsigned char sectors; + unsigned short cylinders; + unsigned long start; +}; + +/* hd/ide ctl's that pass (arg) ptrs to user space are numbered 0x30n/0x31n */ +#define HDIO_GETGEO 0x301 /* get device geometry */ +#define HDIO_REQ HDIO_GETGEO /* obsolete, use HDIO_GETGEO */ +#define HDIO_GET_UNMASKINTR 0x302 /* get current unmask setting */ +#define HDIO_SETUNMASKINTR 0x303 /* obsolete */ +#define HDIO_GET_MULTCOUNT 0x304 /* get current IDE blockmode setting */ +#define HDIO_SETMULTCOUNT 0x305 /* obsolete */ +#define HDIO_GET_IDENTITY 0x307 /* get IDE identification info */ + +/* hd/ide ctl's that pass (arg) non-ptr values are numbered 0x32n/0x33n */ +#define HDIO_SET_MULTCOUNT 0x321 /* set IDE blockmode */ +#define HDIO_SET_UNMASKINTR 0x322 /* permit other irqs during I/O */ +#define HDIO_SET_KEEPSETTINGS 0x323 /* keep ioctl settings on reset */ +#define HDIO_SET_XFERMODE 0x324 /* set IDE transfer mode */ + +/* structure returned by HDIO_GET_IDENTITY, as per ANSI ATA2 rev.2f spec */ +struct hd_driveid { + unsigned short config; /* lots of obsolete bit flags */ + unsigned short cyls; /* "physical" cyls */ + unsigned short reserved2; /* reserved (word 2) */ + unsigned short heads; /* "physical" heads */ + unsigned short track_bytes; /* unformatted bytes per track */ + unsigned short sector_bytes; /* unformatted bytes per sector */ + unsigned short sectors; /* "physical" sectors per track */ + unsigned short vendor0; /* vendor unique */ + unsigned short vendor1; /* vendor unique */ + unsigned short vendor2; /* vendor unique */ + unsigned char serial_no[20]; /* 0 = not_specified */ + unsigned short buf_type; + unsigned short buf_size; /* 512 byte increments; 0 = not_specified */ + unsigned short ecc_bytes; /* for r/w long cmds; 0 = not_specified */ + unsigned char fw_rev[8]; /* 0 = not_specified */ + unsigned char model[40]; /* 0 = not_specified */ + unsigned char max_multsect; /* 0=not_implemented */ + unsigned char vendor3; /* vendor unique */ + unsigned short dword_io; /* 0=not_implemented; 1=implemented */ + unsigned char vendor4; /* vendor unique */ + unsigned char capability; /* bits 0:DMA 1:LBA 2:IORDYsw 3:IORDYsup*/ + unsigned short reserved50; /* reserved (word 50) */ + unsigned char vendor5; /* vendor unique */ + unsigned char tPIO; /* 0=slow, 1=medium, 2=fast */ + unsigned char vendor6; /* vendor unique */ + unsigned char tDMA; /* 0=slow, 1=medium, 2=fast */ + unsigned short field_valid; /* bits 0:cur_ok 1:eide_ok */ + unsigned short cur_cyls; /* logical cylinders */ + unsigned short cur_heads; /* logical heads */ + unsigned short cur_sectors; /* logical sectors per track */ + unsigned short cur_capacity0; /* logical total sectors on drive */ + unsigned short cur_capacity1; /* (2 words, misaligned int) */ + unsigned char multsect; /* current multiple sector count */ + unsigned char multsect_valid; /* when (bit0==1) multsect is ok */ + unsigned int lba_capacity; /* total number of sectors */ + unsigned short dma_1word; /* single-word dma info */ + unsigned short dma_mword; /* multiple-word dma info */ + unsigned short eide_pio_modes; /* bits 0:mode3 1:mode4 */ + unsigned short eide_dma_min; /* min mword dma cycle time (ns) */ + unsigned short eide_dma_time; /* recommended mword dma cycle time (ns) */ + unsigned short eide_pio; /* min cycle time (ns), no IORDY */ + unsigned short eide_pio_iordy; /* min cycle time (ns), with IORDY */ + unsigned short reserved69; /* reserved (word 69) */ + unsigned short reserved70; /* reserved (word 70) */ + /* unsigned short reservedxx[57];*/ /* reserved (words 71-127) */ + /* unsigned short vendor7 [32];*/ /* vendor unique (words 128-159) */ + /* unsigned short reservedyy[96];*/ /* reserved (words 160-255) */ +}; +#endif diff --git a/include/linux/head.h b/include/linux/head.h new file mode 100644 index 000000000..8911a6819 --- /dev/null +++ b/include/linux/head.h @@ -0,0 +1,20 @@ +#ifndef _LINUX_HEAD_H +#define _LINUX_HEAD_H + +typedef struct desc_struct { + unsigned long a,b; +} desc_table[256]; + +extern unsigned long swapper_pg_dir[1024]; +extern desc_table idt,gdt; + +#define GDT_NUL 0 +#define GDT_CODE 1 +#define GDT_DATA 2 +#define GDT_TMP 3 + +#define LDT_NUL 0 +#define LDT_CODE 1 +#define LDT_DATA 2 + +#endif diff --git a/include/linux/hpfs_fs.h b/include/linux/hpfs_fs.h new file mode 100644 index 000000000..0094c359c --- /dev/null +++ b/include/linux/hpfs_fs.h @@ -0,0 +1,12 @@ +#ifndef _LINUX_HPFS_FS_H +#define _LINUX_HPFS_FS_H + +/* HPFS magic number (word 0 of block 16) */ + +#define HPFS_SUPER_MAGIC 0xf995e849 + +/* The entry point for a VFS */ + +extern struct super_block *hpfs_read_super (struct super_block *, void *, int); + +#endif diff --git a/include/linux/hpfs_fs_i.h b/include/linux/hpfs_fs_i.h new file mode 100644 index 000000000..d9aa8f34d --- /dev/null +++ b/include/linux/hpfs_fs_i.h @@ -0,0 +1,24 @@ +#ifndef _HPFS_FS_I +#define _HPFS_FS_I + +struct hpfs_inode_info { + ino_t i_parent_dir; /* (directories) gives fnode of parent dir */ + unsigned i_dno; /* (directories) root dnode */ + unsigned i_dpos; /* (directories) temp for readdir */ + unsigned i_dsubdno; /* (directories) temp for readdir */ + unsigned i_file_sec; /* (files) minimalist cache of alloc info */ + unsigned i_disk_sec; /* (files) minimalist cache of alloc info */ + unsigned i_n_secs; /* (files) minimalist cache of alloc info */ + unsigned i_conv : 2; /* (files) crlf->newline hackery */ +}; + +#define i_hpfs_dno u.hpfs_i.i_dno +#define i_hpfs_parent_dir u.hpfs_i.i_parent_dir +#define i_hpfs_n_secs u.hpfs_i.i_n_secs +#define i_hpfs_file_sec u.hpfs_i.i_file_sec +#define i_hpfs_disk_sec u.hpfs_i.i_disk_sec +#define i_hpfs_dpos u.hpfs_i.i_dpos +#define i_hpfs_dsubdno u.hpfs_i.i_dsubdno +#define i_hpfs_conv u.hpfs_i.i_conv + +#endif diff --git a/include/linux/hpfs_fs_sb.h b/include/linux/hpfs_fs_sb.h new file mode 100644 index 000000000..a383e16ba --- /dev/null +++ b/include/linux/hpfs_fs_sb.h @@ -0,0 +1,32 @@ +#ifndef _HPFS_FS_SB +#define _HPFS_FS_SB + +struct hpfs_sb_info { + ino_t sb_root; /* inode number of root dir */ + unsigned sb_fs_size; /* file system size, sectors */ + unsigned sb_bitmaps; /* sector number of bitmap list */ + unsigned sb_dirband_size; /* directory band size, dnodes */ + unsigned sb_dmap; /* sector number of dnode bit map */ + unsigned sb_n_free; /* free blocks for statfs, or -1 */ + unsigned sb_n_free_dnodes; /* free dnodes for statfs, or -1 */ + uid_t sb_uid; /* uid from mount options */ + gid_t sb_gid; /* gid from mount options */ + umode_t sb_mode; /* mode from mount options */ + unsigned sb_lowercase : 1; /* downcase filenames hackery */ + unsigned sb_conv : 2; /* crlf->newline hackery */ +}; + +#define s_hpfs_root u.hpfs_sb.sb_root +#define s_hpfs_fs_size u.hpfs_sb.sb_fs_size +#define s_hpfs_bitmaps u.hpfs_sb.sb_bitmaps +#define s_hpfs_dirband_size u.hpfs_sb.sb_dirband_size +#define s_hpfs_dmap u.hpfs_sb.sb_dmap +#define s_hpfs_uid u.hpfs_sb.sb_uid +#define s_hpfs_gid u.hpfs_sb.sb_gid +#define s_hpfs_mode u.hpfs_sb.sb_mode +#define s_hpfs_n_free u.hpfs_sb.sb_n_free +#define s_hpfs_n_free_dnodes u.hpfs_sb.sb_n_free_dnodes +#define s_hpfs_lowercase u.hpfs_sb.sb_lowercase +#define s_hpfs_conv u.hpfs_sb.sb_conv + +#endif diff --git a/include/linux/icmp.h b/include/linux/icmp.h new file mode 100644 index 000000000..ca1e8c6bf --- /dev/null +++ b/include/linux/icmp.h @@ -0,0 +1,81 @@ +/* + * INET An implementation of the TCP/IP protocol suite for the LINUX + * operating system. INET is implemented using the BSD Socket + * interface as the means of communication with the user level. + * + * Definitions for the ICMP protocol. + * + * Version: @(#)icmp.h 1.0.3 04/28/93 + * + * Author: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> + * + * 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. + */ +#ifndef _LINUX_ICMP_H +#define _LINUX_ICMP_H + +#define ICMP_ECHOREPLY 0 /* Echo Reply */ +#define ICMP_DEST_UNREACH 3 /* Destination Unreachable */ +#define ICMP_SOURCE_QUENCH 4 /* Source Quench */ +#define ICMP_REDIRECT 5 /* Redirect (change route) */ +#define ICMP_ECHO 8 /* Echo Request */ +#define ICMP_TIME_EXCEEDED 11 /* Time Exceeded */ +#define ICMP_PARAMETERPROB 12 /* Parameter Problem */ +#define ICMP_TIMESTAMP 13 /* Timestamp Request */ +#define ICMP_TIMESTAMPREPLY 14 /* Timestamp Reply */ +#define ICMP_INFO_REQUEST 15 /* Information Request */ +#define ICMP_INFO_REPLY 16 /* Information Reply */ +#define ICMP_ADDRESS 17 /* Address Mask Request */ +#define ICMP_ADDRESSREPLY 18 /* Address Mask Reply */ + + +/* Codes for UNREACH. */ +#define ICMP_NET_UNREACH 0 /* Network Unreachable */ +#define ICMP_HOST_UNREACH 1 /* Host Unreachable */ +#define ICMP_PROT_UNREACH 2 /* Protocol Unreachable */ +#define ICMP_PORT_UNREACH 3 /* Port Unreachable */ +#define ICMP_FRAG_NEEDED 4 /* Fragmentation Needed/DF set */ +#define ICMP_SR_FAILED 5 /* Source Route failed */ +#define ICMP_NET_UNKNOWN 6 +#define ICMP_HOST_UNKNOWN 7 +#define ICMP_HOST_ISOLATED 8 +#define ICMP_NET_ANO 9 +#define ICMP_HOST_ANO 10 +#define ICMP_NET_UNR_TOS 11 +#define ICMP_HOST_UNR_TOS 12 + +/* Codes for REDIRECT. */ +#define ICMP_REDIR_NET 0 /* Redirect Net */ +#define ICMP_REDIR_HOST 1 /* Redirect Host */ +#define ICMP_REDIR_NETTOS 2 /* Redirect Net for TOS */ +#define ICMP_REDIR_HOSTTOS 3 /* Redirect Host for TOS */ + +/* Codes for TIME_EXCEEDED. */ +#define ICMP_EXC_TTL 0 /* TTL count exceeded */ +#define ICMP_EXC_FRAGTIME 1 /* Fragment Reass time exceeded */ + + +struct icmphdr { + unsigned char type; + unsigned char code; + unsigned short checksum; + union { + struct { + unsigned short id; + unsigned short sequence; + } echo; + unsigned long gateway; + } un; +}; + + +struct icmp_err { + int errno; + unsigned fatal:1; +}; + + +#endif /* _LINUX_ICMP_H */ diff --git a/include/linux/if.h b/include/linux/if.h new file mode 100644 index 000000000..63eeab9ed --- /dev/null +++ b/include/linux/if.h @@ -0,0 +1,145 @@ +/* + * INET An implementation of the TCP/IP protocol suite for the LINUX + * operating system. INET is implemented using the BSD Socket + * interface as the means of communication with the user level. + * + * Global definitions for the INET interface module. + * + * Version: @(#)if.h 1.0.2 04/18/93 + * + * Authors: Original taken from Berkeley UNIX 4.3, (c) UCB 1982-1988 + * Ross Biro, <bir7@leland.Stanford.Edu> + * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> + * + * 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. + */ +#ifndef _LINUX_IF_H +#define _LINUX_IF_H + +#include <linux/types.h> /* for "caddr_t" et al */ +#include <linux/socket.h> /* for "struct sockaddr" et al */ + +/* Standard interface flags. */ +#define IFF_UP 0x1 /* interface is up */ +#define IFF_BROADCAST 0x2 /* broadcast address valid */ +#define IFF_DEBUG 0x4 /* turn on debugging */ +#define IFF_LOOPBACK 0x8 /* is a loopback net */ +#define IFF_POINTOPOINT 0x10 /* interface is has p-p link */ +#define IFF_NOTRAILERS 0x20 /* avoid use of trailers */ +#define IFF_RUNNING 0x40 /* resources allocated */ +#define IFF_NOARP 0x80 /* no ARP protocol */ +#define IFF_PROMISC 0x100 /* recve all packets */ +/* These are not yet used: */ +#define IFF_ALLMULTI 0x200 /* recve all multicast packets */ + +#define IFF_MASTER 0x400 /* master of a load balancer */ +#define IFF_SLAVE 0x800 /* slave of a load balancer */ + +/* + * The ifaddr structure contains information about one address + * of an interface. They are maintained by the different address + * families, are allocated and attached when an address is set, + * and are linked together so all addresses for an interface can + * be located. + */ +struct ifaddr { + struct sockaddr ifa_addr; /* address of interface */ + union { + struct sockaddr ifu_broadaddr; + struct sockaddr ifu_dstaddr; + } ifa_ifu; + struct iface *ifa_ifp; /* back-pointer to interface */ + struct ifaddr *ifa_next; /* next address for interface */ +}; +#define ifa_broadaddr ifa_ifu.ifu_broadaddr /* broadcast address */ +#define ifa_dstaddr ifa_ifu.ifu_dstaddr /* other end of link */ + +/* + * Device mapping structure. I'd just gone off and designed a + * beautiful scheme using only loadable modules with arguments + * for driver options and along come the PCMCIA people 8) + * + * Ah well. The get() side of this is good for WDSETUP, and it'll + * be handy for debugging things. The set side is fine for now and + * being very small might be worth keeping for clean configuration. + */ + +struct ifmap { + unsigned long mem_start; + unsigned long mem_end; + unsigned short base_addr; + unsigned char irq; + unsigned char dma; + unsigned char port; + /* 3 bytes spare */ +}; + +/* + * Interface request structure used for socket + * ioctl's. All interface ioctl's must have parameter + * definitions which begin with ifr_name. The + * remainder may be interface specific. + */ +struct ifreq { +#define IFHWADDRLEN 6 +#define IFNAMSIZ 16 + union + { + char ifrn_name[IFNAMSIZ]; /* if name, e.g. "en0" */ + char ifrn_hwaddr[IFHWADDRLEN]; /* Obsolete */ + } ifr_ifrn; + + union { + struct sockaddr ifru_addr; + struct sockaddr ifru_dstaddr; + struct sockaddr ifru_broadaddr; + struct sockaddr ifru_netmask; + struct sockaddr ifru_hwaddr; + short ifru_flags; + int ifru_metric; + int ifru_mtu; + struct ifmap ifru_map; + char ifru_slave[IFNAMSIZ]; /* Just fits the size */ + caddr_t ifru_data; + } ifr_ifru; +}; + +#define ifr_name ifr_ifrn.ifrn_name /* interface name */ +#define old_ifr_hwaddr ifr_ifrn.ifrn_hwaddr /* interface hardware */ +#define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */ +#define ifr_addr ifr_ifru.ifru_addr /* address */ +#define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-p lnk */ +#define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */ +#define ifr_netmask ifr_ifru.ifru_netmask /* interface net mask */ +#define ifr_flags ifr_ifru.ifru_flags /* flags */ +#define ifr_metric ifr_ifru.ifru_metric /* metric */ +#define ifr_mtu ifr_ifru.ifru_mtu /* mtu */ +#define ifr_map ifr_ifru.ifru_map /* device map */ +#define ifr_slave ifr_ifru.ifru_slave /* slave device */ +#define ifr_data ifr_ifru.ifru_data /* for use by interface */ + +/* + * Structure used in SIOCGIFCONF request. + * Used to retrieve interface configuration + * for machine (useful for programs which + * must know all networks accessible). + */ +struct ifconf { + int ifc_len; /* size of buffer */ + union { + caddr_t ifcu_buf; + struct ifreq *ifcu_req; + } ifc_ifcu; +}; +#define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */ +#define ifc_req ifc_ifcu.ifcu_req /* array of structures */ + + +/* BSD UNIX expects to find these here, so here we go: */ +#include <linux/if_arp.h> +#include <linux/route.h> + +#endif /* _NET_IF_H */ diff --git a/include/linux/if_arp.h b/include/linux/if_arp.h new file mode 100644 index 000000000..78b09a6e2 --- /dev/null +++ b/include/linux/if_arp.h @@ -0,0 +1,90 @@ +/* + * INET An implementation of the TCP/IP protocol suite for the LINUX + * operating system. INET is implemented using the BSD Socket + * interface as the means of communication with the user level. + * + * Global definitions for the ARP (RFC 826) protocol. + * + * Version: @(#)if_arp.h 1.0.1 04/16/93 + * + * Authors: Original taken from Berkeley UNIX 4.3, (c) UCB 1986-1988 + * Portions taken from the KA9Q/NOS (v2.00m PA0GRI) source. + * Ross Biro, <bir7@leland.Stanford.Edu> + * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> + * Florian La Roche. + * + * 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. + */ +#ifndef _LINUX_IF_ARP_H +#define _LINUX_IF_ARP_H + +/* ARP protocol HARDWARE identifiers. */ +#define ARPHRD_NETROM 0 /* from KA9Q: NET/ROM pseudo */ +#define ARPHRD_ETHER 1 /* Ethernet 10Mbps */ +#define ARPHRD_EETHER 2 /* Experimental Ethernet */ +#define ARPHRD_AX25 3 /* AX.25 Level 2 */ +#define ARPHRD_PRONET 4 /* PROnet token ring */ +#define ARPHRD_CHAOS 5 /* Chaosnet */ +#define ARPHRD_IEEE802 6 /* IEEE 802.2 Ethernet- huh? */ +#define ARPHRD_ARCNET 7 /* ARCnet */ +#define ARPHRD_APPLETLK 8 /* APPLEtalk */ +/* Dummy types for non ARP hardware */ +#define ARPHRD_SLIP 256 +#define ARPHRD_CSLIP 257 +#define ARPHRD_SLIP6 258 +#define ARPHRD_CSLIP6 259 +#define ARPHRD_RSRVD 260 /* Notional KISS type */ +#define ARPHRD_ADAPT 264 +#define ARPHRD_PPP 512 + +/* ARP protocol opcodes. */ +#define ARPOP_REQUEST 1 /* ARP request */ +#define ARPOP_REPLY 2 /* ARP reply */ +#define ARPOP_RREQUEST 3 /* RARP request */ +#define ARPOP_RREPLY 4 /* RARP reply */ + + +/* ARP ioctl request. */ +struct arpreq { + struct sockaddr arp_pa; /* protocol address */ + struct sockaddr arp_ha; /* hardware address */ + int arp_flags; /* flags */ + struct sockaddr arp_netmask; /* netmask (only for proxy arps) */ +}; + +/* ARP Flag values. */ +#define ATF_COM 0x02 /* completed entry (ha valid) */ +#define ATF_PERM 0x04 /* permanent entry */ +#define ATF_PUBL 0x08 /* publish entry */ +#define ATF_USETRAILERS 0x10 /* has requested trailers */ +#define ATF_NETMASK 0x20 /* want to use a netmask (only + for proxy entries) */ + +/* + * This structure defines an ethernet arp header. + */ + +struct arphdr +{ + unsigned short ar_hrd; /* format of hardware address */ + unsigned short ar_pro; /* format of protocol address */ + unsigned char ar_hln; /* length of hardware address */ + unsigned char ar_pln; /* length of protocol address */ + unsigned short ar_op; /* ARP opcode (command) */ + +#if 0 + /* + * Ethernet looks like this : This bit is variable sized however... + */ + unsigned char ar_sha[ETH_ALEN]; /* sender hardware address */ + unsigned char ar_sip[4]; /* sender IP address */ + unsigned char ar_tha[ETH_ALEN]; /* target hardware address */ + unsigned char ar_tip[4]; /* target IP address */ +#endif + +}; + +#endif /* _LINUX_IF_ARP_H */ diff --git a/include/linux/if_ether.h b/include/linux/if_ether.h new file mode 100644 index 000000000..336184fcb --- /dev/null +++ b/include/linux/if_ether.h @@ -0,0 +1,80 @@ +/* + * INET An implementation of the TCP/IP protocol suite for the LINUX + * operating system. INET is implemented using the BSD Socket + * interface as the means of communication with the user level. + * + * Global definitions for the Ethernet IEEE 802.3 interface. + * + * Version: @(#)if_ether.h 1.0.1a 02/08/94 + * + * Author: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> + * Donald Becker, <becker@super.org> + * + * 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. + */ +#ifndef _LINUX_IF_ETHER_H +#define _LINUX_IF_ETHER_H + + +/* IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble + and FCS/CRC (frame check sequence). */ +#define ETH_ALEN 6 /* Octets in one ethernet addr */ +#define ETH_HLEN 14 /* Total octets in header. */ +#define ETH_ZLEN 60 /* Min. octets in frame sans FCS */ +#define ETH_DATA_LEN 1500 /* Max. octets in payload */ +#define ETH_FRAME_LEN 1514 /* Max. octets in frame sans FCS */ + + +/* These are the defined Ethernet Protocol ID's. */ +#define ETH_P_LOOP 0x0060 /* Ethernet Loopback packet */ +#define ETH_P_ECHO 0x0200 /* Ethernet Echo packet */ +#define ETH_P_PUP 0x0400 /* Xerox PUP packet */ +#define ETH_P_IP 0x0800 /* Internet Protocol packet */ +#define ETH_P_ARP 0x0806 /* Address Resolution packet */ +#define ETH_P_RARP 0x8035 /* Reverse Addr Res packet */ +#define ETH_P_X25 0x0805 /* CCITT X.25 */ +#define ETH_P_IPX 0x8137 /* IPX over DIX */ +#define ETH_P_802_3 0x0001 /* Dummy type for 802.3 frames */ +#define ETH_P_AX25 0x0002 /* Dummy protocol id for AX.25 */ +#define ETH_P_ALL 0x0003 /* Every packet (be careful!!!) */ +#define ETH_P_802_2 0x0004 /* 802.2 frames */ +#define ETH_P_SNAP 0x0005 /* 802.2 SNAP frames */ + +/* This is an Ethernet frame header. */ +struct ethhdr { + unsigned char h_dest[ETH_ALEN]; /* destination eth addr */ + unsigned char h_source[ETH_ALEN]; /* source ether addr */ + unsigned short h_proto; /* packet type ID field */ +}; + +/* Ethernet statistics collection data. */ +struct enet_statistics{ + int rx_packets; /* total packets received */ + int tx_packets; /* total packets transmitted */ + int rx_errors; /* bad packets received */ + int tx_errors; /* packet transmit problems */ + int rx_dropped; /* no space in linux buffers */ + int tx_dropped; /* no space available in linux */ + int multicast; /* multicast packets received */ + int collisions; + + /* detailed rx_errors: */ + int rx_length_errors; + int rx_over_errors; /* receiver ring buff overflow */ + int rx_crc_errors; /* recved pkt with crc error */ + int rx_frame_errors; /* recv'd frame alignment error */ + int rx_fifo_errors; /* recv'r fifo overrun */ + int rx_missed_errors; /* receiver missed packet */ + + /* detailed tx_errors */ + int tx_aborted_errors; + int tx_carrier_errors; + int tx_fifo_errors; + int tx_heartbeat_errors; + int tx_window_errors; +}; + +#endif /* _LINUX_IF_ETHER_H */ diff --git a/include/linux/if_plip.h b/include/linux/if_plip.h new file mode 100644 index 000000000..7e483ad4a --- /dev/null +++ b/include/linux/if_plip.h @@ -0,0 +1,29 @@ +/* + * NET3 PLIP tuning facilities for the new Niibe PLIP. + * + * 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. + * + */ + +#ifndef _LINUX_IF_PLIP_H +#define _LINUX_IF_PLIP_H + +#include <linux/sockios.h> + +#define SIOCDEVPLIP SIOCDEVPRIVATE + +struct plipconf +{ + unsigned short pcmd; + unsigned long nibble; + unsigned long trigger; + unsigned long unit; +}; + +#define PLIP_GET_TIMEOUT 0x1 +#define PLIP_SET_TIMEOUT 0x2 + +#endif diff --git a/include/linux/if_slip.h b/include/linux/if_slip.h new file mode 100644 index 000000000..0cb7f71b8 --- /dev/null +++ b/include/linux/if_slip.h @@ -0,0 +1,19 @@ +/* + * Swansea University Computer Society NET3 + * + * This file declares the constants of special use with the SLIP/CSLIP/ + * KISS TNC driver. + */ + +#ifndef __LINUX_SLIP_H +#define __LINUX_SLIP_H + +#define SL_MODE_SLIP 0 +#define SL_MODE_CSLIP 1 +#define SL_MODE_KISS 4 + +#define SL_OPT_SIXBIT 2 +#define SL_OPT_ADAPTIVE 8 + + +#endif diff --git a/include/linux/in.h b/include/linux/in.h new file mode 100644 index 000000000..1c268f216 --- /dev/null +++ b/include/linux/in.h @@ -0,0 +1,184 @@ +/* + * INET An implementation of the TCP/IP protocol suite for the LINUX + * operating system. INET is implemented using the BSD Socket + * interface as the means of communication with the user level. + * + * Definitions of the Internet Protocol. + * + * Version: @(#)in.h 1.0.1 04/21/93 + * + * Authors: Original taken from the GNU Project <netinet/in.h> file. + * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> + * + * 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. + */ +#ifndef _LINUX_IN_H +#define _LINUX_IN_H + + +/* Standard well-defined IP protocols. */ +enum { + IPPROTO_IP = 0, /* Dummy protocol for TCP */ + IPPROTO_ICMP = 1, /* Internet Control Message Protocol */ + IPPROTO_GGP = 2, /* Gateway Protocol (deprecated) */ + IPPROTO_TCP = 6, /* Transmission Control Protocol */ + IPPROTO_EGP = 8, /* Exterior Gateway Protocol */ + IPPROTO_PUP = 12, /* PUP protocol */ + IPPROTO_UDP = 17, /* User Datagram Protocol */ + IPPROTO_IDP = 22, /* XNS IDP protocol */ + + IPPROTO_RAW = 255, /* Raw IP packets */ + IPPROTO_MAX +}; + + +/* Internet address. */ +struct in_addr { + unsigned long int s_addr; +}; + + +/* Structure describing an Internet (IP) socket address. */ +#define __SOCK_SIZE__ 16 /* sizeof(struct sockaddr) */ +struct sockaddr_in { + short int sin_family; /* Address family */ + unsigned short int sin_port; /* Port number */ + struct in_addr sin_addr; /* Internet address */ + + /* Pad to size of `struct sockaddr'. */ + unsigned char __pad[__SOCK_SIZE__ - sizeof(short int) - + sizeof(unsigned short int) - sizeof(struct in_addr)]; +}; +#define sin_zero __pad /* for BSD UNIX comp. -FvK */ + + +/* + * Definitions of the bits in an Internet address integer. + * On subnets, host and network parts are found according + * to the subnet mask, not these masks. + */ +#define IN_CLASSA(a) ((((long int) (a)) & 0x80000000) == 0) +#define IN_CLASSA_NET 0xff000000 +#define IN_CLASSA_NSHIFT 24 +#define IN_CLASSA_HOST (0xffffffff & ~IN_CLASSA_NET) +#define IN_CLASSA_MAX 128 + +#define IN_CLASSB(a) ((((long int) (a)) & 0xc0000000) == 0x80000000) +#define IN_CLASSB_NET 0xffff0000 +#define IN_CLASSB_NSHIFT 16 +#define IN_CLASSB_HOST (0xffffffff & ~IN_CLASSB_NET) +#define IN_CLASSB_MAX 65536 + +#define IN_CLASSC(a) ((((long int) (a)) & 0xc0000000) == 0xc0000000) +#define IN_CLASSC_NET 0xffffff00 +#define IN_CLASSC_NSHIFT 8 +#define IN_CLASSC_HOST (0xffffffff & ~IN_CLASSC_NET) + +#define IN_CLASSD(a) ((((long int) (a)) & 0xf0000000) == 0xe0000000) +#define IN_MULTICAST(a) IN_CLASSD(a) + +#define IN_EXPERIMENTAL(a) ((((long int) (a)) & 0xe0000000) == 0xe0000000) +#define IN_BADCLASS(a) ((((long int) (a)) & 0xf0000000) == 0xf0000000) + +/* Address to accept any incoming messages. */ +#define INADDR_ANY ((unsigned long int) 0x00000000) + +/* Address to send to all hosts. */ +#define INADDR_BROADCAST ((unsigned long int) 0xffffffff) + +/* Address indicating an error return. */ +#define INADDR_NONE 0xffffffff + +/* Network number for local host loopback. */ +#define IN_LOOPBACKNET 127 + +/* Address to loopback in software to local host. */ +#define INADDR_LOOPBACK 0x7f000001 /* 127.0.0.1 */ + + +/* + * Options for use with `getsockopt' and `setsockopt' at + * the IP level. LINUX does not yet have the IP_OPTIONS + * option (grin), so we undefine it for now.- HJ && FvK + */ +#if 0 +# define IP_OPTIONS 1 /* IP per-packet options */ +#endif +#define IP_HDRINCL 2 /* raw packet header option */ + + +/* Linux Internet number representation function declarations. */ +#undef ntohl +#undef ntohs +#undef htonl +#undef htons + +extern unsigned long int ntohl(unsigned long int); +extern unsigned short int ntohs(unsigned short int); +extern unsigned long int htonl(unsigned long int); +extern unsigned short int htons(unsigned short int); + +static __inline__ unsigned long int +__ntohl(unsigned long int x) +{ + __asm__("xchgb %b0,%h0\n\t" /* swap lower bytes */ + "rorl $16,%0\n\t" /* swap words */ + "xchgb %b0,%h0" /* swap higher bytes */ + :"=q" (x) + : "0" (x)); + return x; +} + +static __inline__ unsigned long int +__constant_ntohl(unsigned long int x) +{ + return (((x & 0x000000ffU) << 24) | + ((x & 0x0000ff00U) << 8) | + ((x & 0x00ff0000U) >> 8) | + ((x & 0xff000000U) >> 24)); +} + +static __inline__ unsigned short int +__ntohs(unsigned short int x) +{ + __asm__("xchgb %b0,%h0" /* swap bytes */ + : "=q" (x) + : "0" (x)); + return x; +} + +static __inline__ unsigned short int +__constant_ntohs(unsigned short int x) +{ + return (((x & 0x00ff) << 8) | + ((x & 0xff00) >> 8)); +} + +#define __htonl(x) __ntohl(x) +#define __htons(x) __ntohs(x) +#define __constant_htonl(x) __constant_ntohl(x) +#define __constant_htons(x) __constant_ntohs(x) + +#ifdef __OPTIMIZE__ +# define ntohl(x) \ +(__builtin_constant_p((long)(x)) ? \ + __constant_ntohl((x)) : \ + __ntohl((x))) +# define ntohs(x) \ +(__builtin_constant_p((short)(x)) ? \ + __constant_ntohs((x)) : \ + __ntohs((x))) +# define htonl(x) \ +(__builtin_constant_p((long)(x)) ? \ + __constant_htonl((x)) : \ + __htonl((x))) +# define htons(x) \ +(__builtin_constant_p((short)(x)) ? \ + __constant_htons((x)) : \ + __htons((x))) +#endif + +#endif /* _LINUX_IN_H */ diff --git a/include/linux/in_systm.h b/include/linux/in_systm.h new file mode 100644 index 000000000..eac9a5888 --- /dev/null +++ b/include/linux/in_systm.h @@ -0,0 +1,32 @@ +/* + * INET An implementation of the TCP/IP protocol suite for the LINUX + * operating system. INET is implemented using the BSD Socket + * interface as the means of communication with the user level. + * + * Miscellaneous internetwork definitions for kernel. + * + * Version: @(#)in_systm.h 1.0.0 12/17/93 + * + * Authors: Original taken from Berkeley BSD UNIX 4.3-RENO. + * Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org> + * + * 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. + */ +#ifndef _LINUX_IN_SYSTM_H +#define _LINUX_IN_SYSTM_H + +/* + * Network types. + * The n_ types are network-order variants of their natural + * equivalents. The Linux kernel NET-2 code does not use + * them (yet), but it might in the future. This is mostly + * there for compatibility with BSD user-level programs. + */ +typedef u_short n_short; /* short as received from the net */ +typedef u_long n_long; /* long as received from the net */ +typedef u_long n_time; /* ms since 00:00 GMT, byte rev */ + +#endif /* _LINUX_IN_SYSTM_H */ diff --git a/include/linux/inet.h b/include/linux/inet.h new file mode 100644 index 000000000..d8511a7ce --- /dev/null +++ b/include/linux/inet.h @@ -0,0 +1,63 @@ +/* + * Swansea University Computer Society NET3 + * + * This work is derived from NET2Debugged, which is in turn derived + * from NET2D which was written by: + * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> + * + * This work was derived from Ross Biro's inspirational work + * for the LINUX operating system. His version numbers were: + * + * $Id: Space.c,v 0.8.4.5 1992/12/12 19:25:04 bir7 Exp $ + * $Id: arp.c,v 0.8.4.6 1993/01/28 22:30:00 bir7 Exp $ + * $Id: arp.h,v 0.8.4.6 1993/01/28 22:30:00 bir7 Exp $ + * $Id: dev.c,v 0.8.4.13 1993/01/23 18:00:11 bir7 Exp $ + * $Id: dev.h,v 0.8.4.7 1993/01/23 18:00:11 bir7 Exp $ + * $Id: eth.c,v 0.8.4.4 1993/01/22 23:21:38 bir7 Exp $ + * $Id: eth.h,v 0.8.4.1 1992/11/10 00:17:18 bir7 Exp $ + * $Id: icmp.c,v 0.8.4.9 1993/01/23 18:00:11 bir7 Exp $ + * $Id: icmp.h,v 0.8.4.2 1992/11/15 14:55:30 bir7 Exp $ + * $Id: ip.c,v 0.8.4.8 1992/12/12 19:25:04 bir7 Exp $ + * $Id: ip.h,v 0.8.4.2 1993/01/23 18:00:11 bir7 Exp $ + * $Id: loopback.c,v 0.8.4.8 1993/01/23 18:00:11 bir7 Exp $ + * $Id: packet.c,v 0.8.4.7 1993/01/26 22:04:00 bir7 Exp $ + * $Id: protocols.c,v 0.8.4.3 1992/11/15 14:55:30 bir7 Exp $ + * $Id: raw.c,v 0.8.4.12 1993/01/26 22:04:00 bir7 Exp $ + * $Id: sock.c,v 0.8.4.6 1993/01/28 22:30:00 bir7 Exp $ + * $Id: sock.h,v 0.8.4.7 1993/01/26 22:04:00 bir7 Exp $ + * $Id: tcp.c,v 0.8.4.16 1993/01/26 22:04:00 bir7 Exp $ + * $Id: tcp.h,v 0.8.4.7 1993/01/22 22:58:08 bir7 Exp $ + * $Id: timer.c,v 0.8.4.8 1993/01/23 18:00:11 bir7 Exp $ + * $Id: timer.h,v 0.8.4.2 1993/01/23 18:00:11 bir7 Exp $ + * $Id: udp.c,v 0.8.4.12 1993/01/26 22:04:00 bir7 Exp $ + * $Id: udp.h,v 0.8.4.1 1992/11/10 00:17:18 bir7 Exp $ + * $Id: we.c,v 0.8.4.10 1993/01/23 18:00:11 bir7 Exp $ + * $Id: wereg.h,v 0.8.4.1 1992/11/10 00:17:18 bir7 Exp $ + * + * 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. + */ +#ifndef _LINUX_INET_H +#define _LINUX_INET_H + +#if defined(__i386__) +#define NET16(x) ((((x) >> 8) & 0x00FF) | (((x) << 8) & 0xFF00)) +#elif defined(__mc68000__) +#define NET16(x) (x) +#elif defined(__alpha__) +#define NET16(x) ((((x) >> 8) & 0x00FF) | (((x) << 8) & 0xFF00)) +#else +#error change this to match your machine +#endif + +#ifdef __KERNEL__ + + +extern void inet_proto_init(struct net_proto *pro); +extern char *in_ntoa(unsigned long in); +extern unsigned long in_aton(char *str); + +#endif +#endif /* _LINUX_INET_H */ diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h new file mode 100644 index 000000000..2ccaec523 --- /dev/null +++ b/include/linux/interrupt.h @@ -0,0 +1,42 @@ +/* interrupt.h */ +#ifndef _LINUX_INTERRUPT_H +#define _LINUX_INTERRUPT_H + +struct bh_struct { + void (*routine)(void *); + void *data; +}; + +extern unsigned long bh_active; +extern unsigned long bh_mask; +extern struct bh_struct bh_base[32]; + +/* Who gets which entry in bh_base. Things which will occur most often + should come first - in which case NET should be up the top with SERIAL/TQUEUE! */ + +enum { + TIMER_BH = 0, + CONSOLE_BH, + TQUEUE_BH, + SERIAL_BH, + NET_BH, + IMMEDIATE_BH, + KEYBOARD_BH +}; + +extern inline void mark_bh(int nr) +{ + __asm__ __volatile__("orl %1,%0":"=m" (bh_active):"ir" (1<<nr)); +} + +extern inline void disable_bh(int nr) +{ + __asm__ __volatile__("andl %1,%0":"=m" (bh_mask):"ir" (~(1<<nr))); +} + +extern inline void enable_bh(int nr) +{ + __asm__ __volatile__("orl %1,%0":"=m" (bh_mask):"ir" (1<<nr)); +} + +#endif diff --git a/include/linux/ioctl.h b/include/linux/ioctl.h new file mode 100644 index 000000000..e76bdb6e0 --- /dev/null +++ b/include/linux/ioctl.h @@ -0,0 +1,53 @@ +/* $Id: ioctl.h,v 1.5 1993/07/19 21:53:50 root Exp root $ + * + * linux/ioctl.h for Linux by H.H. Bergman. + */ + +#ifndef _LINUX_IOCTL_H +#define _LINUX_IOCTL_H + + +/* ioctl command encoding: 32 bits total, command in lower 16 bits, + * size of the parameter structure in the lower 14 bits of the + * upper 16 bits. + * Encoding the size of the parameter structure in the ioctl request + * is useful for catching programs compiled with old versions + * and to avoid overwriting user space outside the user buffer area. + * The highest 2 bits are reserved for indicating the ``access mode''. + * NOTE: This limits the max parameter size to 16kB -1 ! + */ + +#define IOC_VOID 0x00000000 /* param in size field */ +#define IOC_IN 0x40000000 /* user --> kernel */ +#define IOC_OUT 0x80000000 /* kernel --> user */ +#define IOC_INOUT (IOC_IN | IOC_OUT) /* both */ +#define IOCSIZE_MASK 0x3fff0000 /* size (max 16k-1 bytes) */ +#define IOCSIZE_SHIFT 16 /* how to get the size */ +#define IOCSIZE_MAX ((PAGE_SIZE-1)&(IOCSIZE_MASK >> IOC_SHIFT)) +#define IOCCMD_MASK 0x0000ffff /* command code */ +#define IOCCMD_SHIFT 0 +#define IOCPARM_MASK IOCCMD_MASK +#define IOCPARM_SHIFT IOCCMD_SHIFT + +#define IOC_SIZE(cmd) (((cmd) & IOCSIZE_MASK) >> IOCSIZE_SHIFT) +#define IOCBASECMD(cmd) ((cmd) & ~IOCPARM_MASK) +#define IOCGROUP(cmd) (((cmd) >> 8) & 0xFF) + +/* _IO(magic, subcode); size field is zero and the + * subcode determines the command. + */ +#define _IO(c,d) (IOC_VOID | ((c)<<8) | (d)) /* param encoded */ + +/* _IOXX(magic, subcode, arg_t); where arg_t is the type of the + * (last) argument field in the ioctl call, if present. + */ +#define _IOW(c,d,t) (IOC_IN | ((sizeof(t)<<16) & IOCSIZE_MASK) | \ + ((c)<<8) | (d)) +#define _IOR(c,d,t) (IOC_OUT | ((sizeof(t)<<16) & IOCSIZE_MASK) | \ + ((c)<<8) | (d)) +/* WR rather than RW to avoid conflict with stdio.h */ +#define _IOWR(c,d,t) (IOC_INOUT | ((sizeof(t)<<16) & IOCSIZE_MASK) | \ + ((c)<<8) | (d)) + +#endif /* _LINUX_IOCTL_H */ + diff --git a/include/linux/ioport.h b/include/linux/ioport.h new file mode 100644 index 000000000..e5923f6ed --- /dev/null +++ b/include/linux/ioport.h @@ -0,0 +1,30 @@ +/* + * portio.h Definitions of routines for detecting, reserving and + * allocating system resources. + * + * Version: 0.01 8/30/93 + * + * Author: Donald Becker (becker@super.org) + */ + +#ifndef _LINUX_PORTIO_H +#define _LINUX_PORTIO_H + +#define HAVE_PORTRESERVE +/* + * Call check_region() before probing for your hardware. + * Once you have found you hardware, register it with snarf_region(). + * If you unload the driver, use release_region to free ports. + */ +extern void reserve_setup(char *str, int *ints); +extern int check_region(unsigned int from, unsigned int extent); +extern void snarf_region(unsigned int from, unsigned int extent); +extern void release_region(unsigned int from, unsigned int extent); + + +#define HAVE_AUTOIRQ +extern void *irq2dev_map[16]; /* Use only if you own the IRQ. */ +extern void autoirq_setup(int waittime); +extern int autoirq_report(int waittime); + +#endif /* _LINUX_PORTIO_H */ diff --git a/include/linux/ip.h b/include/linux/ip.h new file mode 100644 index 000000000..1d3789638 --- /dev/null +++ b/include/linux/ip.h @@ -0,0 +1,101 @@ +/* + * INET An implementation of the TCP/IP protocol suite for the LINUX + * operating system. INET is implemented using the BSD Socket + * interface as the means of communication with the user level. + * + * Definitions for the IP protocol. + * + * Version: @(#)ip.h 1.0.2 04/28/93 + * + * Authors: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> + * + * 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. + */ +#ifndef _LINUX_IP_H +#define _LINUX_IP_H + + +#define IPOPT_END 0 +#define IPOPT_NOOP 1 +#define IPOPT_SEC 130 +#define IPOPT_LSRR 131 +#define IPOPT_SSRR 137 +#define IPOPT_RR 7 +#define IPOPT_SID 136 +#define IPOPT_TIMESTAMP 68 + + +struct timestamp { + u8 len; + u8 ptr; + union { +#if defined(__i386__) + u8 flags:4, + overflow:4; +#elif defined(__mc68000__) + u8 overflow:4, + flags:4; +#elif defined(__alpha__) + u8 flags:4, + overflow:4; +#else +#error "Adjust this structure to match your CPU" +#endif + u8 full_char; + } x; + u32 data[9]; +}; + + +#define MAX_ROUTE 16 + +struct route { + char route_size; + char pointer; + unsigned long route[MAX_ROUTE]; +}; + + +struct options { + struct route record_route; + struct route loose_route; + struct route strict_route; + struct timestamp tstamp; + unsigned short security; + unsigned short compartment; + unsigned short handling; + unsigned short stream; + unsigned tcc; +}; + + +struct iphdr { +#if defined(__i386__) + u8 ihl:4, + version:4; +#elif defined (__mc68000__) + u8 version:4, + ihl:4; +#elif defined (__alpha__) + u8 ihl:4, + version:4; +#else +#error "Adjust this structure to match your CPU" +#endif + u8 tos; + u16 tot_len; + u16 id; + u16 frag_off; + u8 ttl; + u8 protocol; + u16 check; + u32 saddr; + u32 daddr; + /*The options start here. */ +}; + + +#endif /* _LINUX_IP_H */ diff --git a/include/linux/ipc.h b/include/linux/ipc.h new file mode 100644 index 000000000..a7a841724 --- /dev/null +++ b/include/linux/ipc.h @@ -0,0 +1,65 @@ +#ifndef _LINUX_IPC_H +#define _LINUX_IPC_H +#include <linux/types.h> + +typedef int key_t; /* should go in <types.h> type for IPC key */ +#define IPC_PRIVATE ((key_t) 0) + +struct ipc_perm +{ + key_t key; + ushort uid; /* owner euid and egid */ + ushort gid; + ushort cuid; /* creator euid and egid */ + ushort cgid; + ushort mode; /* access modes see mode flags below */ + ushort seq; /* sequence number */ +}; + + +/* resource get request flags */ +#define IPC_CREAT 00001000 /* create if key is nonexistent */ +#define IPC_EXCL 00002000 /* fail if key exists */ +#define IPC_NOWAIT 00004000 /* return error on wait */ + + +/* + * Control commands used with semctl, msgctl and shmctl + * see also specific commands in sem.h, msg.h and shm.h + */ +#define IPC_RMID 0 /* remove resource */ +#define IPC_SET 1 /* set ipc_perm options */ +#define IPC_STAT 2 /* get ipc_perm options */ +#define IPC_INFO 3 /* see ipcs */ + +#ifdef __KERNEL__ + +/* special shmsegs[id], msgque[id] or semary[id] values */ +#define IPC_UNUSED ((void *) -1) +#define IPC_NOID ((void *) -2) /* being allocated/destroyed */ + +/* + * These are used to wrap system calls. See ipc/util.c. + */ +struct ipc_kludge { + struct msgbuf *msgp; + long msgtyp; +}; + +#define SEMOP 1 +#define SEMGET 2 +#define SEMCTL 3 +#define MSGSND 11 +#define MSGRCV 12 +#define MSGGET 13 +#define MSGCTL 14 +#define SHMAT 21 +#define SHMDT 22 +#define SHMGET 23 +#define SHMCTL 24 + +#endif /* __KERNEL__ */ + +#endif /* _LINUX_IPC_H */ + + diff --git a/include/linux/ipx.h b/include/linux/ipx.h new file mode 100644 index 000000000..1b4b882c1 --- /dev/null +++ b/include/linux/ipx.h @@ -0,0 +1,30 @@ +#ifndef _IPX_H_ +#define _IPX_H_ + +struct sockaddr_ipx +{ + short sipx_family; + unsigned long sipx_network; + unsigned char sipx_node[6]; + short sipx_port; + unsigned char sipx_type; +}; + +struct ipx_route_def +{ + unsigned long ipx_network; + unsigned long ipx_router_network; +#define IPX_ROUTE_NO_ROUTER 0 + unsigned char ipx_router_node[6]; + unsigned char ipx_device[16]; + unsigned short ipx_flags; +#define IPX_RT_SNAP 8 +#define IPX_RT_8022 4 +#define IPX_RT_BLUEBOOK 2 +#define IPX_RT_ROUTED 1 +}; + +#define IPX_MTU 576 + +#endif + diff --git a/include/linux/iso_fs.h b/include/linux/iso_fs.h new file mode 100644 index 000000000..99b032e5e --- /dev/null +++ b/include/linux/iso_fs.h @@ -0,0 +1,210 @@ + +#ifndef _ISOFS_FS_H +#define _ISOFS_FS_H + +#include <linux/types.h> +/* + * The isofs filesystem constants/structures + */ + +/* This part borrowed from the bsd386 isofs */ +#define ISODCL(from, to) (to - from + 1) + +struct iso_volume_descriptor { + char type[ISODCL(1,1)]; /* 711 */ + char id[ISODCL(2,6)]; + char version[ISODCL(7,7)]; + char data[ISODCL(8,2048)]; +}; + +/* volume descriptor types */ +#define ISO_VD_PRIMARY 1 +#define ISO_VD_END 255 + +#define ISO_STANDARD_ID "CD001" + +struct iso_primary_descriptor { + char type [ISODCL ( 1, 1)]; /* 711 */ + char id [ISODCL ( 2, 6)]; + char version [ISODCL ( 7, 7)]; /* 711 */ + char unused1 [ISODCL ( 8, 8)]; + char system_id [ISODCL ( 9, 40)]; /* achars */ + char volume_id [ISODCL ( 41, 72)]; /* dchars */ + char unused2 [ISODCL ( 73, 80)]; + char volume_space_size [ISODCL ( 81, 88)]; /* 733 */ + char unused3 [ISODCL ( 89, 120)]; + char volume_set_size [ISODCL (121, 124)]; /* 723 */ + char volume_sequence_number [ISODCL (125, 128)]; /* 723 */ + char logical_block_size [ISODCL (129, 132)]; /* 723 */ + char path_table_size [ISODCL (133, 140)]; /* 733 */ + char type_l_path_table [ISODCL (141, 144)]; /* 731 */ + char opt_type_l_path_table [ISODCL (145, 148)]; /* 731 */ + char type_m_path_table [ISODCL (149, 152)]; /* 732 */ + char opt_type_m_path_table [ISODCL (153, 156)]; /* 732 */ + char root_directory_record [ISODCL (157, 190)]; /* 9.1 */ + char volume_set_id [ISODCL (191, 318)]; /* dchars */ + char publisher_id [ISODCL (319, 446)]; /* achars */ + char preparer_id [ISODCL (447, 574)]; /* achars */ + char application_id [ISODCL (575, 702)]; /* achars */ + char copyright_file_id [ISODCL (703, 739)]; /* 7.5 dchars */ + char abstract_file_id [ISODCL (740, 776)]; /* 7.5 dchars */ + char bibliographic_file_id [ISODCL (777, 813)]; /* 7.5 dchars */ + char creation_date [ISODCL (814, 830)]; /* 8.4.26.1 */ + char modification_date [ISODCL (831, 847)]; /* 8.4.26.1 */ + char expiration_date [ISODCL (848, 864)]; /* 8.4.26.1 */ + char effective_date [ISODCL (865, 881)]; /* 8.4.26.1 */ + char file_structure_version [ISODCL (882, 882)]; /* 711 */ + char unused4 [ISODCL (883, 883)]; + char application_data [ISODCL (884, 1395)]; + char unused5 [ISODCL (1396, 2048)]; +}; + + +#define HS_STANDARD_ID "CDROM" + +struct hs_volume_descriptor { + char foo [ISODCL ( 1, 8)]; /* 733 */ + char type [ISODCL ( 9, 9)]; /* 711 */ + char id [ISODCL ( 10, 14)]; + char version [ISODCL ( 15, 15)]; /* 711 */ + char data[ISODCL(16,2048)]; +}; + + +struct hs_primary_descriptor { + char foo [ISODCL ( 1, 8)]; /* 733 */ + char type [ISODCL ( 9, 9)]; /* 711 */ + char id [ISODCL ( 10, 14)]; + char version [ISODCL ( 15, 15)]; /* 711 */ + char unused1 [ISODCL ( 16, 16)]; /* 711 */ + char system_id [ISODCL ( 17, 48)]; /* achars */ + char volume_id [ISODCL ( 49, 80)]; /* dchars */ + char unused2 [ISODCL ( 81, 88)]; /* 733 */ + char volume_space_size [ISODCL ( 89, 96)]; /* 733 */ + char unused3 [ISODCL ( 97, 128)]; /* 733 */ + char volume_set_size [ISODCL (129, 132)]; /* 723 */ + char volume_sequence_number [ISODCL (133, 136)]; /* 723 */ + char logical_block_size [ISODCL (137, 140)]; /* 723 */ + char path_table_size [ISODCL (141, 148)]; /* 733 */ + char type_l_path_table [ISODCL (149, 152)]; /* 731 */ + char unused4 [ISODCL (153, 180)]; /* 733 */ + char root_directory_record [ISODCL (181, 214)]; /* 9.1 */ +}; + +/* We use this to help us look up the parent inode numbers. */ + +struct iso_path_table{ + unsigned char name_len[2]; /* 721 */ + char extent[4]; /* 731 */ + char parent[2]; /* 721 */ + char name[0]; +}; + +/* high sierra is identical to iso, except that the date is only 6 bytes, and + there is an extra reserved byte after the flags */ + +struct iso_directory_record { + char length [ISODCL (1, 1)]; /* 711 */ + char ext_attr_length [ISODCL (2, 2)]; /* 711 */ + char extent [ISODCL (3, 10)]; /* 733 */ + char size [ISODCL (11, 18)]; /* 733 */ + char date [ISODCL (19, 25)]; /* 7 by 711 */ + char flags [ISODCL (26, 26)]; + char file_unit_size [ISODCL (27, 27)]; /* 711 */ + char interleave [ISODCL (28, 28)]; /* 711 */ + char volume_sequence_number [ISODCL (29, 32)]; /* 723 */ + unsigned char name_len [ISODCL (33, 33)]; /* 711 */ + char name [0]; +}; + +#define ISOFS_BLOCK_BITS 11 +#define ISOFS_BLOCK_SIZE 2048 + +#define ISOFS_BUFFER_SIZE(INODE) ((INODE)->i_sb->s_blocksize) +#define ISOFS_BUFFER_BITS(INODE) ((INODE)->i_sb->s_blocksize_bits) + +#if 0 +#ifdef ISOFS_FIXED_BLOCKSIZE +/* We use these until the buffer cache supports 2048 */ +#define ISOFS_BUFFER_BITS 10 +#define ISOFS_BUFFER_SIZE 1024 + +#define ISOFS_BLOCK_NUMBER(X) (X<<1) +#else +#define ISOFS_BUFFER_BITS 11 +#define ISOFS_BUFFER_SIZE 2048 + +#define ISOFS_BLOCK_NUMBER(X) (X) +#endif +#endif + +#define ISOFS_SUPER_MAGIC 0x9660 +#define ISOFS_FILE_UNKNOWN 0 +#define ISOFS_FILE_TEXT 1 +#define ISOFS_FILE_BINARY 2 +#define ISOFS_FILE_TEXT_M 3 + +#ifdef __KERNEL__ +extern int isonum_711(char *); +extern int isonum_712(char *); +extern int isonum_721(char *); +extern int isonum_722(char *); +extern int isonum_723(char *); +extern int isonum_731(char *); +extern int isonum_732(char *); +extern int isonum_733(char *); +extern int iso_date(char *, int); + +extern int parse_rock_ridge_inode(struct iso_directory_record *, struct inode *); +extern int get_rock_ridge_filename(struct iso_directory_record *, char ** name, int * len, struct inode *); + +extern char * get_rock_ridge_symlink(struct inode *); +extern int find_rock_ridge_relocation(struct iso_directory_record *, struct inode *); + +/* The stuff that follows may be totally unneeded. I have not checked to see + which prototypes we are still using. */ + +extern int isofs_open(struct inode * inode, struct file * filp); +extern void isofs_release(struct inode * inode, struct file * filp); +extern int isofs_lookup(struct inode * dir,const char * name, int len, + struct inode ** result); +extern unsigned long isofs_count_free_inodes(struct super_block *sb); +extern int isofs_new_block(int dev); +extern int isofs_free_block(int dev, int block); +extern int isofs_bmap(struct inode *,int); + +extern void isofs_put_super(struct super_block *); +extern struct super_block *isofs_read_super(struct super_block *,void *,int); +extern void isofs_read_inode(struct inode *); +extern void isofs_put_inode(struct inode *); +extern void isofs_statfs(struct super_block *, struct statfs *); + +extern int isofs_lseek(struct inode *, struct file *, off_t, int); +extern int isofs_read(struct inode *, struct file *, char *, int); +extern int isofs_lookup_grandparent(struct inode *, int); + +extern struct inode_operations isofs_file_inode_operations; +extern struct inode_operations isofs_dir_inode_operations; +extern struct inode_operations isofs_symlink_inode_operations; +extern struct inode_operations isofs_chrdev_inode_operations; +extern struct inode_operations isofs_blkdev_inode_operations; +extern struct inode_operations isofs_fifo_inode_operations; + +/* The following macros are used to check for memory leaks. */ +#ifdef LEAK_CHECK +#define free_s leak_check_free_s +#define malloc leak_check_malloc +#define bread leak_check_bread +#define brelse leak_check_brelse +extern void * leak_check_malloc(unsigned int size); +extern void leak_check_free_s(void * obj, int size); +extern struct buffer_head * leak_check_bread(int dev, int block, int size); +extern void leak_check_brelse(struct buffer_head * bh); +#endif /* LEAK_CHECK */ + +#endif /* __KERNEL__ */ + +#endif + + + diff --git a/include/linux/iso_fs_i.h b/include/linux/iso_fs_i.h new file mode 100644 index 000000000..d8065500f --- /dev/null +++ b/include/linux/iso_fs_i.h @@ -0,0 +1,13 @@ +#ifndef _ISO_FS_I +#define _ISO_FS_I + +/* + * iso fs inode data in memory + */ +struct iso_inode_info { + unsigned int i_first_extent; + unsigned int i_backlink; + unsigned char i_file_format; +}; + +#endif diff --git a/include/linux/iso_fs_sb.h b/include/linux/iso_fs_sb.h new file mode 100644 index 000000000..1a7e8e517 --- /dev/null +++ b/include/linux/iso_fs_sb.h @@ -0,0 +1,34 @@ +#ifndef _ISOFS_FS_SB +#define _ISOFS_FS_SB + +/* + * minix super-block data in memory + */ +struct isofs_sb_info { + unsigned long s_ninodes; + unsigned long s_nzones; + unsigned long s_firstdatazone; + unsigned long s_log_zone_size; + unsigned long s_max_size; + + unsigned char s_high_sierra; /* A simple flag */ + unsigned char s_mapping; + unsigned char s_conversion; + unsigned char s_rock; + unsigned char s_cruft; /* Broken disks with high + byte of length containing + junk */ + unsigned char s_nosuid; + unsigned char s_nodev; + gid_t s_gid; + uid_t s_uid; +}; + +#endif + + + + + + + diff --git a/include/linux/kd.h b/include/linux/kd.h new file mode 100644 index 000000000..3a343fd32 --- /dev/null +++ b/include/linux/kd.h @@ -0,0 +1,119 @@ +#ifndef _LINUX_KD_H +#define _LINUX_KD_H +#include <linux/types.h> + +/* 0x4B is 'K', to avoid collision with termios and vt */ + +#define GIO_FONT 0x4B60 /* gets font in expanded form */ +#define PIO_FONT 0x4B61 /* use font in expanded form */ + +#define KIOCSOUND 0x4B2F /* start sound generation (0 for off) */ +#define KDMKTONE 0x4B30 /* generate tone */ + +#define KDGETLED 0x4B31 /* return current led state */ +#define KDSETLED 0x4B32 /* set led state [lights, not flags] */ +#define LED_SCR 0x01 /* scroll lock led */ +#define LED_CAP 0x04 /* caps lock led */ +#define LED_NUM 0x02 /* num lock led */ + +#define KDGKBTYPE 0x4B33 /* get keyboard type */ +#define KB_84 0x01 +#define KB_101 0x02 /* this is what we always answer */ +#define KB_OTHER 0x03 + +#define KDADDIO 0x4B34 /* add i/o port as valid */ +#define KDDELIO 0x4B35 /* del i/o port as valid */ +#define KDENABIO 0x4B36 /* enable i/o to video board */ +#define KDDISABIO 0x4B37 /* disable i/o to video board */ + +#define KDSETMODE 0x4B3A /* set text/graphics mode */ +#define KD_TEXT 0x00 +#define KD_GRAPHICS 0x01 +#define KD_TEXT0 0x02 /* obsolete */ +#define KD_TEXT1 0x03 /* obsolete */ +#define KDGETMODE 0x4B3B /* get current mode */ + +#define KDMAPDISP 0x4B3C /* map display into address space */ +#define KDUNMAPDISP 0x4B3D /* unmap display from address space */ + +typedef char scrnmap_t; +#define E_TABSZ 256 +#define GIO_SCRNMAP 0x4B40 /* get screen mapping from kernel */ +#define PIO_SCRNMAP 0x4B41 /* put screen mapping table in kernel */ + +#define GIO_UNIMAP 0x4B66 /* get unicode-to-font mapping from kernel */ +struct unipair { + u_short unicode; + u_short fontpos; +}; +struct unimapdesc { + u_short entry_ct; + struct unipair *entries; +}; +#define PIO_UNIMAP 0x4B67 /* put unicode-to-font mapping in kernel */ +#define PIO_UNIMAPCLR 0x4B68 /* clear table, possibly advise hash algorithm */ +struct unimapinit { + u_short advised_hashsize; /* 0 if no opinion */ + u_short advised_hashstep; /* 0 if no opinion */ + u_short advised_hashlevel; /* 0 if no opinion */ +}; + +#define K_RAW 0x00 +#define K_XLATE 0x01 +#define K_MEDIUMRAW 0x02 +#define K_UNICODE 0x03 +#define KDGKBMODE 0x4B44 /* gets current keyboard mode */ +#define KDSKBMODE 0x4B45 /* sets current keyboard mode */ + +#define K_METABIT 0x03 +#define K_ESCPREFIX 0x04 +#define KDGKBMETA 0x4B62 /* gets meta key handling mode */ +#define KDSKBMETA 0x4B63 /* sets meta key handling mode */ + +#define K_SCROLLLOCK 0x01 +#define K_CAPSLOCK 0x02 +#define K_NUMLOCK 0x04 +#define KDGKBLED 0x4B64 /* get led flags (not lights) */ +#define KDSKBLED 0x4B65 /* set led flags (not lights) */ + +struct kbentry { + u_char kb_table; + u_char kb_index; + u_short kb_value; +}; +#define K_NORMTAB 0x00 +#define K_SHIFTTAB 0x01 +#define K_ALTTAB 0x02 +#define K_ALTSHIFTTAB 0x03 + +#define KDGKBENT 0x4B46 /* gets one entry in translation table */ +#define KDSKBENT 0x4B47 /* sets one entry in translation table */ + +struct kbsentry { + u_char kb_func; + u_char kb_string[512]; +}; +#define KDGKBSENT 0x4B48 /* gets one function key string entry */ +#define KDSKBSENT 0x4B49 /* sets one function key string entry */ + +struct kbdiacr { + u_char diacr, base, result; +}; +struct kbdiacrs { + unsigned int kb_cnt; /* number of entries in following array */ + struct kbdiacr kbdiacr[256]; /* MAX_DIACR from keyboard.h */ +}; +#define KDGKBDIACR 0x4B4A /* read kernel accent table */ +#define KDSKBDIACR 0x4B4B /* write kernel accent table */ + +struct kbkeycode { + unsigned int scancode, keycode; +}; +#define KDGETKEYCODE 0x4B4C /* read kernel keycode table entry */ +#define KDSETKEYCODE 0x4B4D /* write kernel keycode table entry */ + +/* note: 0x4B00-0x4B4D all have had a value at some time; + don't reuse for the time being */ +/* note: 0x4B60-0x4B68 used above */ + +#endif /* _LINUX_KD_H */ diff --git a/include/linux/kernel.h b/include/linux/kernel.h new file mode 100644 index 000000000..f4d1d4963 --- /dev/null +++ b/include/linux/kernel.h @@ -0,0 +1,87 @@ +#ifndef _LINUX_KERNEL_H +#define _LINUX_KERNEL_H + +/* + * 'kernel.h' contains some often-used function prototypes etc + */ + +#ifdef __KERNEL__ + +#include <stdarg.h> +#include <linux/linkage.h> + +#define INT_MAX ((int)(~0U>>1)) +#define UINT_MAX (~0U) +#define LONG_MAX ((long)(~0UL>>1)) +#define ULONG_MAX (~0UL) + +#define STACK_MAGIC 0xdeadbeef + +#define KERN_EMERG "<0>" /* system is unusable */ +#define KERN_ALERT "<1>" /* action must be taken immediately */ +#define KERN_CRIT "<2>" /* critical conditions */ +#define KERN_ERR "<3>" /* error conditions */ +#define KERN_WARNING "<4>" /* warning conditions */ +#define KERN_NOTICE "<5>" /* normal but significant condition */ +#define KERN_INFO "<6>" /* informational */ +#define KERN_DEBUG "<7>" /* debug-level messages */ + +#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) +# define NORET_TYPE __volatile__ +# define ATTRIB_NORET /**/ +# define NORET_AND /**/ +#else +# define NORET_TYPE /**/ +# define ATTRIB_NORET __attribute__((noreturn)) +# define NORET_AND noreturn, +#endif + +extern void math_error(void); +NORET_TYPE void panic(const char * fmt, ...) + __attribute__ ((NORET_AND format (printf, 1, 2))); +NORET_TYPE void do_exit(long error_code) + ATTRIB_NORET; +extern unsigned long simple_strtoul(const char *,char **,unsigned int); +extern int sprintf(char * buf, const char * fmt, ...); +extern int vsprintf(char *buf, const char *, va_list); + +extern int session_of_pgrp(int pgrp); + +extern int kill_proc(int pid, int sig, int priv); +extern int kill_pg(int pgrp, int sig, int priv); +extern int kill_sl(int sess, int sig, int priv); + +asmlinkage int printk(const char * fmt, ...) + __attribute__ ((format (printf, 1, 2))); + +/* + * This is defined as a macro, but at some point this might become a + * real subroutine that sets a flag if it returns true (to do + * BSD-style accounting where the process is flagged if it uses root + * privs). The implication of this is that you should do normal + * permissions checks first, and check suser() last. + * + * "suser()" checks against the effective user id, while "fsuser()" + * is used for file permission checking and checks against the fsuid.. + */ +#define suser() (current->euid == 0) +#define fsuser() (current->fsuid == 0) + +extern int splx (int new_ipl); +#endif /* __KERNEL__ */ + +#define SI_LOAD_SHIFT 16 +struct sysinfo { + long uptime; /* Seconds since boot */ + unsigned long loads[3]; /* 1, 5, and 15 minute load averages */ + unsigned long totalram; /* Total usable main memory size */ + unsigned long freeram; /* Available memory size */ + unsigned long sharedram; /* Amount of shared memory */ + unsigned long bufferram; /* Memory used by buffers */ + unsigned long totalswap; /* Total swap space size */ + unsigned long freeswap; /* swap space still available */ + unsigned short procs; /* Number of current processes */ + char _f[22]; /* Pads structure to 64 bytes */ +}; + +#endif diff --git a/include/linux/kernel_stat.h b/include/linux/kernel_stat.h new file mode 100644 index 000000000..4d3f3e941 --- /dev/null +++ b/include/linux/kernel_stat.h @@ -0,0 +1,26 @@ +#ifndef _LINUX_KERNEL_STAT_H +#define _LINUX_KERNEL_STAT_H + +/* + * 'kernel_stat.h' contains the definitions needed for doing + * some kernel statistics (cpu usage, context switches ...), + * used by rstatd/perfmeter + */ + +#define DK_NDRIVE 4 + +struct kernel_stat { + unsigned int cpu_user, cpu_nice, cpu_system; + unsigned int dk_drive[DK_NDRIVE]; + unsigned int pgpgin, pgpgout; + unsigned int pswpin, pswpout; + unsigned int interrupts[16]; + unsigned int ipackets, opackets; + unsigned int ierrors, oerrors; + unsigned int collisions; + unsigned int context_swtch; +}; + +extern struct kernel_stat kstat; + +#endif /* _LINUX_KERNEL_STAT_H */ diff --git a/include/linux/keyboard.h b/include/linux/keyboard.h new file mode 100644 index 000000000..a10422b54 --- /dev/null +++ b/include/linux/keyboard.h @@ -0,0 +1,411 @@ +#ifndef __LINUX_KEYBOARD_H +#define __LINUX_KEYBOARD_H + +#define KG_SHIFT 0 +#define KG_CTRL 2 +#define KG_ALT 3 +#define KG_ALTGR 1 +#define KG_SHIFTL 4 +#define KG_SHIFTR 5 +#define KG_CTRLL 6 +#define KG_CTRLR 7 +#define KG_CAPSSHIFT 8 + +#define NR_SHIFT 9 + +#define NR_KEYS 128 +#define MAX_NR_KEYMAPS 256 +/* This means 64Kb if all keymaps are allocated. Only the superuser + may increase the number of keymaps beyond MAX_NR_OF_USER_KEYMAPS. */ +#define MAX_NR_OF_USER_KEYMAPS 256 /* should be at least 7 */ + +extern const int NR_TYPES; +extern const int max_vals[]; +extern unsigned short *key_maps[MAX_NR_KEYMAPS]; +extern unsigned short plain_map[NR_KEYS]; + +#define MAX_NR_FUNC 256 /* max nr of strings assigned to keys */ + +#define KT_LATIN 0 /* we depend on this being zero */ +#define KT_LETTER 11 /* symbol that can be acted upon by CapsLock */ +#define KT_FN 1 +#define KT_SPEC 2 +#define KT_PAD 3 +#define KT_DEAD 4 +#define KT_CONS 5 +#define KT_CUR 6 +#define KT_SHIFT 7 +#define KT_META 8 +#define KT_ASCII 9 +#define KT_LOCK 10 + +#define K(t,v) (((t)<<8)|(v)) +#define KTYP(x) ((x) >> 8) +#define KVAL(x) ((x) & 0xff) + +#define K_F1 K(KT_FN,0) +#define K_F2 K(KT_FN,1) +#define K_F3 K(KT_FN,2) +#define K_F4 K(KT_FN,3) +#define K_F5 K(KT_FN,4) +#define K_F6 K(KT_FN,5) +#define K_F7 K(KT_FN,6) +#define K_F8 K(KT_FN,7) +#define K_F9 K(KT_FN,8) +#define K_F10 K(KT_FN,9) +#define K_F11 K(KT_FN,10) +#define K_F12 K(KT_FN,11) +#define K_F13 K(KT_FN,12) +#define K_F14 K(KT_FN,13) +#define K_F15 K(KT_FN,14) +#define K_F16 K(KT_FN,15) +#define K_F17 K(KT_FN,16) +#define K_F18 K(KT_FN,17) +#define K_F19 K(KT_FN,18) +#define K_F20 K(KT_FN,19) +#define K_FIND K(KT_FN,20) +#define K_INSERT K(KT_FN,21) +#define K_REMOVE K(KT_FN,22) +#define K_SELECT K(KT_FN,23) +#define K_PGUP K(KT_FN,24) /* PGUP is a synonym for PRIOR */ +#define K_PGDN K(KT_FN,25) /* PGDN is a synonym for NEXT */ +#define K_MACRO K(KT_FN,26) +#define K_HELP K(KT_FN,27) +#define K_DO K(KT_FN,28) +#define K_PAUSE K(KT_FN,29) +#define K_F21 K(KT_FN,30) +#define K_F22 K(KT_FN,31) +#define K_F23 K(KT_FN,32) +#define K_F24 K(KT_FN,33) +#define K_F25 K(KT_FN,34) +#define K_F26 K(KT_FN,35) +#define K_F27 K(KT_FN,36) +#define K_F28 K(KT_FN,37) +#define K_F29 K(KT_FN,38) +#define K_F30 K(KT_FN,39) +#define K_F31 K(KT_FN,40) +#define K_F32 K(KT_FN,41) +#define K_F33 K(KT_FN,42) +#define K_F34 K(KT_FN,43) +#define K_F35 K(KT_FN,44) +#define K_F36 K(KT_FN,45) +#define K_F37 K(KT_FN,46) +#define K_F38 K(KT_FN,47) +#define K_F39 K(KT_FN,48) +#define K_F40 K(KT_FN,49) +#define K_F41 K(KT_FN,50) +#define K_F42 K(KT_FN,51) +#define K_F43 K(KT_FN,52) +#define K_F44 K(KT_FN,53) +#define K_F45 K(KT_FN,54) +#define K_F46 K(KT_FN,55) +#define K_F47 K(KT_FN,56) +#define K_F48 K(KT_FN,57) +#define K_F49 K(KT_FN,58) +#define K_F50 K(KT_FN,59) +#define K_F51 K(KT_FN,60) +#define K_F52 K(KT_FN,61) +#define K_F53 K(KT_FN,62) +#define K_F54 K(KT_FN,63) +#define K_F55 K(KT_FN,64) +#define K_F56 K(KT_FN,65) +#define K_F57 K(KT_FN,66) +#define K_F58 K(KT_FN,67) +#define K_F59 K(KT_FN,68) +#define K_F60 K(KT_FN,69) +#define K_F61 K(KT_FN,70) +#define K_F62 K(KT_FN,71) +#define K_F63 K(KT_FN,72) +#define K_F64 K(KT_FN,73) +#define K_F65 K(KT_FN,74) +#define K_F66 K(KT_FN,75) +#define K_F67 K(KT_FN,76) +#define K_F68 K(KT_FN,77) +#define K_F69 K(KT_FN,78) +#define K_F70 K(KT_FN,79) +#define K_F71 K(KT_FN,80) +#define K_F72 K(KT_FN,81) +#define K_F73 K(KT_FN,82) +#define K_F74 K(KT_FN,83) +#define K_F75 K(KT_FN,84) +#define K_F76 K(KT_FN,85) +#define K_F77 K(KT_FN,86) +#define K_F78 K(KT_FN,87) +#define K_F79 K(KT_FN,88) +#define K_F80 K(KT_FN,89) +#define K_F81 K(KT_FN,90) +#define K_F82 K(KT_FN,91) +#define K_F83 K(KT_FN,92) +#define K_F84 K(KT_FN,93) +#define K_F85 K(KT_FN,94) +#define K_F86 K(KT_FN,95) +#define K_F87 K(KT_FN,96) +#define K_F88 K(KT_FN,97) +#define K_F89 K(KT_FN,98) +#define K_F90 K(KT_FN,99) +#define K_F91 K(KT_FN,100) +#define K_F92 K(KT_FN,101) +#define K_F93 K(KT_FN,102) +#define K_F94 K(KT_FN,103) +#define K_F95 K(KT_FN,104) +#define K_F96 K(KT_FN,105) +#define K_F97 K(KT_FN,106) +#define K_F98 K(KT_FN,107) +#define K_F99 K(KT_FN,108) +#define K_F100 K(KT_FN,109) +#define K_F101 K(KT_FN,110) +#define K_F102 K(KT_FN,111) +#define K_F103 K(KT_FN,112) +#define K_F104 K(KT_FN,113) +#define K_F105 K(KT_FN,114) +#define K_F106 K(KT_FN,115) +#define K_F107 K(KT_FN,116) +#define K_F108 K(KT_FN,117) +#define K_F109 K(KT_FN,118) +#define K_F110 K(KT_FN,119) +#define K_F111 K(KT_FN,120) +#define K_F112 K(KT_FN,121) +#define K_F113 K(KT_FN,122) +#define K_F114 K(KT_FN,123) +#define K_F115 K(KT_FN,124) +#define K_F116 K(KT_FN,125) +#define K_F117 K(KT_FN,126) +#define K_F118 K(KT_FN,127) +#define K_F119 K(KT_FN,128) +#define K_F120 K(KT_FN,129) +#define K_F121 K(KT_FN,130) +#define K_F122 K(KT_FN,131) +#define K_F123 K(KT_FN,132) +#define K_F124 K(KT_FN,133) +#define K_F125 K(KT_FN,134) +#define K_F126 K(KT_FN,135) +#define K_F127 K(KT_FN,136) +#define K_F128 K(KT_FN,137) +#define K_F129 K(KT_FN,138) +#define K_F130 K(KT_FN,139) +#define K_F131 K(KT_FN,140) +#define K_F132 K(KT_FN,141) +#define K_F133 K(KT_FN,142) +#define K_F134 K(KT_FN,143) +#define K_F135 K(KT_FN,144) +#define K_F136 K(KT_FN,145) +#define K_F137 K(KT_FN,146) +#define K_F138 K(KT_FN,147) +#define K_F139 K(KT_FN,148) +#define K_F140 K(KT_FN,149) +#define K_F141 K(KT_FN,150) +#define K_F142 K(KT_FN,151) +#define K_F143 K(KT_FN,152) +#define K_F144 K(KT_FN,153) +#define K_F145 K(KT_FN,154) +#define K_F146 K(KT_FN,155) +#define K_F147 K(KT_FN,156) +#define K_F148 K(KT_FN,157) +#define K_F149 K(KT_FN,158) +#define K_F150 K(KT_FN,159) +#define K_F151 K(KT_FN,160) +#define K_F152 K(KT_FN,161) +#define K_F153 K(KT_FN,162) +#define K_F154 K(KT_FN,163) +#define K_F155 K(KT_FN,164) +#define K_F156 K(KT_FN,165) +#define K_F157 K(KT_FN,166) +#define K_F158 K(KT_FN,167) +#define K_F159 K(KT_FN,168) +#define K_F160 K(KT_FN,169) +#define K_F161 K(KT_FN,170) +#define K_F162 K(KT_FN,171) +#define K_F163 K(KT_FN,172) +#define K_F164 K(KT_FN,173) +#define K_F165 K(KT_FN,174) +#define K_F166 K(KT_FN,175) +#define K_F167 K(KT_FN,176) +#define K_F168 K(KT_FN,177) +#define K_F169 K(KT_FN,178) +#define K_F170 K(KT_FN,179) +#define K_F171 K(KT_FN,180) +#define K_F172 K(KT_FN,181) +#define K_F173 K(KT_FN,182) +#define K_F174 K(KT_FN,183) +#define K_F175 K(KT_FN,184) +#define K_F176 K(KT_FN,185) +#define K_F177 K(KT_FN,186) +#define K_F178 K(KT_FN,187) +#define K_F179 K(KT_FN,188) +#define K_F180 K(KT_FN,189) +#define K_F181 K(KT_FN,190) +#define K_F182 K(KT_FN,191) +#define K_F183 K(KT_FN,192) +#define K_F184 K(KT_FN,193) +#define K_F185 K(KT_FN,194) +#define K_F186 K(KT_FN,195) +#define K_F187 K(KT_FN,196) +#define K_F188 K(KT_FN,197) +#define K_F189 K(KT_FN,198) +#define K_F190 K(KT_FN,199) +#define K_F191 K(KT_FN,200) +#define K_F192 K(KT_FN,201) +#define K_F193 K(KT_FN,202) +#define K_F194 K(KT_FN,203) +#define K_F195 K(KT_FN,204) +#define K_F196 K(KT_FN,205) +#define K_F197 K(KT_FN,206) +#define K_F198 K(KT_FN,207) +#define K_F199 K(KT_FN,208) +#define K_F200 K(KT_FN,209) +#define K_F201 K(KT_FN,210) +#define K_F202 K(KT_FN,211) +#define K_F203 K(KT_FN,212) +#define K_F204 K(KT_FN,213) +#define K_F205 K(KT_FN,214) +#define K_F206 K(KT_FN,215) +#define K_F207 K(KT_FN,216) +#define K_F208 K(KT_FN,217) +#define K_F209 K(KT_FN,218) +#define K_F210 K(KT_FN,219) +#define K_F211 K(KT_FN,220) +#define K_F212 K(KT_FN,221) +#define K_F213 K(KT_FN,222) +#define K_F214 K(KT_FN,223) +#define K_F215 K(KT_FN,224) +#define K_F216 K(KT_FN,225) +#define K_F217 K(KT_FN,226) +#define K_F218 K(KT_FN,227) +#define K_F219 K(KT_FN,228) +#define K_F220 K(KT_FN,229) +#define K_F221 K(KT_FN,230) +#define K_F222 K(KT_FN,231) +#define K_F223 K(KT_FN,232) +#define K_F224 K(KT_FN,233) +#define K_F225 K(KT_FN,234) +#define K_F226 K(KT_FN,235) +#define K_F227 K(KT_FN,236) +#define K_F228 K(KT_FN,237) +#define K_F229 K(KT_FN,238) +#define K_F230 K(KT_FN,239) +#define K_F231 K(KT_FN,240) +#define K_F232 K(KT_FN,241) +#define K_F233 K(KT_FN,242) +#define K_F234 K(KT_FN,243) +#define K_F235 K(KT_FN,244) +#define K_F236 K(KT_FN,245) +#define K_F237 K(KT_FN,246) +#define K_F238 K(KT_FN,247) +#define K_F239 K(KT_FN,248) +#define K_F240 K(KT_FN,249) +#define K_F241 K(KT_FN,250) +#define K_F242 K(KT_FN,251) +#define K_F243 K(KT_FN,252) +#define K_F244 K(KT_FN,253) +#define K_F245 K(KT_FN,254) +#define K_F246 K(KT_FN,255) + + +#define K_HOLE K(KT_SPEC,0) +#define K_ENTER K(KT_SPEC,1) +#define K_SH_REGS K(KT_SPEC,2) +#define K_SH_MEM K(KT_SPEC,3) +#define K_SH_STAT K(KT_SPEC,4) +#define K_BREAK K(KT_SPEC,5) +#define K_CONS K(KT_SPEC,6) +#define K_CAPS K(KT_SPEC,7) +#define K_NUM K(KT_SPEC,8) +#define K_HOLD K(KT_SPEC,9) +#define K_SCROLLFORW K(KT_SPEC,10) +#define K_SCROLLBACK K(KT_SPEC,11) +#define K_BOOT K(KT_SPEC,12) +#define K_CAPSON K(KT_SPEC,13) +#define K_COMPOSE K(KT_SPEC,14) +#define K_SAK K(KT_SPEC,15) +#define K_DECRCONSOLE K(KT_SPEC,16) +#define K_INCRCONSOLE K(KT_SPEC,17) + +#define K_ALLOCATED K(KT_SPEC,126) /* dynamically allocated keymap */ +#define K_NOSUCHMAP K(KT_SPEC,127) /* returned by KDGKBENT */ + +#define K_P0 K(KT_PAD,0) +#define K_P1 K(KT_PAD,1) +#define K_P2 K(KT_PAD,2) +#define K_P3 K(KT_PAD,3) +#define K_P4 K(KT_PAD,4) +#define K_P5 K(KT_PAD,5) +#define K_P6 K(KT_PAD,6) +#define K_P7 K(KT_PAD,7) +#define K_P8 K(KT_PAD,8) +#define K_P9 K(KT_PAD,9) +#define K_PPLUS K(KT_PAD,10) /* key-pad plus */ +#define K_PMINUS K(KT_PAD,11) /* key-pad minus */ +#define K_PSTAR K(KT_PAD,12) /* key-pad asterisk (star) */ +#define K_PSLASH K(KT_PAD,13) /* key-pad slash */ +#define K_PENTER K(KT_PAD,14) /* key-pad enter */ +#define K_PCOMMA K(KT_PAD,15) /* key-pad comma: kludge... */ +#define K_PDOT K(KT_PAD,16) /* key-pad dot (period): kludge... */ +#define K_PPLUSMINUS K(KT_PAD,17) /* key-pad plus/minus */ + +#define NR_PAD 18 + +#define K_DGRAVE K(KT_DEAD,0) +#define K_DACUTE K(KT_DEAD,1) +#define K_DCIRCM K(KT_DEAD,2) +#define K_DTILDE K(KT_DEAD,3) +#define K_DDIERE K(KT_DEAD,4) + +#define NR_DEAD 5 + +#define K_DOWN K(KT_CUR,0) +#define K_LEFT K(KT_CUR,1) +#define K_RIGHT K(KT_CUR,2) +#define K_UP K(KT_CUR,3) + +#define K_SHIFT K(KT_SHIFT,KG_SHIFT) +#define K_CTRL K(KT_SHIFT,KG_CTRL) +#define K_ALT K(KT_SHIFT,KG_ALT) +#define K_ALTGR K(KT_SHIFT,KG_ALTGR) +#define K_SHIFTL K(KT_SHIFT,KG_SHIFTL) +#define K_SHIFTR K(KT_SHIFT,KG_SHIFTR) +#define K_CTRLL K(KT_SHIFT,KG_CTRLL) +#define K_CTRLR K(KT_SHIFT,KG_CTRLR) +#define K_CAPSSHIFT K(KT_SHIFT,KG_CAPSSHIFT) + +#define K_ASC0 K(KT_ASCII,0) +#define K_ASC1 K(KT_ASCII,1) +#define K_ASC2 K(KT_ASCII,2) +#define K_ASC3 K(KT_ASCII,3) +#define K_ASC4 K(KT_ASCII,4) +#define K_ASC5 K(KT_ASCII,5) +#define K_ASC6 K(KT_ASCII,6) +#define K_ASC7 K(KT_ASCII,7) +#define K_ASC8 K(KT_ASCII,8) +#define K_ASC9 K(KT_ASCII,9) +#define K_HEX0 K(KT_ASCII,10) +#define K_HEX1 K(KT_ASCII,11) +#define K_HEX2 K(KT_ASCII,12) +#define K_HEX3 K(KT_ASCII,13) +#define K_HEX4 K(KT_ASCII,14) +#define K_HEX5 K(KT_ASCII,15) +#define K_HEX6 K(KT_ASCII,16) +#define K_HEX7 K(KT_ASCII,17) +#define K_HEX8 K(KT_ASCII,18) +#define K_HEX9 K(KT_ASCII,19) +#define K_HEXa K(KT_ASCII,20) +#define K_HEXb K(KT_ASCII,21) +#define K_HEXc K(KT_ASCII,22) +#define K_HEXd K(KT_ASCII,23) +#define K_HEXe K(KT_ASCII,24) +#define K_HEXf K(KT_ASCII,25) + +#define NR_ASCII 26 + +#define K_SHIFTLOCK K(KT_LOCK,KG_SHIFT) +#define K_CTRLLOCK K(KT_LOCK,KG_CTRL) +#define K_ALTLOCK K(KT_LOCK,KG_ALT) +#define K_ALTGRLOCK K(KT_LOCK,KG_ALTGR) +#define K_SHIFTLLOCK K(KT_LOCK,KG_SHIFTL) +#define K_SHIFTRLOCK K(KT_LOCK,KG_SHIFTR) +#define K_CTRLLLOCK K(KT_LOCK,KG_CTRLL) +#define K_CTRLRLOCK K(KT_LOCK,KG_CTRLR) + +#define NR_LOCK 8 + +#define MAX_DIACR 256 +#endif diff --git a/include/linux/ldt.h b/include/linux/ldt.h new file mode 100644 index 000000000..83add4248 --- /dev/null +++ b/include/linux/ldt.h @@ -0,0 +1,34 @@ +/* + * ldt.h + * + * Definitions of structures used with the modify_ldt system call. + */ +#ifndef _LINUX_LDT_H +#define _LINUX_LDT_H + +/* Maximum number of LDT entries supported. */ +#define LDT_ENTRIES 8192 +/* The size of each LDT entry. */ +#define LDT_ENTRY_SIZE 8 + +struct modify_ldt_ldt_s { + unsigned int entry_number; + unsigned long base_addr; + unsigned int limit; + unsigned int seg_32bit:1; + unsigned int contents:2; + unsigned int read_exec_only:1; + unsigned int limit_in_pages:1; + unsigned int seg_not_present:1; +}; + +#define MODIFY_LDT_CONTENTS_DATA 0 +#define MODIFY_LDT_CONTENTS_STACK 1 +#define MODIFY_LDT_CONTENTS_CODE 2 + +extern int get_ldt(void *buffer); +extern int set_ldt_entry(int entry, unsigned long base, unsigned int limit, + int seg_32bit_flag, int contents, int read_only_flag, + int limit_in_pages_flag); + +#endif diff --git a/include/linux/limits.h b/include/linux/limits.h new file mode 100644 index 000000000..d0f300c4f --- /dev/null +++ b/include/linux/limits.h @@ -0,0 +1,17 @@ +#ifndef _LINUX_LIMITS_H +#define _LINUX_LIMITS_H + +#define NR_OPEN 256 + +#define NGROUPS_MAX 32 /* supplemental group IDs are available */ +#define ARG_MAX 131072 /* # bytes of args + environ for exec() */ +#define CHILD_MAX 999 /* no limit :-) */ +#define OPEN_MAX 256 /* # open files a process may have */ +#define LINK_MAX 127 /* # links a file may have */ +#define MAX_CANON 255 /* size of the canonical input queue */ +#define MAX_INPUT 255 /* size of the type-ahead buffer */ +#define NAME_MAX 255 /* # chars in a file name */ +#define PATH_MAX 1024 /* # chars in a path name */ +#define PIPE_BUF 4096 /* # bytes in atomic write to a pipe */ + +#endif diff --git a/include/linux/linkage.h b/include/linux/linkage.h new file mode 100644 index 000000000..8f5c4d5f2 --- /dev/null +++ b/include/linux/linkage.h @@ -0,0 +1,10 @@ +#ifndef _LINUX_LINKAGE_H +#define _LINUX_LINKAGE_H + +#ifdef __cplusplus +#define asmlinkage extern "C" +#else +#define asmlinkage +#endif + +#endif diff --git a/include/linux/locks.h b/include/linux/locks.h new file mode 100644 index 000000000..ac9b29076 --- /dev/null +++ b/include/linux/locks.h @@ -0,0 +1,56 @@ +#ifndef _LINUX_LOCKS_H +#define _LINUX_LOCKS_H + +/* + * Buffer cache locking - note that interrupts may only unlock, not + * lock buffers. + */ +extern void __wait_on_buffer(struct buffer_head *); + +extern inline void wait_on_buffer(struct buffer_head * bh) +{ + if (bh->b_lock) + __wait_on_buffer(bh); +} + +extern inline void lock_buffer(struct buffer_head * bh) +{ + if (bh->b_lock) + __wait_on_buffer(bh); + bh->b_lock = 1; +} + +extern inline void unlock_buffer(struct buffer_head * bh) +{ + bh->b_lock = 0; + wake_up(&bh->b_wait); +} + +/* + * super-block locking. Again, interrupts may only unlock + * a super-block (although even this isn't done right now. + * nfs may need it). + */ +extern void __wait_on_super(struct super_block *); + +extern inline void wait_on_super(struct super_block * sb) +{ + if (sb->s_lock) + __wait_on_super(sb); +} + +extern inline void lock_super(struct super_block * sb) +{ + if (sb->s_lock) + __wait_on_super(sb); + sb->s_lock = 1; +} + +extern inline void unlock_super(struct super_block * sb) +{ + sb->s_lock = 0; + wake_up(&sb->s_wait); +} + +#endif /* _LINUX_LOCKS_H */ + diff --git a/include/linux/lp.h b/include/linux/lp.h new file mode 100644 index 000000000..b8a1c03fc --- /dev/null +++ b/include/linux/lp.h @@ -0,0 +1,134 @@ +#ifndef _LINUX_LP_H +#define _LINUX_LP_H + +/* + * usr/include/linux/lp.h c.1991-1992 James Wiegand + * many modifications copyright (C) 1992 Michael K. Johnson + * Interrupt support added 1993 Nigel Gamble + */ + +/* + * Per POSIX guidelines, this module reserves the LP and lp prefixes + * These are the lp_table[minor].flags flags... + */ +#define LP_EXIST 0x0001 +#define LP_SELEC 0x0002 +#define LP_BUSY 0x0004 +#define LP_OFFL 0x0008 +#define LP_NOPA 0x0010 +#define LP_ERR 0x0020 +#define LP_ABORT 0x0040 + +/* timeout for each character. This is relative to bus cycles -- it + * is the count in a busy loop. THIS IS THE VALUE TO CHANGE if you + * have extremely slow printing, or if the machine seems to slow down + * a lot when you print. If you have slow printing, increase this + * number and recompile, and if your system gets bogged down, decrease + * this number. This can be changed with the tunelp(8) command as well. + */ + +#define LP_INIT_CHAR 1000 + +/* The parallel port specs apparently say that there needs to be + * a .5usec wait before and after the strobe. Since there are wildly + * different computers running linux, I can't come up with a perfect + * value, but since it worked well on most printers before without, + * I'll initialize it to 0. + */ + +#define LP_INIT_WAIT 0 + +/* This is the amount of time that the driver waits for the printer to + * catch up when the printer's buffer appears to be filled. If you + * want to tune this and have a fast printer (i.e. HPIIIP), decrease + * this number, and if you have a slow printer, increase this number. + * This is in hundredths of a second, the default 2 being .05 second. + * Or use the tunelp(8) command, which is especially nice if you want + * change back and forth between character and graphics printing, which + * are wildly different... + */ + +#define LP_INIT_TIME 2 + +/* IOCTL numbers */ +#define LPCHAR 0x0001 /* corresponds to LP_INIT_CHAR */ +#define LPTIME 0x0002 /* corresponds to LP_INIT_TIME */ +#define LPABORT 0x0004 /* call with TRUE arg to abort on error, + FALSE to retry. Default is retry. */ +#define LPSETIRQ 0x0005 /* call with new IRQ number, + or 0 for polling (no IRQ) */ +#define LPGETIRQ 0x0006 /* get the current IRQ number */ +#define LPWAIT 0x0008 /* corresponds to LP_INIT_WAIT */ + +/* timeout for printk'ing a timeout, in jiffies (100ths of a second). + This is also used for re-checking error conditions if LP_ABORT is + not set. This is the default behavior. */ + +#define LP_TIMEOUT_INTERRUPT (60 * HZ) +#define LP_TIMEOUT_POLLED (10 * HZ) + +#define LP_B(minor) lp_table[(minor)].base /* IO address */ +#define LP_F(minor) lp_table[(minor)].flags /* flags for busy, etc. */ +#define LP_S(minor) inb_p(LP_B((minor)) + 1) /* status port */ +#define LP_C(minor) (lp_table[(minor)].base + 2) /* control port */ +#define LP_CHAR(minor) lp_table[(minor)].chars /* busy timeout */ +#define LP_TIME(minor) lp_table[(minor)].time /* wait time */ +#define LP_WAIT(minor) lp_table[(minor)].wait /* strobe wait */ +#define LP_IRQ(minor) lp_table[(minor)].irq /* interrupt # */ + /* 0 means polled */ + +#define LP_BUFFER_SIZE 256 + +struct lp_struct { + int base; + unsigned int irq; + int flags; + unsigned int chars; + unsigned int time; + unsigned int wait; + struct wait_queue *lp_wait_q; + char *lp_buffer; +}; + +/* + * bit defines for 8255 status port + * base + 1 + * accessed with LP_S(minor), which gets the byte... + */ +#define LP_PBUSY 0x80 /* active low */ +#define LP_PACK 0x40 /* active low */ +#define LP_POUTPA 0x20 +#define LP_PSELECD 0x10 +#define LP_PERRORP 0x08 /* active low*/ + +/* + * defines for 8255 control port + * base + 2 + * accessed with LP_C(minor) + */ +#define LP_PINTEN 0x10 +#define LP_PSELECP 0x08 +#define LP_PINITP 0x04 /* active low */ +#define LP_PAUTOLF 0x02 +#define LP_PSTROBE 0x01 + +/* + * the value written to ports to test existence. PC-style ports will + * return the value written. AT-style ports will return 0. so why not + * make them the same ? + */ +#define LP_DUMMY 0x00 + +/* + * This is the port delay time. Your mileage may vary. + * It is used only in the lp_init() routine. + */ +#define LP_DELAY 150000 + +/* + * function prototypes + */ + +extern long lp_init(long); + +#endif diff --git a/include/linux/major.h b/include/linux/major.h new file mode 100644 index 000000000..da3eaf941 --- /dev/null +++ b/include/linux/major.h @@ -0,0 +1,95 @@ +#ifndef _LINUX_MAJOR_H +#define _LINUX_MAJOR_H + +/* + * This file has definitions for major device numbers + */ + +/* limits */ + +#define MAX_CHRDEV 32 +#define MAX_BLKDEV 32 + +/* + * assignments + * + * devices are as follows (same as minix, so we can use the minix fs): + * + * character block comments + * -------------------- -------------------- -------------------- + * 0 - unnamed unnamed minor 0 = true nodev + * 1 - /dev/mem ramdisk + * 2 - floppy + * 3 - hd + * 4 - /dev/tty* + * 5 - /dev/tty; /dev/cua* + * 6 - lp + * 7 - UNUSED + * 8 - scsi disk + * 9 - scsi tape + * 10 - mice + * 11 - scsi cdrom + * 12 - qic02 tape + * 13 - xt disk + * 14 - sound card + * 15 - cdu31a cdrom + * 16 - sockets + * 17 - af_unix + * 18 - af_inet + * 19 - UNUSED + * 20 - UNUSED + * 21 - scsi generic + * 22 - (at2disk) + * 23 - mitsumi cdrom + * 24 - sony535 cdrom + * 25 - matsushita cdrom minors 0..3 + * 26 - matsushita cdrom 2 minors 0..3 + * 27 - qic117 tape matsushita cdrom 3 minors 0..3 + * 28 - matsushita cdrom 4 minors 0..3 + */ + +#define UNNAMED_MAJOR 0 +#define MEM_MAJOR 1 +#define FLOPPY_MAJOR 2 +#define HD_MAJOR 3 +#define TTY_MAJOR 4 +#define TTYAUX_MAJOR 5 +#define LP_MAJOR 6 +/* unused: 7 */ +#define SCSI_DISK_MAJOR 8 +#define SCSI_TAPE_MAJOR 9 +#define MOUSE_MAJOR 10 +#define SCSI_CDROM_MAJOR 11 +#define QIC02_TAPE_MAJOR 12 +#define XT_DISK_MAJOR 13 +#define SOUND_MAJOR 14 +#define CDU31A_CDROM_MAJOR 15 +#define SOCKET_MAJOR 16 +#define AF_UNIX_MAJOR 17 +#define AF_INET_MAJOR 18 +/* unused: 19, 20 */ +#define SCSI_GENERIC_MAJOR 21 +/* unused: 22 */ +#define MITSUMI_CDROM_MAJOR 23 +#define CDU535_CDROM_MAJOR 24 +#define MATSUSHITA_CDROM_MAJOR 25 +#define MATSUSHITA_CDROM2_MAJOR 26 +#define MATSUSHITA_CDROM3_MAJOR 27 +#define MATSUSHITA_CDROM4_MAJOR 28 +#define QIC117_TAPE_MAJOR 27 + +/* + * Tests for SCSI devices. + */ + +#define SCSI_MAJOR(M) \ + ((M) == SCSI_DISK_MAJOR \ + || (M) == SCSI_TAPE_MAJOR \ + || (M) == SCSI_CDROM_MAJOR \ + || (M) == SCSI_GENERIC_MAJOR) + +static inline int scsi_major(int m) { + return SCSI_MAJOR(m); +} + +#endif diff --git a/include/linux/malloc.h b/include/linux/malloc.h new file mode 100644 index 000000000..b803b8b8d --- /dev/null +++ b/include/linux/malloc.h @@ -0,0 +1,30 @@ +#ifndef _LINUX_MALLOC_H +#define _LINUX_MALLOC_H + +#include <linux/config.h> + +#ifdef CONFIG_DEBUG_MALLOC +#define kmalloc(a,b) deb_kmalloc(__FILE__,__LINE__,a,b) +#define kfree_s(a,b) deb_kfree_s(__FILE__,__LINE__,a,b) + +void *deb_kmalloc(const char *deb_file, unsigned short deb_line,unsigned int size, int priority); +void deb_kfree_s (const char *deb_file, unsigned short deb_line,void * obj, int size); +void deb_kcheck_s(const char *deb_file, unsigned short deb_line,void * obj, int size); + +#define kfree(a) deb_kfree_s(__FILE__,__LINE__, a,0) +#define kcheck(a) deb_kcheck_s(__FILE__,__LINE__, a,0) +#define kcheck_s(a,b) deb_kcheck_s(__FILE__,__LINE__, a,b) + +#else /* !debug */ + +void * kmalloc(unsigned int size, int priority); +void kfree_s(void * obj, int size); + +#define kcheck_s(a,b) 0 + +#define kfree(x) kfree_s((x), 0) +#define kcheck(x) kcheck_s((x), 0) + +#endif + +#endif /* _LINUX_MALLOC_H */ diff --git a/include/linux/math_emu.h b/include/linux/math_emu.h new file mode 100644 index 000000000..0d9606d94 --- /dev/null +++ b/include/linux/math_emu.h @@ -0,0 +1,43 @@ +#ifndef _LINUX_MATH_EMU_H +#define _LINUX_MATH_EMU_H + +struct fpu_reg { + char sign; + char tag; + long exp; + unsigned sigl; + unsigned sigh; +}; + + +/* This structure matches the layout of the data saved to the stack + following a device-not-present interrupt, part of it saved + automatically by the 80386/80486. + */ +struct info { + long ___orig_eip; + long ___ret_from_system_call; + long ___ebx; + long ___ecx; + long ___edx; + long ___esi; + long ___edi; + long ___ebp; + long ___eax; + long ___ds; + long ___es; + long ___fs; + long ___gs; + long ___orig_eax; + long ___eip; + long ___cs; + long ___eflags; + long ___esp; + long ___ss; + long ___vm86_es; /* This and the following only in vm86 mode */ + long ___vm86_ds; + long ___vm86_fs; + long ___vm86_gs; +}; + +#endif diff --git a/include/linux/mc146818rtc.h b/include/linux/mc146818rtc.h new file mode 100644 index 000000000..741aa2dc5 --- /dev/null +++ b/include/linux/mc146818rtc.h @@ -0,0 +1,104 @@ +/* mc146818rtc.h - register definitions for the Real-Time-Clock / CMOS RAM + * Copyright Torsten Duwe <duwe@informatik.uni-erlangen.de> 1993 + * derived from Data Sheet, Copyright Motorola 1984 (!). + * It was written to be part of the Linux operating system. + */ +/* permission is hereby granted to copy, modify and redistribute this code + * in terms of the GNU Library General Public License, Version 2 or later, + * at your option. + */ + +#ifndef _MC146818RTC_H +#define _MC146818RTC_H +#include <asm/io.h> + +#define CMOS_READ(addr) ({ \ +outb_p(addr|0x80,0x70); \ +inb_p(0x71); \ +}) +#define CMOS_WRITE(val, addr) ({ \ +outb_p(addr|0x80,0x70); \ +outb_p(val,0x71); \ +}) + +/********************************************************************** + * register summary + **********************************************************************/ +#define RTC_SECONDS 0 +#define RTC_SECONDS_ALARM 1 +#define RTC_MINUTES 2 +#define RTC_MINUTES_ALARM 3 +#define RTC_HOURS 4 +#define RTC_HOURS_ALARM 5 +/* RTC_*_alarm is always true if 2 MSBs are set */ +# define RTC_ALARM_DONT_CARE 0xC0 + +#define RTC_DAY_OF_WEEK 6 +#define RTC_DAY_OF_MONTH 7 +#define RTC_MONTH 8 +#define RTC_YEAR 9 + +/* control registers - Moto names + */ +#define RTC_REG_A 10 +#define RTC_REG_B 11 +#define RTC_REG_C 12 +#define RTC_REG_D 13 + +/********************************************************************** + * register details + **********************************************************************/ +#define RTC_FREQ_SELECT RTC_REG_A + +/* update-in-progress - set to "1" 244 microsecs before RTC goes off the bus, + * reset after update (may take 1.984ms @ 32768Hz RefClock) is complete, + * totalling to a max high interval of 2.228 ms. + */ +# define RTC_UIP 0x80 +# define RTC_DIV_CTL 0x70 + /* divider control: refclock values 4.194 / 1.049 MHz / 32.768 kHz */ +# define RTC_REF_CLCK_4MHZ 0x00 +# define RTC_REF_CLCK_1MHZ 0x10 +# define RTC_REF_CLCK_32KHZ 0x20 + /* 2 values for divider stage reset, others for "testing purposes only" */ +# define RTC_DIV_RESET1 0x60 +# define RTC_DIV_RESET2 0x70 + /* Periodic intr. / Square wave rate select. 0=none, 1=32.8kHz,... 15=2Hz */ +# define RTC_RATE_SELECT 0x0F + +/**********************************************************************/ +#define RTC_CONTROL RTC_REG_B +# define RTC_SET 0x80 /* disable updates for clock setting */ +# define RTC_PIE 0x40 /* periodic interrupt enable */ +# define RTC_AIE 0x20 /* alarm interrupt enable */ +# define RTC_UIE 0x10 /* update-finished interrupt enable */ +# define RTC_SQWE 0x08 /* enable square-wave output */ +# define RTC_DM_BINARY 0x04 /* all time/date values are BCD if clear */ +# define RTC_24H 0x02 /* 24 hour mode - else hours bit 7 means pm */ +# define RTC_DST_EN 0x01 /* auto switch DST - works f. USA only */ + +/**********************************************************************/ +#define RTC_INTR_FLAGS RTC_REG_C +/* caution - cleared by read */ +# define RTC_IRQF 0x80 /* any of the following 3 is active */ +# define RTC_PF 0x40 +# define RTC_AF 0x20 +# define RTC_UF 0x10 + +/**********************************************************************/ +#define RTC_VALID RTC_REG_D +# define RTC_VRT 0x80 /* valid RAM and time */ +/**********************************************************************/ + +/* example: !(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) + * determines if the following two #defines are needed + */ +#ifndef BCD_TO_BIN +#define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10) +#endif + +#ifndef BIN_TO_BCD +#define BIN_TO_BCD(val) ((val)=(((val)/10)<<4) + (val)%10) +#endif + +#endif /* _MC146818RTC_H */ diff --git a/include/linux/mcd.h b/include/linux/mcd.h new file mode 100644 index 000000000..975a3f840 --- /dev/null +++ b/include/linux/mcd.h @@ -0,0 +1,107 @@ +/* + * Definitions for a Mitsumi CD-ROM interface + * + * Copyright (C) 1992 Martin Harriss + * + * martin@bdsi.com + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +/* *** change this to set the I/O port address */ +#define MCD_BASE_ADDR 0x300 + +/* *** change this to set the interrupt number */ +#define MCD_INTR_NR 10 + +/* Increase this if you get lots of timeouts */ +#define MCD_STATUS_DELAY 200 + +/* number of times to retry a command before giving up */ +#define MCD_RETRY_ATTEMPTS 5 + +/* port access macro */ +#define MCDPORT(x) (mcd_port + (x)) + +/* status bits */ + +#define MST_CMD_CHECK 0x01 /* command error */ +#define MST_BUSY 0x02 /* now playing */ +#define MST_READ_ERR 0x04 /* read error */ +#define MST_DSK_TYPE 0x08 +#define MST_SERVO_CHECK 0x10 +#define MST_DSK_CHG 0x20 /* disk removed or changed */ +#define MST_READY 0x40 /* disk in the drive */ +#define MST_DOOR_OPEN 0x80 /* door is open */ + +/* flag bits */ + +#define MFL_DATA 0x02 /* data available */ +#define MFL_STATUS 0x04 /* status available */ + +/* commands */ + +#define MCMD_GET_DISK_INFO 0x10 /* read info from disk */ +#define MCMD_GET_Q_CHANNEL 0x20 /* read info from q channel */ +#define MCMD_GET_STATUS 0x40 +#define MCMD_SET_MODE 0x50 +#define MCMD_SOFT_RESET 0x60 +#define MCMD_STOP 0x70 /* stop play */ +#define MCMD_CONFIG_DRIVE 0x90 +#define MCMD_SET_VOLUME 0xAE /* set audio level */ +#define MCMD_PLAY_READ 0xC0 /* play or read data */ +#define MCMD_GET_VERSION 0xDC +#define MCMD_EJECT 0xF6 /* eject (FX drive) */ + +/* borrowed from hd.c */ + +#define READ_DATA(port, buf, nr) \ +insb(port, buf, nr) + +#define SET_TIMER(func, jifs) \ + ((timer_table[MCD_TIMER].expires = jiffies + jifs), \ + (timer_table[MCD_TIMER].fn = func), \ + (timer_active |= 1<<MCD_TIMER)) + +#define CLEAR_TIMER timer_active &= ~(1<<MCD_TIMER) + +#define MAX_TRACKS 104 + +struct msf { + unsigned char min; + unsigned char sec; + unsigned char frame; +}; + +struct mcd_Play_msf { + struct msf start; + struct msf end; +}; + +struct mcd_DiskInfo { + unsigned char first; + unsigned char last; + struct msf diskLength; + struct msf firstTrack; +}; + +struct mcd_Toc { + unsigned char ctrl_addr; + unsigned char track; + unsigned char pointIndex; + struct msf trackTime; + struct msf diskTime; +}; diff --git a/include/linux/minix_fs.h b/include/linux/minix_fs.h new file mode 100644 index 000000000..971a50d8a --- /dev/null +++ b/include/linux/minix_fs.h @@ -0,0 +1,123 @@ +#ifndef _LINUX_MINIX_FS_H +#define _LINUX_MINIX_FS_H + +/* + * The minix filesystem constants/structures + */ + +/* + * Thanks to Kees J Bot for sending me the definitions of the new + * minix filesystem (aka V2) with bigger inodes and 32-bit block + * pointers. It's not actually implemented yet, but I'll look into + * it. + */ + +#define MINIX_ROOT_INO 1 + +/* Not the same as the bogus LINK_MAX in <linux/limits.h>. Oh well. */ +#define MINIX_LINK_MAX 250 + +#define MINIX_I_MAP_SLOTS 8 +#define MINIX_Z_MAP_SLOTS 8 +#define MINIX_SUPER_MAGIC 0x137F /* original minix fs */ +#define MINIX_SUPER_MAGIC2 0x138F /* minix fs, 30 char names */ +#define NEW_MINIX_SUPER_MAGIC 0x2468 /* minix V2 - not implemented */ +#define MINIX_VALID_FS 0x0001 /* Clean fs. */ +#define MINIX_ERROR_FS 0x0002 /* fs has errors. */ + +#define MINIX_INODES_PER_BLOCK ((BLOCK_SIZE)/(sizeof (struct minix_inode))) + +struct minix_inode { + unsigned short i_mode; + unsigned short i_uid; + unsigned long i_size; + unsigned long i_time; + unsigned char i_gid; + unsigned char i_nlinks; + unsigned short i_zone[9]; +}; + +/* + * The new minix inode has all the time entries, as well as + * long block numbers and a third indirect block (7+1+1+1 + * instead of 7+1+1). Also, some previously 8-bit values are + * now 16-bit. The inode is now 64 bytes instead of 32. + */ +struct new_minix_inode { + unsigned short i_mode; + unsigned short i_nlinks; + unsigned short i_uid; + unsigned short i_gid; + unsigned long i_size; + unsigned long i_atime; + unsigned long i_mtime; + unsigned long i_ctime; + unsigned long i_zone[10]; +}; + +/* + * minix super-block data on disk + */ +struct minix_super_block { + unsigned short s_ninodes; + unsigned short s_nzones; + unsigned short s_imap_blocks; + unsigned short s_zmap_blocks; + unsigned short s_firstdatazone; + unsigned short s_log_zone_size; + unsigned long s_max_size; + unsigned short s_magic; + unsigned short s_state; +}; + +struct minix_dir_entry { + unsigned short inode; + char name[0]; +}; + +#ifdef __KERNEL__ + +extern int minix_lookup(struct inode * dir,const char * name, int len, + struct inode ** result); +extern int minix_create(struct inode * dir,const char * name, int len, int mode, + struct inode ** result); +extern int minix_mkdir(struct inode * dir, const char * name, int len, int mode); +extern int minix_rmdir(struct inode * dir, const char * name, int len); +extern int minix_unlink(struct inode * dir, const char * name, int len); +extern int minix_symlink(struct inode * inode, const char * name, int len, + const char * symname); +extern int minix_link(struct inode * oldinode, struct inode * dir, const char * name, int len); +extern int minix_mknod(struct inode * dir, const char * name, int len, int mode, int rdev); +extern int minix_rename(struct inode * old_dir, const char * old_name, int old_len, + struct inode * new_dir, const char * new_name, int new_len); +extern struct inode * minix_new_inode(const struct inode * dir); +extern void minix_free_inode(struct inode * inode); +extern unsigned long minix_count_free_inodes(struct super_block *sb); +extern int minix_new_block(struct super_block * sb); +extern void minix_free_block(struct super_block * sb, int block); +extern unsigned long minix_count_free_blocks(struct super_block *sb); + +extern int minix_bmap(struct inode *,int); + +extern struct buffer_head * minix_getblk(struct inode *, int, int); +extern struct buffer_head * minix_bread(struct inode *, int, int); + +extern void minix_truncate(struct inode *); +extern void minix_put_super(struct super_block *); +extern struct super_block *minix_read_super(struct super_block *,void *,int); +extern void minix_write_super(struct super_block *); +extern int minix_remount (struct super_block * sb, int * flags, char * data); +extern void minix_read_inode(struct inode *); +extern void minix_write_inode(struct inode *); +extern void minix_put_inode(struct inode *); +extern void minix_statfs(struct super_block *, struct statfs *); +extern int minix_sync_inode(struct inode *); +extern int minix_sync_file(struct inode *, struct file *); + +extern struct inode_operations minix_file_inode_operations; +extern struct inode_operations minix_dir_inode_operations; +extern struct inode_operations minix_symlink_inode_operations; + +#endif /* __KERNEL__ */ + +#endif diff --git a/include/linux/minix_fs_i.h b/include/linux/minix_fs_i.h new file mode 100644 index 000000000..6478627bc --- /dev/null +++ b/include/linux/minix_fs_i.h @@ -0,0 +1,11 @@ +#ifndef _MINIX_FS_I +#define _MINIX_FS_I + +/* + * minix fs inode data in memory + */ +struct minix_inode_info { + unsigned short i_data[16]; +}; + +#endif diff --git a/include/linux/minix_fs_sb.h b/include/linux/minix_fs_sb.h new file mode 100644 index 000000000..a48347980 --- /dev/null +++ b/include/linux/minix_fs_sb.h @@ -0,0 +1,24 @@ +#ifndef _MINIX_FS_SB +#define _MINIX_FS_SB + +/* + * minix super-block data in memory + */ +struct minix_sb_info { + unsigned long s_ninodes; + unsigned long s_nzones; + unsigned long s_imap_blocks; + unsigned long s_zmap_blocks; + unsigned long s_firstdatazone; + unsigned long s_log_zone_size; + unsigned long s_max_size; + struct buffer_head * s_imap[8]; + struct buffer_head * s_zmap[8]; + unsigned long s_dirsize; + unsigned long s_namelen; + struct buffer_head * s_sbh; + struct minix_super_block * s_ms; + unsigned short s_mount_state; +}; + +#endif diff --git a/include/linux/mm.h b/include/linux/mm.h new file mode 100644 index 000000000..e2128f033 --- /dev/null +++ b/include/linux/mm.h @@ -0,0 +1,314 @@ +#ifndef _LINUX_MM_H +#define _LINUX_MM_H + +#include <asm/page.h> + +#include <linux/sched.h> +#include <linux/errno.h> +#include <linux/kernel.h> + +#define VERIFY_READ 0 +#define VERIFY_WRITE 1 + +extern int verify_area(int, const void *, unsigned long); + +/* + * Linux kernel virtual memory manager primitives. + * The idea being to have a "virtual" mm in the same way + * we have a virtual fs - giving a cleaner interface to the + * mm details, and allowing different kinds of memory mappings + * (from shared memory to executable loading to arbitrary + * mmap() functions). + */ + +/* + * This struct defines a memory VMM memory area. There is one of these + * per VM-area/task. A VM area is any part of the process virtual memory + * space that has a special rule for the page-fault handlers (ie a shared + * library, the executable area etc). + */ +struct vm_area_struct { + struct task_struct * vm_task; /* VM area parameters */ + unsigned long vm_start; + unsigned long vm_end; + unsigned short vm_page_prot; + unsigned short vm_flags; + struct vm_area_struct * vm_next; /* linked list */ + struct vm_area_struct * vm_share; /* linked list */ + struct vm_operations_struct * vm_ops; + unsigned long vm_offset; + struct inode * vm_inode; + unsigned long vm_pte; /* shared mem */ +}; + +/* + * vm_flags.. + */ +#define VM_READ 0x0001 /* currently active flags */ +#define VM_WRITE 0x0002 +#define VM_EXEC 0x0004 +#define VM_SHARED 0x0008 + +#define VM_MAYREAD 0x0010 /* limits for mprotect() etc */ +#define VM_MAYWRITE 0x0020 +#define VM_MAYEXEC 0x0040 +#define VM_MAYSHARE 0x0080 + +#define VM_GROWSDOWN 0x0100 /* general info on the segment */ +#define VM_GROWSUP 0x0200 +#define VM_SHM 0x0400 +#define VM_DENYWRITE 0x0800 /* ETXTBSY on write attempts.. */ + +#define VM_EXECUTABLE 0x1000 + +#define VM_STACK_FLAGS 0x0177 + +/* + * These are the virtual MM functions - opening of an area, closing it (needed to + * keep files on disk up-to-date etc), pointer to the functions called when a + * no-page or a wp-page exception occurs, and the function which decides on sharing + * of pages between different processes. + */ +struct vm_operations_struct { + void (*open)(struct vm_area_struct * area); + void (*close)(struct vm_area_struct * area); + unsigned long (*nopage)(struct vm_area_struct * area, unsigned long address, + unsigned long page, int error_code); + unsigned long (*wppage)(struct vm_area_struct * area, unsigned long address, + unsigned long page); + int (*share)(struct vm_area_struct * from, struct vm_area_struct * to, unsigned long address); + int (*unmap)(struct vm_area_struct *area, unsigned long, size_t); + void (*swapout)(struct vm_area_struct *, unsigned long *); + unsigned long (*swapin)(struct vm_area_struct *, unsigned long); +}; + +extern unsigned long __bad_page(void); +extern unsigned long __bad_pagetable(void); +extern unsigned long __zero_page(void); + +#define BAD_PAGETABLE __bad_pagetable() +#define BAD_PAGE __bad_page() +#define ZERO_PAGE __zero_page() + +/* planning stage.. */ +#define P_DIRTY 0x0001 +#define P_LOCKED 0x0002 +#define P_UPTODATE 0x0004 +#define P_RESERVED 0x8000 + +struct page_info { + unsigned short flags; + unsigned short count; + struct inode * inode; + unsigned long offset; + struct page_info * next_same_inode; + struct page_info * prev_same_inode; + struct page_info * next_hash; + struct page_info * prev_hash; + struct wait_queue *wait; +}; +/* end of planning stage */ + +#ifdef __KERNEL__ + +/* + * Free area management + */ + +extern int nr_swap_pages; +extern int nr_free_pages; +extern int min_free_pages; + +#define NR_MEM_LISTS 6 + +struct mem_list { + struct mem_list * next; + struct mem_list * prev; +}; + +extern struct mem_list free_area_list[NR_MEM_LISTS]; +extern unsigned char * free_area_map[NR_MEM_LISTS]; + +/* + * This is timing-critical - most of the time in getting a new page + * goes to clearing the page. If you want a page without the clearing + * overhead, just use __get_free_page() directly.. + */ +#define __get_free_page(priority) __get_free_pages((priority),0) +extern unsigned long __get_free_pages(int priority, unsigned long gfporder); +extern inline unsigned long get_free_page(int priority) +{ + unsigned long page; + + page = __get_free_page(priority); + if (page) + __asm__ __volatile__("rep ; stosl" + : /* no outputs */ \ + :"a" (0),"c" (1024),"D" (page) + :"di","cx"); + return page; +} + +/* memory.c & swap.c*/ + +#define free_page(addr) free_pages((addr),0) +extern void free_pages(unsigned long addr, unsigned long order); + +extern void show_free_areas(void); +extern unsigned long put_dirty_page(struct task_struct * tsk,unsigned long page, + unsigned long address); + +extern void free_page_tables(struct task_struct * tsk); +extern void clear_page_tables(struct task_struct * tsk); +extern int copy_page_tables(struct task_struct * to); +extern int clone_page_tables(struct task_struct * to); +extern int unmap_page_range(unsigned long from, unsigned long size); +extern int remap_page_range(unsigned long from, unsigned long to, unsigned long size, int mask); +extern int zeromap_page_range(unsigned long from, unsigned long size, int mask); + +extern void do_wp_page(struct vm_area_struct * vma, unsigned long address, + unsigned long error_code); +extern void do_no_page(struct vm_area_struct * vma, unsigned long address, + unsigned long error_code); + +extern unsigned long paging_init(unsigned long start_mem, unsigned long end_mem); +extern void mem_init(unsigned long low_start_mem, + unsigned long start_mem, unsigned long end_mem); +extern void show_mem(void); +extern void oom(struct task_struct * task); +extern void si_meminfo(struct sysinfo * val); + +/* vmalloc.c */ + +extern void * vmalloc(unsigned long size); +extern void vfree(void * addr); +extern int vread(char *buf, char *addr, int count); + +/* swap.c */ + +extern void swap_free(unsigned long page_nr); +extern unsigned long swap_duplicate(unsigned long page_nr); +extern unsigned long swap_in(unsigned long entry); +extern void si_swapinfo(struct sysinfo * val); +extern void rw_swap_page(int rw, unsigned long nr, char * buf); + +/* mmap.c */ +extern int do_mmap(struct file * file, unsigned long addr, unsigned long len, + unsigned long prot, unsigned long flags, unsigned long off); +extern void merge_segments(struct vm_area_struct *); +extern void insert_vm_struct(struct task_struct *, struct vm_area_struct *); +extern int do_munmap(unsigned long, size_t); +extern unsigned long get_unmapped_area(unsigned long); + +#define read_swap_page(nr,buf) \ + rw_swap_page(READ,(nr),(buf)) +#define write_swap_page(nr,buf) \ + rw_swap_page(WRITE,(nr),(buf)) + +extern unsigned long high_memory; + +#define MAP_NR(addr) ((addr) >> PAGE_SHIFT) +#define MAP_PAGE_RESERVED (1<<15) + +extern unsigned short * mem_map; + +#define PAGE_PRESENT 0x001 +#define PAGE_RW 0x002 +#define PAGE_USER 0x004 +#define PAGE_PWT 0x008 /* 486 only - not used currently */ +#define PAGE_PCD 0x010 /* 486 only - not used currently */ +#define PAGE_ACCESSED 0x020 +#define PAGE_DIRTY 0x040 +#define PAGE_COW 0x200 /* implemented in software (one of the AVL bits) */ + +#define PAGE_PRIVATE (PAGE_PRESENT | PAGE_RW | PAGE_USER | PAGE_ACCESSED | PAGE_COW) +#define PAGE_SHARED (PAGE_PRESENT | PAGE_RW | PAGE_USER | PAGE_ACCESSED) +#define PAGE_COPY (PAGE_PRESENT | PAGE_USER | PAGE_ACCESSED | PAGE_COW) +#define PAGE_READONLY (PAGE_PRESENT | PAGE_USER | PAGE_ACCESSED) +#define PAGE_TABLE (PAGE_PRESENT | PAGE_RW | PAGE_USER | PAGE_ACCESSED) + +#define GFP_BUFFER 0x00 +#define GFP_ATOMIC 0x01 +#define GFP_USER 0x02 +#define GFP_KERNEL 0x03 +#define GFP_NOBUFFER 0x04 +#define GFP_NFS 0x05 + +/* Flag - indicates that the buffer will be suitable for DMA. Ignored on some + platforms, used as appropriate on others */ + +#define GFP_DMA 0x80 + +/* + * vm_ops not present page codes for shared memory. + * + * Will go away eventually.. + */ +#define SHM_SWP_TYPE 0x41 +extern void shm_no_page (ulong *); + +/* + * swap cache stuff (in swap.c) + */ +#define SWAP_CACHE_INFO + +extern unsigned long * swap_cache; + +#ifdef SWAP_CACHE_INFO +extern unsigned long swap_cache_add_total; +extern unsigned long swap_cache_add_success; +extern unsigned long swap_cache_del_total; +extern unsigned long swap_cache_del_success; +extern unsigned long swap_cache_find_total; +extern unsigned long swap_cache_find_success; +#endif + +extern inline unsigned long in_swap_cache(unsigned long addr) +{ + return swap_cache[addr >> PAGE_SHIFT]; +} + +extern inline long find_in_swap_cache (unsigned long addr) +{ + unsigned long entry; + +#ifdef SWAP_CACHE_INFO + swap_cache_find_total++; +#endif + __asm__ __volatile__("xchgl %0,%1" + :"=m" (swap_cache[addr >> PAGE_SHIFT]), + "=r" (entry) + :"0" (swap_cache[addr >> PAGE_SHIFT]), + "1" (0)); +#ifdef SWAP_CACHE_INFO + if (entry) + swap_cache_find_success++; +#endif + return entry; +} + +extern inline int delete_from_swap_cache(unsigned long addr) +{ + unsigned long entry; + +#ifdef SWAP_CACHE_INFO + swap_cache_del_total++; +#endif + __asm__ __volatile__("xchgl %0,%1" + :"=m" (swap_cache[addr >> PAGE_SHIFT]), + "=r" (entry) + :"0" (swap_cache[addr >> PAGE_SHIFT]), + "1" (0)); + if (entry) { +#ifdef SWAP_CACHE_INFO + swap_cache_del_success++; +#endif + swap_free(entry); + return 1; + } + return 0; +} + +#endif /* __KERNEL__ */ + +#endif diff --git a/include/linux/mman.h b/include/linux/mman.h new file mode 100644 index 000000000..082fd88b7 --- /dev/null +++ b/include/linux/mman.h @@ -0,0 +1,19 @@ +#ifndef _LINUX_MMAN_H +#define _LINUX_MMAN_H + +#define PROT_READ 0x1 /* page can be read */ +#define PROT_WRITE 0x2 /* page can be written */ +#define PROT_EXEC 0x4 /* page can be executed */ +#define PROT_NONE 0x0 /* page can not be accessed */ + +#define MAP_SHARED 1 /* Share changes */ +#define MAP_PRIVATE 2 /* Changes are private */ +#define MAP_TYPE 0xf /* Mask for type of mapping */ +#define MAP_FIXED 0x10 /* Interpret addr exactly */ +#define MAP_ANONYMOUS 0x20 /* don't use a file */ + +#define MAP_GROWSDOWN 0x0400 /* stack-like segment */ +#define MAP_DENYWRITE 0x0800 /* ETXTBSY */ +#define MAP_EXECUTABLE 0x1000 /* mark it as a executable */ + +#endif /* _LINUX_MMAN_H */ diff --git a/include/linux/module.h b/include/linux/module.h new file mode 100644 index 000000000..b82fa281b --- /dev/null +++ b/include/linux/module.h @@ -0,0 +1,81 @@ +/* + * Dynamic loading of modules into the kernel. + * + * Modified by Bjorn Ekwall <bj0rn@blox.se> + */ + +#ifndef _LINUX_MODULE_H +#define _LINUX_MODULE_H + +/* values of module.state */ +#define MOD_UNINITIALIZED 0 +#define MOD_RUNNING 1 +#define MOD_DELETED 2 + +/* maximum length of module name */ +#define MOD_MAX_NAME 64 + +/* maximum length of symbol name */ +#define SYM_MAX_NAME 60 + +struct kernel_sym { /* sent to "insmod" */ + unsigned long value; /* value of symbol */ + char name[SYM_MAX_NAME]; /* name of symbol */ +}; + +struct module_ref { + struct module *module; + struct module_ref *next; +}; + +struct internal_symbol { + void *addr; + char *name; + }; + +struct symbol_table { /* received from "insmod" */ + int size; /* total, including string table!!! */ + int n_symbols; + int n_refs; + struct internal_symbol symbol[0]; /* actual size defined by n_symbols */ + struct module_ref ref[0]; /* actual size defined by n_refs */ +}; +/* + * Note: The string table follows immediately after the symbol table in memory! + */ + +struct module { + struct module *next; + struct module_ref *ref; /* the list of modules that refer to me */ + struct symbol_table *symtab; + char *name; + int size; /* size of module in pages */ + void* addr; /* address of module */ + int state; + void (*cleanup)(void); /* cleanup routine */ +}; + +struct mod_routines { + int (*init)(void); /* initialization routine */ + void (*cleanup)(void); /* cleanup routine */ +}; + +/* rename_module_symbol(old_name, new_name) WOW! */ +extern int rename_module_symbol(char *, char *); + + +/* + * The first word of the module contains the use count. + */ +#define GET_USE_COUNT(module) (* (int *) (module)->addr) +/* + * define the count variable, and usage macros. + */ + +extern int mod_use_count_; + +#define MOD_INC_USE_COUNT mod_use_count_++ +#define MOD_DEC_USE_COUNT mod_use_count_-- +#define MOD_IN_USE (mod_use_count_ != 0) + +#endif diff --git a/include/linux/mouse.h b/include/linux/mouse.h new file mode 100644 index 000000000..df4e42718 --- /dev/null +++ b/include/linux/mouse.h @@ -0,0 +1,11 @@ +#ifndef _LINUX_MOUSE_H +#define _LINUX_MOUSE_H + +#define BUSMOUSE_MINOR 0 +#define PSMOUSE_MINOR 1 +#define MS_BUSMOUSE_MINOR 2 +#define ATIXL_BUSMOUSE_MINOR 3 + +unsigned long mouse_init(unsigned long); + +#endif diff --git a/include/linux/msdos_fs.h b/include/linux/msdos_fs.h new file mode 100644 index 000000000..dd6699a0d --- /dev/null +++ b/include/linux/msdos_fs.h @@ -0,0 +1,194 @@ +#ifndef _LINUX_MSDOS_FS_H +#define _LINUX_MSDOS_FS_H + +/* + * The MS-DOS filesystem constants/structures + */ +#include <linux/fs.h> +#include <linux/stat.h> +#include <linux/fd.h> + +#define MSDOS_ROOT_INO 1 /* == MINIX_ROOT_INO */ +#define SECTOR_SIZE 512 /* sector size (bytes) */ +#define SECTOR_BITS 9 /* log2(SECTOR_SIZE) */ +#define MSDOS_DPB (MSDOS_DPS) /* dir entries per block */ +#define MSDOS_DPB_BITS 4 /* log2(MSDOS_DPB) */ +#define MSDOS_DPS (SECTOR_SIZE/sizeof(struct msdos_dir_entry)) +#define MSDOS_DPS_BITS 4 /* log2(MSDOS_DPS) */ +#define MSDOS_DIR_BITS 5 /* log2(sizeof(struct msdos_dir_entry)) */ + +#define MSDOS_SUPER_MAGIC 0x4d44 /* MD */ + +#define FAT_CACHE 8 /* FAT cache size */ + +#define ATTR_RO 1 /* read-only */ +#define ATTR_HIDDEN 2 /* hidden */ +#define ATTR_SYS 4 /* system */ +#define ATTR_VOLUME 8 /* volume label */ +#define ATTR_DIR 16 /* directory */ +#define ATTR_ARCH 32 /* archived */ + +#define ATTR_NONE 0 /* no attribute bits */ +#define ATTR_UNUSED (ATTR_VOLUME | ATTR_ARCH | ATTR_SYS | ATTR_HIDDEN) + /* attribute bits that are copied "as is" */ + +#define DELETED_FLAG 0xe5 /* marks file as deleted when in name[0] */ +#define IS_FREE(n) (!*(n) || *(unsigned char *) (n) == DELETED_FLAG || \ + *(unsigned char *) (n) == FD_FILL_BYTE) + +#define MSDOS_VALID_MODE (S_IFREG | S_IFDIR | S_IRWXU | S_IRWXG | S_IRWXO) + /* valid file mode bits */ + +#define MSDOS_SB(s) (&((s)->u.msdos_sb)) +#define MSDOS_I(i) (&((i)->u.msdos_i)) + +#define MSDOS_NAME 11 /* maximum name length */ +#define MSDOS_DOT ". " /* ".", padded to MSDOS_NAME chars */ +#define MSDOS_DOTDOT ".. " /* "..", padded to MSDOS_NAME chars */ + +#define MSDOS_FAT12 4078 /* maximum number of clusters in a 12 bit FAT */ + +/* + * Conversion from and to little-endian byte order. (no-op on i386/i486) + * + * Naming: Ca_b_c, where a: F = from, T = to, b: LE = little-endian, BE = big- + * endian, c: W = word (16 bits), L = longword (32 bits) + */ + +#define CF_LE_W(v) (v) +#define CF_LE_L(v) (v) +#define CT_LE_W(v) (v) +#define CT_LE_L(v) (v) + + +struct msdos_boot_sector { + char ignored[3]; /* Boot strap short or near jump */ + char system_id[8]; /* Name - can be used to special case + partition manager volumes */ + unsigned char sector_size[2];/* bytes per logical sector */ + unsigned char cluster_size; /* sectors/cluster */ + unsigned short reserved; /* reserved sectors */ + unsigned char fats; /* number of FATs */ + unsigned char dir_entries[2];/* root directory entries */ + unsigned char sectors[2]; /* number of sectors */ + unsigned char media; /* media code (unused) */ + unsigned short fat_length; /* sectors/FAT */ + unsigned short secs_track; /* sectors per track */ + unsigned short heads; /* number of heads */ + unsigned long hidden; /* hidden sectors (unused) */ + unsigned long total_sect; /* number of sectors (if sectors == 0) */ +}; + +struct msdos_dir_entry { + char name[8],ext[3]; /* name and extension */ + unsigned char attr; /* attribute bits */ + char unused[10]; + unsigned short time,date,start; /* time, date and first cluster */ + unsigned long size; /* file size (in bytes) */ +}; + +struct fat_cache { + int device; /* device number. 0 means unused. */ + int ino; /* inode number. */ + int file_cluster; /* cluster number in the file. */ + int disk_cluster; /* cluster number on disk. */ + struct fat_cache *next; /* next cache entry */ +}; + +/* Determine whether this FS has kB-aligned data. */ + +#define MSDOS_CAN_BMAP(mib) (!(((mib)->cluster_size & 1) || \ + ((mib)->data_start & 1))) + +/* Convert attribute bits and a mask to the UNIX mode. */ + +#define MSDOS_MKMODE(a,m) (m & (a & ATTR_RO ? S_IRUGO|S_IXUGO : S_IRWXUGO)) + +/* Convert the UNIX mode to MS-DOS attribute bits. */ + +#define MSDOS_MKATTR(m) ((m & S_IWUGO) ? ATTR_NONE : ATTR_RO) + +#ifdef __KERNEL__ + +static inline struct buffer_head *msdos_sread(int dev,int sector) +{ + return bread(dev,sector,SECTOR_SIZE); +} + + +/* misc.c */ + +extern void fs_panic(struct super_block *s,char *msg); +extern int is_binary(char conversion,char *extension); +extern void lock_creation(void); +extern void unlock_creation(void); +extern void lock_fat(struct super_block *sb); +extern void unlock_fat(struct super_block *sb); +extern int msdos_add_cluster(struct inode *inode); +extern int date_dos2unix(unsigned short time,unsigned short date); +extern void date_unix2dos(int unix_date,unsigned short *time, + unsigned short *date); +extern int msdos_get_entry(struct inode *dir,loff_t *pos,struct buffer_head **bh, + struct msdos_dir_entry **de); +extern int msdos_scan(struct inode *dir,char *name,struct buffer_head **res_bh, + struct msdos_dir_entry **res_de,int *ino); +extern int msdos_parent_ino(struct inode *dir,int locked); +extern int msdos_subdirs(struct inode *dir); + +/* fat.c */ + +extern int fat_access(struct super_block *sb,int nr,int new_value); +extern int msdos_smap(struct inode *inode,int sector); +extern int fat_free(struct inode *inode,int skip); +extern void cache_init(void); +void cache_lookup(struct inode *inode,int cluster,int *f_clu,int *d_clu); +void cache_add(struct inode *inode,int f_clu,int d_clu); +void cache_inval_inode(struct inode *inode); +void cache_inval_dev(int device); +int get_cluster(struct inode *inode,int cluster); + +/* namei.c */ + +extern int msdos_lookup(struct inode *dir,const char *name,int len, + struct inode **result); +extern int msdos_create(struct inode *dir,const char *name,int len,int mode, + struct inode **result); +extern int msdos_mkdir(struct inode *dir,const char *name,int len,int mode); +extern int msdos_rmdir(struct inode *dir,const char *name,int len); +extern int msdos_unlink(struct inode *dir,const char *name,int len); +extern int msdos_unlink_umsdos(struct inode *dir,const char *name,int len); +extern int msdos_rename(struct inode *old_dir,const char *old_name,int old_len, + struct inode *new_dir,const char *new_name,int new_len); + +/* inode.c */ + +extern void msdos_put_inode(struct inode *inode); +extern void msdos_put_super(struct super_block *sb); +extern struct super_block *msdos_read_super(struct super_block *s, + void *data,int); +extern void msdos_statfs(struct super_block *sb,struct statfs *buf); +extern int msdos_bmap(struct inode *inode,int block); +extern void msdos_read_inode(struct inode *inode); +extern void msdos_write_inode(struct inode *inode); +extern int msdos_notify_change(struct inode *,struct iattr *); + +/* dir.c */ + +extern struct inode_operations msdos_dir_inode_operations; +extern int msdos_readdir (struct inode *inode, struct file *filp, + struct dirent *dirent, int count); +/* file.c */ + +extern struct inode_operations msdos_file_inode_operations; +extern int msdos_file_read(struct inode *, struct file *, char *, int); +extern int msdos_file_write(struct inode *, struct file *, char *, int); +extern struct inode_operations msdos_file_inode_operations_no_bmap; + +extern void msdos_truncate(struct inode *inode); + +/* mmap.c */ +extern int msdos_mmap(struct inode *, struct file *, struct vm_area_struct *); + +#endif /* __KERNEL__ */ + +#endif diff --git a/include/linux/msdos_fs_i.h b/include/linux/msdos_fs_i.h new file mode 100644 index 000000000..f74cd2ba4 --- /dev/null +++ b/include/linux/msdos_fs_i.h @@ -0,0 +1,42 @@ +#ifndef _MSDOS_FS_I +#define _MSDOS_FS_I + +#ifndef _LINUX_CONFIG_H +#include <linux/config.h> +#endif +#ifndef _LINUX_PIPE_FS_I_H +#include <linux/pipe_fs_i.h> +#endif + +/* + * MS-DOS file system inode data in memory + */ + +struct msdos_inode_info { + /* + UMSDOS manage special file and fifo as normal empty + msdos file. fifo inode processing conflict with msdos + processing. So I insert the pipe_inode_info so the + information does not overlap. This increases the size of + the msdos_inode_info, but the clear winner here is + the ext2_inode_info. So it does not change anything to + the total size of a struct inode. + + I have not put it conditional. With the advent of loadable + file system drivers, it would be very easy to compile + a MsDOS FS driver unaware of UMSDOS and then later to + load a (then incompatible) UMSDOS FS driver. + */ + struct pipe_inode_info reserved; + int i_start; /* first cluster or 0 */ + int i_attrs; /* unused attribute bits */ + int i_busy; /* file is either deleted but still open, or + inconsistent (mkdir) */ + struct inode *i_depend; /* pointer to inode that depends on the + current inode */ + struct inode *i_old; /* pointer to the old inode this inode + depends on */ + int i_binary; /* file contains non-text data */ +}; + +#endif diff --git a/include/linux/msdos_fs_sb.h b/include/linux/msdos_fs_sb.h new file mode 100644 index 000000000..8e5f3041b --- /dev/null +++ b/include/linux/msdos_fs_sb.h @@ -0,0 +1,27 @@ +#ifndef _MSDOS_FS_SB +#define _MSDOS_FS_SB + +/* + * MS-DOS file system in-core superblock data + */ + +struct msdos_sb_info { + unsigned short cluster_size; /* sectors/cluster */ + unsigned char fats,fat_bits; /* number of FATs, FAT bits (12 or 16) */ + unsigned short fat_start,fat_length; /* FAT start & length (sec.) */ + unsigned short dir_start,dir_entries; /* root dir start & entries */ + unsigned short data_start; /* first data sector */ + unsigned long clusters; /* number of clusters */ + uid_t fs_uid; + gid_t fs_gid; + int quiet; /* fake successful chmods and chowns */ + unsigned short fs_umask; + unsigned char name_check; /* r = relaxed, n = normal, s = strict */ + unsigned char conversion; /* b = binary, t = text, a = auto */ + struct wait_queue *fat_wait; + int fat_lock; + int prev_free; /* previously returned free cluster number */ + int free_clusters; /* -1 if undefined */ +}; + +#endif diff --git a/include/linux/msg.h b/include/linux/msg.h new file mode 100644 index 000000000..f31a08038 --- /dev/null +++ b/include/linux/msg.h @@ -0,0 +1,72 @@ +#ifndef _LINUX_MSG_H +#define _LINUX_MSG_H +#include <linux/ipc.h> + +/* msgrcv options */ +#define MSG_NOERROR 010000 /* no error if message is too big */ +#define MSG_EXCEPT 020000 /* recv any msg except of specified type.*/ + +/* one msqid structure for each queue on the system */ +struct msqid_ds { + struct ipc_perm msg_perm; + struct msg *msg_first; /* first message on queue */ + struct msg *msg_last; /* last message in queue */ + time_t msg_stime; /* last msgsnd time */ + time_t msg_rtime; /* last msgrcv time */ + time_t msg_ctime; /* last change time */ + struct wait_queue *wwait; + struct wait_queue *rwait; + ushort msg_cbytes; /* current number of bytes on queue */ + ushort msg_qnum; /* number of messages in queue */ + ushort msg_qbytes; /* max number of bytes on queue */ + ushort msg_lspid; /* pid of last msgsnd */ + ushort msg_lrpid; /* last receive pid */ +}; + +/* message buffer for msgsnd and msgrcv calls */ +struct msgbuf { + long mtype; /* type of message */ + char mtext[1]; /* message text */ +}; + +/* buffer for msgctl calls IPC_INFO, MSG_INFO */ +struct msginfo { + int msgpool; + int msgmap; + int msgmax; + int msgmnb; + int msgmni; + int msgssz; + int msgtql; + ushort msgseg; +}; + +#define MSGMNI 128 /* <= 1K */ /* max # of msg queue identifiers */ +#define MSGMAX 4056 /* <= 4056 */ /* max size of message (bytes) */ +#define MSGMNB 16384 /* ? */ /* default max size of a message queue */ + +/* unused */ +#define MSGPOOL (MSGMNI*MSGMNB/1024) /* size in kilobytes of message pool */ +#define MSGTQL MSGMNB /* number of system message headers */ +#define MSGMAP MSGMNB /* number of entries in message map */ +#define MSGSSZ 16 /* message segment size */ +#define __MSGSEG ((MSGPOOL*1024)/ MSGSSZ) /* max no. of segments */ +#define MSGSEG (__MSGSEG <= 0xffff ? __MSGSEG : 0xffff) + +#ifdef __KERNEL__ + +/* one msg structure for each message */ +struct msg { + struct msg *msg_next; /* next message on queue */ + long msg_type; + char *msg_spot; /* message text address */ + short msg_ts; /* message text size */ +}; + +/* ipcs ctl commands */ +#define MSG_STAT 11 +#define MSG_INFO 12 + +#endif /* __KERNEL__ */ + +#endif /* _LINUX_MSG_H */ diff --git a/include/linux/mtio.h b/include/linux/mtio.h new file mode 100644 index 000000000..cee9ac026 --- /dev/null +++ b/include/linux/mtio.h @@ -0,0 +1,224 @@ +/* $Id: mtio.h,v 1.13 1994/07/19 19:35:52 root Exp $ + * + * linux/mtio.h header file for Linux. Written by H. Bergman + */ + +#ifndef _LINUX_MTIO_H +#define _LINUX_MTIO_H + +#include <linux/ioctl.h> + +/* + * Structures and definitions for mag tape io control commands + */ + +/* structure for MTIOCTOP - mag tape op command */ +struct mtop { + short mt_op; /* operations defined below */ + int mt_count; /* how many of them */ +}; + +/* Magnetic Tape operations [Not all operations supported by all drivers]: */ +#define MTRESET 0 /* +reset drive in case of problems */ +#define MTFSF 1 /* forward space over FileMark, + * position at first record of next file + */ +#define MTBSF 2 /* backward space FileMark (position before FM) */ +#define MTFSR 3 /* forward space record */ +#define MTBSR 4 /* backward space record */ +#define MTWEOF 5 /* write an end-of-file record (mark) */ +#define MTREW 6 /* rewind */ +#define MTOFFL 7 /* rewind and put the drive offline (eject?) */ +#define MTNOP 8 /* no op, set status only (read with MTIOCGET) */ +#define MTRETEN 9 /* retension tape */ +#define MTBSFM 10 /* +backward space FileMark, position at FM */ +#define MTFSFM 11 /* +forward space FileMark, position at FM */ +#define MTEOM 12 /* goto end of recorded media (for appending files). + * MTEOM positions after the last FM, ready for + * appending another file. + */ +#define MTERASE 13 /* erase tape -- be careful! */ + +#define MTRAS1 14 /* run self test 1 (nondestructive) */ +#define MTRAS2 15 /* run self test 2 (destructive) */ +#define MTRAS3 16 /* reserved for self test 3 */ + + +#define MTSETBLK 20 /* set block length (SCSI) */ +#define MTSETDENSITY 21 /* set tape density (SCSI) */ +#define MTSEEK 22 /* seek to block (Tandberg, etc.) */ +#define MTTELL 23 /* tell block (Tandberg, etc.) */ +#define MTSETDRVBUFFER 24 /* set the drive buffering according to SCSI-2 */ + /* ordinary buffered operation with code 1 */ +#define MTFSS 25 /* space forward over setmarks */ +#define MTBSS 26 /* space backward over setmarks */ +#define MTWSM 27 /* write setmarks */ + +/* structure for MTIOCGET - mag tape get status command */ + +struct mtget { + long mt_type; /* type of magtape device */ + long mt_resid; /* residual count: (not sure) + * number of bytes ignored, or + * number of files not skipped, or + * number of records not skipped. + */ + /* the following registers are device dependent */ + long mt_dsreg; /* status register */ + long mt_gstat; /* generic (device independent) status */ + long mt_erreg; /* error register */ + /* The next two fields are not always used */ + daddr_t mt_fileno; /* number of current file on tape */ + daddr_t mt_blkno; /* current block number */ +}; + + + +/* + * Constants for mt_type. Not all of these are supported, + * and these are not all of the ones that are supported. + */ +#define MT_ISUNKNOWN 0x01 +#define MT_ISQIC02 0x02 /* Generic QIC-02 tape streamer */ +#define MT_ISWT5150 0x03 /* Wangtek 5150EQ, QIC-150, QIC-02 */ +#define MT_ISARCHIVE_5945L2 0x04 /* Archive 5945L-2, QIC-24, QIC-02? */ +#define MT_ISCMSJ500 0x05 /* CMS Jumbo 500 (QIC-02?) */ +#define MT_ISTDC3610 0x06 /* Tandberg 6310, QIC-24 */ +#define MT_ISARCHIVE_VP60I 0x07 /* Archive VP60i, QIC-02 */ +#define MT_ISARCHIVE_2150L 0x08 /* Archive Viper 2150L */ +#define MT_ISARCHIVE_2060L 0x09 /* Archive Viper 2060L */ +#define MT_ISARCHIVESC499 0x0A /* Archive SC-499 QIC-36 controller */ +#define MT_ISQIC02_ALL_FEATURES 0x0F /* Generic QIC-02 with all features */ +#define MT_ISWT5099EEN24 0x11 /* Wangtek 5099-een24, 60MB, QIC-24 */ +#define MT_ISTEAC_MT2ST 0x12 /* Teac MT-2ST 155mb drive, Teac DC-1 card (Wangtek type) */ +#define MT_ISEVEREX_FT40A 0x32 /* Everex FT40A (QIC-40) */ +#define MT_ISDDS1 0x51 /* DDS device without partitions */ +#define MT_ISDDS2 0x52 /* DDS device with partitions */ +#define MT_ISSCSI1 0x71 /* Generic ANSI SCSI-1 tape unit */ +#define MT_ISSCSI2 0x72 /* Generic ANSI SCSI-2 tape unit */ + +/* QIC-40/QIC-80 ftape supported drives. + * 20bit vendor ID + 0x800000 + */ +#define MT_ISFTAPE_UNKNOWN 0x800000 +#define MT_ISCMSDJ10_DJ20 0x800047 +#define MT_ISCMSDJ10_DJ20_NEW 0x8011c4 +#define MT_ISARCHIVE_5580I 0x800005 +#define MT_ISARCHIVE_XL9250I 0x80014a +#define MT_ISARCHIVE_31250Q 0x800146 +#define MT_ISINSIGHT_80 0x810005 +#define MT_ISCONNER_C250MQT 0x80014c +#define MT_ISWANGTEK_2040F 0x8001c1 +#define MT_ISWANGTEK_2080F 0x8001c8 +#define MT_ISIOMEGA_250 0x808880 +#define MT_ISSUMMIT_SE150 0x800180 +#define MT_ISSUMMIT_SE250 0x800181 +#define MT_ISESCOM_IDTBU120E 0x800140 + +struct mt_tape_info { + long t_type; /* device type id (mt_type) */ + char *t_name; /* descriptive name */ +}; + +#define MT_TAPE_INFO { \ + {MT_ISUNKNOWN, "Unknown type of tape device"}, \ + {MT_ISQIC02, "Generic QIC-02 tape streamer"}, \ + {MT_ISWT5150, "Wangtek 5150, QIC-150"}, \ + {MT_ISARCHIVE_5945L2, "Archive 5945L-2"}, \ + {MT_ISCMSJ500, "CMS Jumbo 500"}, \ + {MT_ISTDC3610, "Tandberg TDC 3610, QIC-24"}, \ + {MT_ISARCHIVE_VP60I, "Archive VP60i, QIC-02"}, \ + {MT_ISARCHIVE_2150L, "Archive Viper 2150L"}, \ + {MT_ISARCHIVE_2060L, "Archive Viper 2060L"}, \ + {MT_ISARCHIVESC499, "Archive SC-499 QIC-36 controller"}, \ + {MT_ISQIC02_ALL_FEATURES, "Generic QIC-02 tape, all features"}, \ + {MT_ISWT5099EEN24, "Wangtek 5099-een24, 60MB"}, \ + {MT_ISTEAC_MT2ST, "Teac MT-2ST 155mb data cassette drive"}, \ + {MT_ISEVEREX_FT40A, "Everex FT40A, QIC-40"}, \ + {MT_ISSCSI1, "Generic SCSI-1 tape"}, \ + {MT_ISSCSI2, "Generic SCSI-2 tape"}, \ + {MT_ISFTAPE_UNKNOWN, "Unknown floppy interface tape drive"},\ + {MT_ISCMSDJ10_DJ20, "Colorado DJ-10/DJ-20"},\ + {MT_ISCMSDJ10_DJ20_NEW, "Colorado DJ-10/DJ-20 (new)"},\ + {MT_ISARCHIVE_5580I, "Archive 5580i"},\ + {MT_ISARCHIVE_XL9250I, "Archive XL9250i [Conner/Escom]"},\ + {MT_ISARCHIVE_31250Q, "Escom/Archive 31250Q"},\ + {MT_ISINSIGHT_80, "Insight 80 Mb"},\ + {MT_ISCONNER_C250MQT, "Conner C250MQT"},\ + {MT_ISWANGTEK_2040F, "Wangtek 3040F"},\ + {MT_ISWANGTEK_2080F, "Wangtek 3080F"},\ + {MT_ISIOMEGA_250, "Iomega 250"},\ + {MT_ISSUMMIT_SE150, "Summit SE 150"},\ + {MT_ISSUMMIT_SE250, "Summit SE 250/Mountain FS8000"},\ + {MT_ISESCOM_IDTBU120E, "Identity IDTBU120E, Escom?"},\ + {0, NULL} \ +} + + +/* structure for MTIOCPOS - mag tape get position command */ + +struct mtpos { + long mt_blkno; /* current block number */ +}; + + +/* mag tape io control commands */ +#define MTIOCTOP _IOW('m', 1, struct mtop) /* do a mag tape op */ +#define MTIOCGET _IOR('m', 2, struct mtget) /* get tape status */ +#define MTIOCPOS _IOR('m', 3, struct mtpos) /* get tape position */ + +/* The next two are used by the QIC-02 driver for runtime reconfiguration. + * See tpqic02.h for struct mtconfiginfo. + */ +#define MTIOCGETCONFIG _IOR('m', 4, struct mtconfiginfo) /* get tape config */ +#define MTIOCSETCONFIG _IOW('m', 5, struct mtconfiginfo) /* set tape config */ + + +/* Generic Mag Tape (device independent) status macros for examining + * mt_gstat -- HP-UX compatible. + * There is room for more generic status bits here, but I don't + * know which of them are reserved. At least three or so should + * be added to make this really useful. + */ +#define GMT_EOF(x) ((x) & 0x80000000) +#define GMT_BOT(x) ((x) & 0x40000000) +#define GMT_EOT(x) ((x) & 0x20000000) +#define GMT_SM(x) ((x) & 0x10000000) /* DDS setmark */ +#define GMT_EOD(x) ((x) & 0x08000000) /* DDS EOD */ +#define GMT_WR_PROT(x) ((x) & 0x04000000) +/* #define GMT_ ? ((x) & 0x02000000) */ +#define GMT_ONLINE(x) ((x) & 0x01000000) +#define GMT_D_6250(x) ((x) & 0x00800000) +#define GMT_D_1600(x) ((x) & 0x00400000) +#define GMT_D_800(x) ((x) & 0x00200000) +/* #define GMT_ ? ((x) & 0x00100000) */ +/* #define GMT_ ? ((x) & 0x00080000) */ +#define GMT_DR_OPEN(x) ((x) & 0x00040000) /* door open (no tape) */ +/* #define GMT_ ? ((x) & 0x00020000) */ +#define GMT_IM_REP_EN(x) ((x) & 0x00010000) /* immediate report mode */ +/* 16 generic status bits unused */ + +/* DDS drives have 'setmarks', sort of like filemarks but used to group + * files, rather than blocks. Not used. Not supported. + * I think DDS drives are DAT drives. + */ + +/* SCSI-tape specific definitions */ +#define MT_ST_BLKSIZE_SHIFT 0 +#define MT_ST_BLKSIZE_MASK 0xffffff +#define MT_ST_DENSITY_SHIFT 24 +#define MT_ST_DENSITY_MASK 0xff000000 + +#define MT_ST_SOFTERR_SHIFT 0 +#define MT_ST_SOFTERR_MASK 0xffff + +#define MT_ST_OPTIONS 0xf0000000 +#define MT_ST_BOOLEANS 0x10000000 +#define MT_ST_WRITE_THRESHOLD 0x20000000 +#define MT_ST_BUFFER_WRITES 0x1 +#define MT_ST_ASYNC_WRITES 0x2 +#define MT_ST_READ_AHEAD 0x4 +#define MT_ST_DEBUGGING 0x8 +#define MT_ST_TWO_FM 0x10 + +#endif /* _LINUX_MTIO_H */ diff --git a/include/linux/net.h b/include/linux/net.h new file mode 100644 index 000000000..a19f619cb --- /dev/null +++ b/include/linux/net.h @@ -0,0 +1,137 @@ +/* + * NET An implementation of the SOCKET network access protocol. + * This is the master header file for the Linux NET layer, + * or, in plain English: the networking handling part of the + * kernel. + * + * Version: @(#)net.h 1.0.3 05/25/93 + * + * Authors: Orest Zborowski, <obz@Kodak.COM> + * Ross Biro, <bir7@leland.Stanford.Edu> + * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> + * + * 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. + */ +#ifndef _LINUX_NET_H +#define _LINUX_NET_H + + +#include <linux/wait.h> +#include <linux/socket.h> + + +#define NSOCKETS 128 /* should be dynamic, later... */ +#define NPROTO 16 /* should be enough for now.. */ + + +#define SYS_SOCKET 1 /* sys_socket(2) */ +#define SYS_BIND 2 /* sys_bind(2) */ +#define SYS_CONNECT 3 /* sys_connect(2) */ +#define SYS_LISTEN 4 /* sys_listen(2) */ +#define SYS_ACCEPT 5 /* sys_accept(2) */ +#define SYS_GETSOCKNAME 6 /* sys_getsockname(2) */ +#define SYS_GETPEERNAME 7 /* sys_getpeername(2) */ +#define SYS_SOCKETPAIR 8 /* sys_socketpair(2) */ +#define SYS_SEND 9 /* sys_send(2) */ +#define SYS_RECV 10 /* sys_recv(2) */ +#define SYS_SENDTO 11 /* sys_sendto(2) */ +#define SYS_RECVFROM 12 /* sys_recvfrom(2) */ +#define SYS_SHUTDOWN 13 /* sys_shutdown(2) */ +#define SYS_SETSOCKOPT 14 /* sys_setsockopt(2) */ +#define SYS_GETSOCKOPT 15 /* sys_getsockopt(2) */ + + +typedef enum { + SS_FREE = 0, /* not allocated */ + SS_UNCONNECTED, /* unconnected to any socket */ + SS_CONNECTING, /* in process of connecting */ + SS_CONNECTED, /* connected to socket */ + SS_DISCONNECTING /* in process of disconnecting */ +} socket_state; + +#define SO_ACCEPTCON (1<<16) /* performed a listen */ + +#ifdef __KERNEL__ +/* + * Internal representation of a socket. not all the fields are used by + * all configurations: + * + * server client + * conn client connected to server connected to + * iconn list of clients -unused- + * awaiting connections + * wait sleep for clients, sleep for connection, + * sleep for i/o sleep for i/o + */ +struct socket { + short type; /* SOCK_STREAM, ... */ + socket_state state; + long flags; + struct proto_ops *ops; /* protocols do most everything */ + void *data; /* protocol data */ + struct socket *conn; /* server socket connected to */ + struct socket *iconn; /* incomplete client conn.s */ + struct socket *next; + struct wait_queue **wait; /* ptr to place to wait on */ + struct inode *inode; + struct fasync_struct *fasync_list; /* Asynchronous wake up list */ +}; + +#define SOCK_INODE(S) ((S)->inode) + +struct proto_ops { + int family; + + int (*create) (struct socket *sock, int protocol); + int (*dup) (struct socket *newsock, struct socket *oldsock); + int (*release) (struct socket *sock, struct socket *peer); + int (*bind) (struct socket *sock, struct sockaddr *umyaddr, + int sockaddr_len); + int (*connect) (struct socket *sock, struct sockaddr *uservaddr, + int sockaddr_len, int flags); + int (*socketpair) (struct socket *sock1, struct socket *sock2); + int (*accept) (struct socket *sock, struct socket *newsock, + int flags); + int (*getname) (struct socket *sock, struct sockaddr *uaddr, + int *usockaddr_len, int peer); + int (*read) (struct socket *sock, char *ubuf, int size, + int nonblock); + int (*write) (struct socket *sock, char *ubuf, int size, + int nonblock); + int (*select) (struct socket *sock, int sel_type, + select_table *wait); + int (*ioctl) (struct socket *sock, unsigned int cmd, + unsigned long arg); + int (*listen) (struct socket *sock, int len); + int (*send) (struct socket *sock, void *buff, int len, int nonblock, + unsigned flags); + int (*recv) (struct socket *sock, void *buff, int len, int nonblock, + unsigned flags); + int (*sendto) (struct socket *sock, void *buff, int len, int nonblock, + unsigned flags, struct sockaddr *, int addr_len); + int (*recvfrom) (struct socket *sock, void *buff, int len, int nonblock, + unsigned flags, struct sockaddr *, int *addr_len); + int (*shutdown) (struct socket *sock, int flags); + int (*setsockopt) (struct socket *sock, int level, int optname, + char *optval, int optlen); + int (*getsockopt) (struct socket *sock, int level, int optname, + char *optval, int *optlen); + int (*fcntl) (struct socket *sock, unsigned int cmd, + unsigned long arg); +}; + +struct net_proto { + char *name; /* Protocol name */ + void (*init_func)(struct net_proto *); /* Bootstrap */ +}; + +extern int sock_awaitconn(struct socket *mysock, struct socket *servsock); +extern int sock_wake_async(struct socket *sock); +extern int sock_register(int family, struct proto_ops *ops); +extern int sock_unregister(int family); + +#endif /* __KERNEL__ */ +#endif /* _LINUX_NET_H */ diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h new file mode 100644 index 000000000..0c66a3e5e --- /dev/null +++ b/include/linux/netdevice.h @@ -0,0 +1,207 @@ +/* + * INET An implementation of the TCP/IP protocol suite for the LINUX + * operating system. INET is implemented using the BSD Socket + * interface as the means of communication with the user level. + * + * Definitions for the Interfaces handler. + * + * Version: @(#)dev.h 1.0.10 08/12/93 + * + * Authors: Ross Biro, <bir7@leland.Stanford.Edu> + * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> + * Corey Minyard <wf-rch!minyard@relay.EU.net> + * Donald J. Becker, <becker@super.org> + * Alan Cox, <A.Cox@swansea.ac.uk> + * Bjorn Ekwall. <bj0rn@blox.se> + * + * 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. + * + * Moved to /usr/include/linux for NET3 + */ +#ifndef _LINUX_NETDEVICE_H +#define _LINUX_NETDEVICE_H + +#include <linux/if.h> +#include <linux/if_ether.h> +#include <linux/skbuff.h> + +/* for future expansion when we will have different priorities. */ +#define DEV_NUMBUFFS 3 +#define MAX_ADDR_LEN 7 +#define MAX_HEADER 18 + +#define IS_MYADDR 1 /* address is (one of) our own */ +#define IS_LOOPBACK 2 /* address is for LOOPBACK */ +#define IS_BROADCAST 3 /* address is a valid broadcast */ +#define IS_INVBCAST 4 /* Wrong netmask bcast not for us (unused)*/ +#define IS_MULTICAST 5 /* Multicast IP address */ + +/* + * The DEVICE structure. + * Actually, this whole structure is a big mistake. It mixes I/O + * data with strictly "high-level" data, and it has to know about + * almost every data structure used in the INET module. + */ +struct device +{ + + /* + * This is the first field of the "visible" part of this structure + * (i.e. as seen by users in the "Space.c" file). It is the name + * the interface. + */ + char *name; + + /* I/O specific fields - FIXME: Merge these and struct ifmap into one */ + unsigned long rmem_end; /* shmem "recv" end */ + unsigned long rmem_start; /* shmem "recv" start */ + unsigned long mem_end; /* sahared mem end */ + unsigned long mem_start; /* shared mem start */ + unsigned short base_addr; /* device I/O address */ + unsigned char irq; /* device IRQ number */ + + /* Low-level status flags. */ + volatile unsigned char start, /* start an operation */ + tbusy, /* transmitter busy */ + interrupt; /* interrupt arrived */ + + struct device *next; + + /* The device initialization function. Called only once. */ + int (*init)(struct device *dev); + + /* Some hardware also needs these fields, but they are not part of the + usual set specified in Space.c. */ + unsigned char if_port; /* Selectable AUI, TP,..*/ + unsigned char dma; /* DMA channel */ + + struct enet_statistics* (*get_stats)(struct device *dev); + + /* + * This marks the end of the "visible" part of the structure. All + * fields hereafter are internal to the system, and may change at + * will (read: may be cleaned up at will). + */ + + /* These may be needed for future network-power-down code. */ + unsigned long trans_start; /* Time (in jiffies) of last Tx */ + unsigned long last_rx; /* Time of last Rx */ + + unsigned short flags; /* interface flags (a la BSD) */ + unsigned short family; /* address family ID (AF_INET) */ + unsigned short metric; /* routing metric (not used) */ + unsigned short mtu; /* interface MTU value */ + unsigned short type; /* interface hardware type */ + unsigned short hard_header_len; /* hardware hdr length */ + void *priv; /* pointer to private data */ + + /* Interface address info. */ + unsigned char broadcast[MAX_ADDR_LEN]; /* hw bcast add */ + unsigned char dev_addr[MAX_ADDR_LEN]; /* hw address */ + unsigned char addr_len; /* hardware address length */ + unsigned long pa_addr; /* protocol address */ + unsigned long pa_brdaddr; /* protocol broadcast addr */ + unsigned long pa_dstaddr; /* protocol P-P other side addr */ + unsigned long pa_mask; /* protocol netmask */ + unsigned short pa_alen; /* protocol address length */ + + /* For load balancing driver pair support */ + + unsigned long pkt_queue; /* Packets queued */ + struct device *slave; /* Slave device */ + + + /* Pointer to the interface buffers. */ + struct sk_buff_head buffs[DEV_NUMBUFFS]; + + /* Pointers to interface service routines. */ + int (*open)(struct device *dev); + int (*stop)(struct device *dev); + int (*hard_start_xmit) (struct sk_buff *skb, + struct device *dev); + int (*hard_header) (unsigned char *buff, + struct device *dev, + unsigned short type, + void *daddr, + void *saddr, + unsigned len, + struct sk_buff *skb); + int (*rebuild_header)(void *eth, struct device *dev, + unsigned long raddr, struct sk_buff *skb); + unsigned short (*type_trans) (struct sk_buff *skb, + struct device *dev); +#define HAVE_MULTICAST + void (*set_multicast_list)(struct device *dev, + int num_addrs, void *addrs); +#define HAVE_SET_MAC_ADDR + int (*set_mac_address)(struct device *dev, void *addr); +#define HAVE_PRIVATE_IOCTL + int (*do_ioctl)(struct device *dev, struct ifreq *ifr, int cmd); +#define HAVE_SET_CONFIG + int (*set_config)(struct device *dev, struct ifmap *map); + +}; + + +struct packet_type { + unsigned short type; /* This is really htons(ether_type). */ + unsigned short copy:1; + int (*func) (struct sk_buff *, struct device *, + struct packet_type *); + void *data; + struct packet_type *next; +}; + + +#ifdef __KERNEL__ + +/* Used by dev_rint */ +#define IN_SKBUFF 1 + +extern volatile char in_bh; + +extern struct device *dev_base; +extern struct packet_type *ptype_base; + + +extern int ip_addr_match(unsigned long addr1, unsigned long addr2); +extern int ip_chk_addr(unsigned long addr); +extern struct device *ip_dev_check(unsigned long daddr); +extern unsigned long ip_my_addr(void); +extern unsigned long ip_get_mask(unsigned long addr); + +extern void dev_add_pack(struct packet_type *pt); +extern void dev_remove_pack(struct packet_type *pt); +extern struct device *dev_get(char *name); +extern int dev_open(struct device *dev); +extern int dev_close(struct device *dev); +extern void dev_queue_xmit(struct sk_buff *skb, struct device *dev, + int pri); +#define HAVE_NETIF_RX 1 +extern void netif_rx(struct sk_buff *skb); +/* The old interface to netif_rx(). */ +extern int dev_rint(unsigned char *buff, long len, int flags, + struct device * dev); +extern void dev_transmit(void); +extern int in_net_bh(void); +extern void net_bh(void *tmp); +extern void dev_tint(struct device *dev); +extern int dev_get_info(char *buffer, char **start, off_t offset, int length); +extern int dev_ioctl(unsigned int cmd, void *); + +extern void dev_init(void); + +/* These functions live elsewhere (drivers/net/net_init.c, but related) */ + +extern void ether_setup(struct device *dev); +extern int ether_config(struct device *dev, struct ifmap *map); +/* Support for loadable net-drivers */ +extern int register_netdev(struct device *dev); +extern void unregister_netdev(struct device *dev); + +#endif /* __KERNEL__ */ + +#endif /* _LINUX_DEV_H */ diff --git a/include/linux/nfs.h b/include/linux/nfs.h new file mode 100644 index 000000000..3cfbd1d12 --- /dev/null +++ b/include/linux/nfs.h @@ -0,0 +1,169 @@ +#ifndef _LINUX_NFS_H +#define _LINUX_NFS_H + +#define NFS_PORT 2049 +#define NFS_MAXDATA 8192 +#define NFS_MAXPATHLEN 1024 +#define NFS_MAXNAMLEN 255 +#define NFS_MAXGROUPS 16 +#define NFS_FHSIZE 32 +#define NFS_COOKIESIZE 4 +#define NFS_FIFO_DEV (-1) +#define NFSMODE_FMT 0170000 +#define NFSMODE_DIR 0040000 +#define NFSMODE_CHR 0020000 +#define NFSMODE_BLK 0060000 +#define NFSMODE_REG 0100000 +#define NFSMODE_LNK 0120000 +#define NFSMODE_SOCK 0140000 +#define NFSMODE_FIFO 0010000 + +#ifdef __KERNEL__ /* user programs should get these from the rpc header files */ + +#define RPC_VERSION 2 + +enum rpc_auth_flavor { + RPC_AUTH_NULL = 0, + RPC_AUTH_UNIX = 1, + RPC_AUTH_SHORT = 2 +}; + +enum rpc_msg_type { + RPC_CALL = 0, + RPC_REPLY = 1 +}; + +enum rpc_reply_stat { + RPC_MSG_ACCEPTED = 0, + RPC_MSG_DENIED = 1 +}; + +enum rpc_accept_stat { + RPC_SUCCESS = 0, + RPC_PROG_UNAVAIL = 1, + RPC_PROG_MISMATCH = 2, + RPC_PROC_UNAVAIL = 3, + RPC_GARBAGE_ARGS = 4 +}; + +enum rpc_reject_stat { + RPC_MISMATCH = 0, + RPC_AUTH_ERROR = 1 +}; + +enum rpc_auth_stat { + RPC_AUTH_BADCRED = 1, + RPC_AUTH_REJECTEDCRED = 2, + RPC_AUTH_BADVERF = 3, + RPC_AUTH_REJECTEDVERF = 4, + RPC_AUTH_TOOWEAK = 5 +}; + +#endif /* __KERNEL__ */ + +enum nfs_stat { + NFS_OK = 0, + NFSERR_PERM = 1, + NFSERR_NOENT = 2, + NFSERR_IO = 5, + NFSERR_NXIO = 6, + NFSERR_ACCES = 13, + NFSERR_EXIST = 17, + NFSERR_NODEV = 19, + NFSERR_NOTDIR = 20, + NFSERR_ISDIR = 21, + NFSERR_INVAL = 22, /* that Sun forgot */ + NFSERR_FBIG = 27, + NFSERR_NOSPC = 28, + NFSERR_ROFS = 30, + NFSERR_NAMETOOLONG = 63, + NFSERR_NOTEMPTY = 66, + NFSERR_DQUOT = 69, + NFSERR_STALE = 70, + NFSERR_WFLUSH = 99 +}; + +enum nfs_ftype { + NFNON = 0, + NFREG = 1, + NFDIR = 2, + NFBLK = 3, + NFCHR = 4, + NFLNK = 5, + NFSOCK = 6, + NFBAD = 7, + NFFIFO = 8 +}; + +#define NFS_PROGRAM 100003 +#define NFS_VERSION 2 +#define NFSPROC_NULL 0 +#define NFSPROC_GETATTR 1 +#define NFSPROC_SETATTR 2 +#define NFSPROC_ROOT 3 +#define NFSPROC_LOOKUP 4 +#define NFSPROC_READLINK 5 +#define NFSPROC_READ 6 +#define NFSPROC_WRITECACHE 7 +#define NFSPROC_WRITE 8 +#define NFSPROC_CREATE 9 +#define NFSPROC_REMOVE 10 +#define NFSPROC_RENAME 11 +#define NFSPROC_LINK 12 +#define NFSPROC_SYMLINK 13 +#define NFSPROC_MKDIR 14 +#define NFSPROC_RMDIR 15 +#define NFSPROC_READDIR 16 +#define NFSPROC_STATFS 17 + +struct nfs_fh { + char data[NFS_FHSIZE]; +}; + +struct nfs_time { + u_int seconds; + u_int useconds; +}; + +struct nfs_fattr { + enum nfs_ftype type; + u_int mode; + u_int nlink; + u_int uid; + u_int gid; + u_int size; + u_int blocksize; + u_int rdev; + u_int blocks; + u_int fsid; + u_int fileid; + struct nfs_time atime; + struct nfs_time mtime; + struct nfs_time ctime; +}; + +struct nfs_sattr { + u_int mode; + u_int uid; + u_int gid; + u_int size; + struct nfs_time atime; + struct nfs_time mtime; +}; + +struct nfs_entry { + u_int fileid; + char *name; + int cookie; + int eof; +}; + +struct nfs_fsinfo { + u_int tsize; + u_int bsize; + u_int blocks; + u_int bfree; + u_int bavail; +}; + +#endif diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h new file mode 100644 index 000000000..66116a4e7 --- /dev/null +++ b/include/linux/nfs_fs.h @@ -0,0 +1,120 @@ +#ifndef _LINUX_NFS_FS_H +#define _LINUX_NFS_FS_H + +/* + * linux/include/linux/nfs_fs.h + * + * Copyright (C) 1992 Rick Sladkey + * + * OS-specific nfs filesystem definitions and declarations + */ + +#include <linux/nfs.h> + +#include <linux/in.h> +#include <linux/nfs_mount.h> + +/* + * The readdir cache size controls how many directory entries are cached. + * Its size is limited by the number of nfs_entry structures that can fit + * in one 4096-byte page, currently 256. + */ + +#define NFS_READDIR_CACHE_SIZE 64 + +#define NFS_MAX_FILE_IO_BUFFER_SIZE 16384 +#define NFS_DEF_FILE_IO_BUFFER_SIZE 1024 + +/* + * The upper limit on timeouts for the exponential backoff algorithm + * in tenths of a second. + */ + +#define NFS_MAX_RPC_TIMEOUT 600 + +/* + * Size of the lookup cache in units of number of entries cached. + * It is better not to make this too large although the optimum + * depends on a usage and environment. + */ + +#define NFS_LOOKUP_CACHE_SIZE 64 + +#define NFS_SUPER_MAGIC 0x6969 + +#define NFS_SERVER(inode) (&(inode)->i_sb->u.nfs_sb.s_server) +#define NFS_FH(inode) (&(inode)->u.nfs_i.fhandle) + +#ifdef __KERNEL__ + +/* linux/fs/nfs/proc.c */ + +extern int nfs_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle, + struct nfs_fattr *fattr); +extern int nfs_proc_setattr(struct nfs_server *server, struct nfs_fh *fhandle, + struct nfs_sattr *sattr, struct nfs_fattr *fattr); +extern int nfs_proc_lookup(struct nfs_server *server, struct nfs_fh *dir, + const char *name, struct nfs_fh *fhandle, + struct nfs_fattr *fattr); +extern int nfs_proc_readlink(struct nfs_server *server, struct nfs_fh *fhandle, + int **p0, char **string, unsigned int *len, + unsigned int maxlen); +extern int nfs_proc_read(struct nfs_server *server, struct nfs_fh *fhandle, + int offset, int count, char *data, + struct nfs_fattr *fattr, int fs); +extern int nfs_proc_write(struct nfs_server *server, struct nfs_fh *fhandle, + int offset, int count, char *data, + struct nfs_fattr *fattr); +extern int nfs_proc_create(struct nfs_server *server, struct nfs_fh *dir, + const char *name, struct nfs_sattr *sattr, + struct nfs_fh *fhandle, struct nfs_fattr *fattr); +extern int nfs_proc_remove(struct nfs_server *server, struct nfs_fh *dir, + const char *name); +extern int nfs_proc_rename(struct nfs_server *server, + struct nfs_fh *old_dir, const char *old_name, + struct nfs_fh *new_dir, const char *new_name); +extern int nfs_proc_link(struct nfs_server *server, struct nfs_fh *fhandle, + struct nfs_fh *dir, const char *name); +extern int nfs_proc_symlink(struct nfs_server *server, struct nfs_fh *dir, + const char *name, const char *path, struct nfs_sattr *sattr); +extern int nfs_proc_mkdir(struct nfs_server *server, struct nfs_fh *dir, + const char *name, struct nfs_sattr *sattr, + struct nfs_fh *fhandle, struct nfs_fattr *fattr); +extern int nfs_proc_rmdir(struct nfs_server *server, struct nfs_fh *dir, + const char *name); +extern int nfs_proc_readdir(struct nfs_server *server, struct nfs_fh *fhandle, + int cookie, int count, struct nfs_entry *entry); +extern int nfs_proc_statfs(struct nfs_server *server, struct nfs_fh *fhandle, + struct nfs_fsinfo *res); + +/* linux/fs/nfs/sock.c */ + +extern int nfs_rpc_call(struct nfs_server *server, int *start, int *end, int size); + +/* linux/fs/nfs/inode.c */ + +extern struct super_block *nfs_read_super(struct super_block *sb, + void *data,int); +extern struct inode *nfs_fhget(struct super_block *sb, struct nfs_fh *fhandle, + struct nfs_fattr *fattr); +extern void nfs_refresh_inode(struct inode *inode, struct nfs_fattr *fattr); + +/* linux/fs/nfs/file.c */ + +extern struct inode_operations nfs_file_inode_operations; + +/* linux/fs/nfs/dir.c */ + +extern struct inode_operations nfs_dir_inode_operations; + +/* linux/fs/nfs/symlink.c */ + +extern struct inode_operations nfs_symlink_inode_operations; + +/* linux/fs/nfs/mmap.c */ + +extern int nfs_mmap(struct inode * inode, struct file * file, struct vm_area_struct * vma); + +#endif /* __KERNEL__ */ + +#endif diff --git a/include/linux/nfs_fs_i.h b/include/linux/nfs_fs_i.h new file mode 100644 index 000000000..d4652865b --- /dev/null +++ b/include/linux/nfs_fs_i.h @@ -0,0 +1,13 @@ +#ifndef _NFS_FS_I +#define _NFS_FS_I + +#include <linux/nfs.h> + +/* + * nfs fs inode data in memory + */ +struct nfs_inode_info { + struct nfs_fh fhandle; +}; + +#endif diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h new file mode 100644 index 000000000..25db9e83f --- /dev/null +++ b/include/linux/nfs_fs_sb.h @@ -0,0 +1,31 @@ +#ifndef _NFS_FS_SB +#define _NFS_FS_SB + +#include <linux/nfs.h> + +struct nfs_server { + struct file *file; + int lock; + struct wait_queue *wait; + int flags; + int rsize; + int wsize; + int timeo; + int retrans; + int acregmin; + int acregmax; + int acdirmin; + int acdirmax; + char hostname[256]; +}; + +/* + * nfs super-block data in memory + */ + +struct nfs_sb_info { + struct nfs_server s_server; + struct nfs_fh s_root; +}; + +#endif diff --git a/include/linux/nfs_mount.h b/include/linux/nfs_mount.h new file mode 100644 index 000000000..beb5f1dd8 --- /dev/null +++ b/include/linux/nfs_mount.h @@ -0,0 +1,48 @@ +#ifndef _LINUX_NFS_MOUNT_H +#define _LINUX_NFS_MOUNT_H + +/* + * linux/include/linux/nfs_mount.h + * + * Copyright (C) 1992 Rick Sladkey + * + * structure passed from user-space to kernel-space during an nfs mount + */ + +/* + * WARNING! Do not delete or change the order of these fields. If + * a new field is required then add it to the end. The version field + * tracks which fields are present. This will ensure some measure of + * mount-to-kernel version compatibility. Some of these aren't used yet + * but here they are anyway. + */ + +#define NFS_MOUNT_VERSION 1 /* current version */ + +struct nfs_mount_data { + int version; /* 1 */ + int fd; /* 1 */ + struct nfs_fh root; /* 1 */ + int flags; /* 1 */ + int rsize; /* 1 */ + int wsize; /* 1 */ + int timeo; /* 1 */ + int retrans; /* 1 */ + int acregmin; /* 1 */ + int acregmax; /* 1 */ + int acdirmin; /* 1 */ + int acdirmax; /* 1 */ + struct sockaddr_in addr; /* 1 */ + char hostname[256]; /* 1 */ +}; + +/* bits in the flags field */ + +#define NFS_MOUNT_SOFT 0x0001 /* 1 */ +#define NFS_MOUNT_INTR 0x0002 /* 1 */ +#define NFS_MOUNT_SECURE 0x0004 /* 1 */ +#define NFS_MOUNT_POSIX 0x0008 /* 1 */ +#define NFS_MOUNT_NOCTO 0x0010 /* 1 */ +#define NFS_MOUNT_NOAC 0x0020 /* 1 */ + +#endif diff --git a/include/linux/param.h b/include/linux/param.h new file mode 100644 index 000000000..c634b1ea3 --- /dev/null +++ b/include/linux/param.h @@ -0,0 +1,20 @@ +#ifndef _LINUX_PARAM_H +#define _LINUX_PARAM_H + +#ifndef HZ +#define HZ 100 +#endif + +#define EXEC_PAGESIZE 4096 + +#ifndef NGROUPS +#define NGROUPS 32 +#endif + +#ifndef NOGROUP +#define NOGROUP (-1) +#endif + +#define MAXHOSTNAMELEN 64 /* max length of hostname */ + +#endif diff --git a/include/linux/pci.h b/include/linux/pci.h new file mode 100644 index 000000000..9b112ab80 --- /dev/null +++ b/include/linux/pci.h @@ -0,0 +1,159 @@ +/* + * PCI defines and function prototypes + * Copyright 1994, Drew Eckhardt + * + * For more information, please consult + * + * PCI BIOS Specification Revision + * PCI Local Bus Specification + * PCI System Design Guide + * + * PCI Special Interest Group + * M/S HF3-15A + * 5200 N.E. Elam Young Parkway + * Hillsboro, Oregon 97124-6497 + * +1 (503) 696-2000 + * +1 (800) 433-5177 + * + * Manuals are $25 each or $50 for all three, plus $7 shipping + * within the United States, $35 abroad. + */ + +#ifndef PCI_H +#define PCI_H + +/* Configuration method #1 */ +#define PCI_CONFIG1_ADDRESS_REG 0xcf8 +#define PCI_CONFIG1_ENABLE 0x80000000 +#define PCI_CONFIG1_TUPPLE (bus, device, function, register) \ + (PCI_CONFIG1_ENABLE | ((bus) << 16) & 0xff0000 | \ + ((device) << 11) & 0xf800 | ((function) << 8) & 0x700 | \ + ((register) << 2) & 0xfc) +#define PCI_CONFIG1_DATA_REG 0xcfc + +/* Configuration method #2, deprecated */ +#define PCI_CONFIG2_ENABLE_REG 0xcf8 +#define PCI_CONFIG2_ENABLE 0xf0 +#define PCI_CONFIG2_TUPPLE (function) \ + (PCI_CONFIG2_ENABLE | ((function) << 1) & 0xe) +#define PCI_CONFIG2_FORWARD_REG 0xcfa + +/* + * Under PCI, each device has 256 bytes of configuration address space, + * of which the first 64 bytes is standardized as follows : + */ + +#define PCI_VENDOR_ID 0x00 /* 16 bits */ +#define PCI_DEVICE_ID 0x02 /* 16 bits */ +#define PCI_COMMAND 0x04 /* 16 bits */ +#define PCI_COMMAND_IO 0x1 /* Enable response in I/O space */ +#define PCI_COMMAND_MEMORY 0x2 /* Enable response in I/O space */ +#define PCI_COMMAND_MASTER 0x4 /* Enable bus mastering */ +#define PCI_COMMAND_SPECIAL 0x8 /* Enable response to special cycles */ +#define PCI_COMMAND_INVALIDATE 0x10 /* Use memory write and invalidate */ +#define PCI_COMMAND_VGA_PALETTE 0x20 /* Enable palette snooping */ +#define PCI_COMMAND_PARITY 0x40 /* Enable parity checking */ +#define PCI_COMMAND_WAIT 0x80 /* Enable address/data stepping */ +#define PCI_COMMAND_SERR 0x100 /* Enable SERR */ +#define PCI_COMMAND_FAST_BACK 0x200 /* Enable back-to-back writes */ + +#define PCI_STATUS 0x06 /* 16 bits */ +#define PCI_STATUS_FAST_BACK 0x80 /* Accept fast-back to back */ +#define PCI_STATUS_PARITY 0x100 /* Detected parity error */ +#define PCI_STATUS_DEVSEL_MASK 0x600 /* DEVSEL timing */ +#define PCI_STATUS_DEVSEL_FAST 0x000 +#define PCI_STATUS_DEVSEL_MEDIUM 0x200 +#define PCI_STATUS_DEVESEL_SLOW 0x400 +#define PCI_STATUS_SIG_TARGET_ABORT 0x800 /* Set on target abort */ +#define PCI_STATUS_REC_TARGET_ABORT 0x1000 /* Master ack of " */ +#define PCI_STATUS_REC_MASTER_ABORT 0x2000 /* Set on master abort */ +#define PCI_STATUS_SIG_SYSTEM_ERROR 0x4000 /* Set when we drive SERR */ +#define PCI_STATUS_DETECTED_PARITY 0x8000 /* Set on parity error */ + +#define PCI_CLASS_REVISION 0x08 /* High 24 bits are class, low 8 + revision */ +#define PCI_CACHE_LINE_SIZE 0x0c /* 8 bits */ +#define PCI_LATENCY_TIMER 0x0d /* 8 bits */ +#define PCI_HEADER_TYPE 0x0e /* 8 bits */ +#define PCI_BIST 0x0f /* 8 bits */ +#define PCI_BIST_CODE_MASK 0x0f /* Return result */ +#define PCI_BIST_START 0x40 /* 1 to start BIST, 2 secs or less */ +#define PCI_BIST_CAPABLE 0x80 /* 1 if BIST capable */ + +/* + * Base addresses specify locations in memory or I/O space. + * Decoded size can be determined by writing a value of + * 0xffffffff to the register, and reading it back. Only + * 1 bits are decoded. + */ + +#define PCI_BASE_ADDRESS_0 0x10 /* 32 bits */ +#define PCI_BASE_ADDRESS_1 0x14 /* 32 bits */ +#define PCI_BASE_ADDRESS_2 0x18 /* 32 bits */ +#define PCI_BASE_ADDRESS_3 0x1c /* 32 bits */ +#define PCI_BASE_ADDRESS_4 0x20 /* 32 bits */ +#define PCI_BASE_ADDRESS_5 0x24 /* 32 bits */ +#define PCI_BASE_ADDRESS_SPACE 0x01 /* 0 = memory, 1 = I/O */ +#define PCI_BASE_ADDRESS_SPACE_IO 0x01 +#define PCI_BASE_ADDRESS_SPACE_MEMORY 0x00 +#define PCI_BASE_ADDRESS_MEM_TYPE_MASK 0x06 +#define PCI_BASE_ADDRESS_MEM_TYPE_32 0x00 /* 32 bit address */ +#define PCI_BASE_ADDRESS_MEM_TYPE_1M 0x02 /* Below 1M */ +#define PCI_BASE_ADDRESS_MEM_TYPE_64 0x04 /* 64 bit address */ +#define PCI_BASE_ADDRESS_MEM_MASK ~7 +#define PCI_BASE_ADDRESS_IO_MASK ~3 +/* bit 1 is reserved if address_space = 1 */ + +/* 0x28-0x2f are reserved */ +#define PCI_ROM_ADDRESS 0x30 /* 32 bits */ +#define PCI_ROM_ADDRESS_ENABLE 0x01 /* Write 1 to enable ROM, + bits 31..11 are address, + 10..2 are reserved */ +/* 0x34-0x3b are reserved */ +#define PCI_INTERRUPT_LINE 0x3c /* 8 bits */ +#define PCI_INTERRUPT_PIN 0x3d /* 8 bits */ +#define PCI_MIN_GNT 0x3e /* 8 bits */ +#define PCI_MAX_LAT 0x3f /* 8 bits */ + +#define PCI_VENDOR_ID_NCR 0x1000 +#define PCI_DEVICE_ID_NCR_53C810 0x0001 +#define PCI_DEVICE_ID_NCR_53C820 0x0002 +#define PCI_DEVICE_ID_NCR_53C825 0x0003 + +#define PCI_VENDOR_ID_ADAPTEC 0x9004 +#define PCI_DEVICE_ID_ADAPTEC_2940 0x7178 + +/* PCI BIOS */ + +extern int pcibios_present (void); + +#define PCIBIOS_SUCCESSFUL 0x00 +#define PCIBIOS_FUNC_NOT_SUPPORTED 0x81 +#define PCIBIOS_BAD_VENDOR_ID 0x83 +#define PCIBIOS_DEVICE_NOT_FOUND 0x86 +#define PCIBIOS_BAD_REGISTER_NUMBER 0x87 + +/* + * The PCIBIOS calls all bit-field the device_function variable such that + * the bit fielding matches that of the bl register used in the actual + * calls. + */ + +extern int pcibios_find_class (unsigned long class_code, unsigned short index, + unsigned char *bus, unsigned char *device_fn); +extern int pcibios_find_device (unsigned short vendor, unsigned short device_id, + unsigned short index, unsigned char *bus, unsigned char *device_fn); +extern int pcibios_read_config_byte (unsigned char bus, + unsigned char device_fn, unsigned char where, unsigned char *value); +extern int pcibios_read_config_word (unsigned char bus, + unsigned char device_fn, unsigned char where, unsigned short *value); +extern int pcibios_read_config_dword (unsigned char bus, + unsigned char device_fn, unsigned char where, unsigned long *value); +extern char *pcibios_strerror (int error); +extern int pcibios_write_config_byte (unsigned char bus, + unsigned char device_fn, unsigned char where, unsigned char value); +extern int pcibios_write_config_word (unsigned char bus, + unsigned char device_fn, unsigned char where, unsigned short value); +extern pcibios_write_config_dword (unsigned char bus, + unsigned char device_fn, unsigned char where, unsigned long value); +#endif /* ndef PCI_H */ diff --git a/include/linux/personality.h b/include/linux/personality.h new file mode 100644 index 000000000..4f292251a --- /dev/null +++ b/include/linux/personality.h @@ -0,0 +1,51 @@ +#ifndef _PERSONALITY_H +#define _PERSONALITY_H + +#include <linux/linkage.h> +#include <linux/ptrace.h> + + +/* Flags for bug emulation. These occupy the top three bytes. */ +#define STICKY_TIMEOUTS 0x4000000 +#define WHOLE_SECONDS 0x2000000 + +/* Personality types. These go in the low byte. Avoid using the top bit, + * it will conflict with error returns. + */ +#define PER_MASK (0x00ff) +#define PER_LINUX (0x0000) +#define PER_SVR4 (0x0001 | STICKY_TIMEOUTS) +#define PER_SVR3 (0x0002 | STICKY_TIMEOUTS) +#define PER_SCOSVR3 (0x0003 | STICKY_TIMEOUTS | WHOLE_SECONDS) +#define PER_WYSEV386 (0x0004 | STICKY_TIMEOUTS) +#define PER_ISCR4 (0x0005 | STICKY_TIMEOUTS) +#define PER_BSD (0x0006) + + +/* Prototype for an lcall7 syscall handler. */ +typedef asmlinkage void (*lcall7_func)(struct pt_regs *); + + +/* Description of an execution domain - personality range supported, + * lcall7 syscall handler, start up / shut down functions etc. + * N.B. The name and lcall7 handler must be where they are since the + * offset of the handler is hard coded in kernel/sys_call.S. + */ +struct exec_domain { + char *name; + lcall7_func handler; + unsigned char pers_low, pers_high; + unsigned long * signal_map; + unsigned long * signal_invmap; + int *use_count; + struct exec_domain *next; +}; + +extern struct exec_domain default_exec_domain; + +extern struct exec_domain *lookup_exec_domain(unsigned long personality); +extern int register_exec_domain(struct exec_domain *it); +extern int unregister_exec_domain(struct exec_domain *it); +extern asmlinkage int sys_personality(unsigned long personality); + +#endif /* _PERSONALITY_H */ diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h new file mode 100644 index 000000000..21b39d628 --- /dev/null +++ b/include/linux/pipe_fs_i.h @@ -0,0 +1,35 @@ +#ifndef _LINUX_PIPE_FS_I_H +#define _LINUX_PIPE_FS_I_H + +struct pipe_inode_info { + struct wait_queue * wait; + char * base; + unsigned int start; + unsigned int len; + unsigned int lock; + unsigned int rd_openers; + unsigned int wr_openers; + unsigned int readers; + unsigned int writers; +}; + +#define PIPE_WAIT(inode) ((inode).u.pipe_i.wait) +#define PIPE_BASE(inode) ((inode).u.pipe_i.base) +#define PIPE_START(inode) ((inode).u.pipe_i.start) +#define PIPE_LEN(inode) ((inode).u.pipe_i.len) +#define PIPE_RD_OPENERS(inode) ((inode).u.pipe_i.rd_openers) +#define PIPE_WR_OPENERS(inode) ((inode).u.pipe_i.wr_openers) +#define PIPE_READERS(inode) ((inode).u.pipe_i.readers) +#define PIPE_WRITERS(inode) ((inode).u.pipe_i.writers) +#define PIPE_LOCK(inode) ((inode).u.pipe_i.lock) +#define PIPE_SIZE(inode) PIPE_LEN(inode) + +#define PIPE_EMPTY(inode) (PIPE_SIZE(inode)==0) +#define PIPE_FULL(inode) (PIPE_SIZE(inode)==PIPE_BUF) +#define PIPE_FREE(inode) (PIPE_BUF - PIPE_LEN(inode)) +#define PIPE_END(inode) ((PIPE_START(inode)+PIPE_LEN(inode))&\ + (PIPE_BUF-1)) +#define PIPE_MAX_RCHUNK(inode) (PIPE_BUF - PIPE_START(inode)) +#define PIPE_MAX_WCHUNK(inode) (PIPE_BUF - PIPE_END(inode)) + +#endif diff --git a/include/linux/ppp.h b/include/linux/ppp.h new file mode 100644 index 000000000..eaa15f933 --- /dev/null +++ b/include/linux/ppp.h @@ -0,0 +1,233 @@ +#ifndef _LINUX_PPP_H +#define _LINUX_PPP_H + +/* definitions for kernel PPP module + Michael Callahan <callahan@maths.ox.ac.uk> + Nov. 4 1993 */ + +/* how many PPP units? */ +#define PPP_NRUNIT 4 + +#define PPP_VERSION "0.2.7" + +/* line discipline number */ +#define N_PPP 3 + +/* Magic value for the ppp structure */ +#define PPP_MAGIC 0x5002 + +#define PPPIOCGFLAGS 0x5490 /* get configuration flags */ +#define PPPIOCSFLAGS 0x5491 /* set configuration flags */ +#define PPPIOCGASYNCMAP 0x5492 /* get async map */ +#define PPPIOCSASYNCMAP 0x5493 /* set async map */ +#define PPPIOCGUNIT 0x5494 /* get ppp unit number */ +#define PPPIOCSINPSIG 0x5495 /* set input ready signal */ +#define PPPIOCSDEBUG 0x5497 /* set debug level */ +#define PPPIOCGDEBUG 0x5498 /* get debug level */ +#define PPPIOCGSTAT 0x5499 /* read PPP statistic information */ +#define PPPIOCGTIME 0x549A /* read time delta information */ +#define PPPIOCGXASYNCMAP 0x549B /* get async table */ +#define PPPIOCSXASYNCMAP 0x549C /* set async table */ +#define PPPIOCSMRU 0x549D /* set receive unit size for PPP */ +#define PPPIOCRASYNCMAP 0x549E /* set receive async map */ +#define PPPIOCSMAXCID 0x549F /* set the maximum compression slot id */ + +/* special characters in the framing protocol */ +#define PPP_ALLSTATIONS 0xff /* All-Stations broadcast address */ +#define PPP_UI 0x03 /* Unnumbered Information */ +#define PPP_FLAG 0x7E /* frame delimiter -- marks frame boundaries */ +#define PPP_ADDRESS 0xFF /* first character of frame <-- (may be */ +#define PPP_CONTROL 0x03 /* second character of frame <-- compressed)*/ +#define PPP_TRANS 0x20 /* Asynchronous transparency modifier */ +#define PPP_ESC 0x7d /* escape character -- next character is + data, and the PPP_TRANS bit should be + toggled. PPP_ESC PPP_FLAG is illegal */ + +/* protocol numbers */ +#define PROTO_IP 0x0021 +#define PROTO_VJCOMP 0x002d +#define PROTO_VJUNCOMP 0x002f + +/* FCS support */ +#define PPP_FCS_INIT 0xffff +#define PPP_FCS_GOOD 0xf0b8 + +/* initial MTU */ +#define PPP_MTU 1500 + +/* initial MRU */ +#define PPP_MRU PPP_MTU + +/* flags */ +#define SC_COMP_PROT 0x00000001 /* protocol compression (output) */ +#define SC_COMP_AC 0x00000002 /* header compression (output) */ +#define SC_COMP_TCP 0x00000004 /* TCP (VJ) compression (output) */ +#define SC_NO_TCP_CCID 0x00000008 /* disable VJ connection-id comp. */ +#define SC_REJ_COMP_AC 0x00000010 /* reject adrs/ctrl comp. on input */ +#define SC_REJ_COMP_TCP 0x00000020 /* reject TCP (VJ) comp. on input */ +#define SC_ENABLE_IP 0x00000100 /* IP packets may be exchanged */ +#define SC_IP_DOWN 0x00000200 /* give ip frames to pppd */ +#define SC_IP_FLUSH 0x00000400 /* "next time" flag for IP_DOWN */ +#define SC_DEBUG 0x00010000 /* enable debug messages */ +#define SC_LOG_INPKT 0x00020000 /* log contents of good pkts recvd */ +#define SC_LOG_OUTPKT 0x00040000 /* log contents of pkts sent */ +#define SC_LOG_RAWIN 0x00080000 /* log all chars received */ +#define SC_LOG_FLUSH 0x00100000 /* log all chars flushed */ + +/* Flag bits to determine state of input characters */ +#define SC_RCV_B7_0 0x01000000 /* have rcvd char with bit 7 = 0 */ +#define SC_RCV_B7_1 0x02000000 /* have rcvd char with bit 7 = 0 */ +#define SC_RCV_EVNP 0x04000000 /* have rcvd char with even parity */ +#define SC_RCV_ODDP 0x08000000 /* have rcvd char with odd parity */ + +#define SC_MASK 0x0fffffff /* bits that user can change */ + +/* flag for doing transmitter lockout */ +#define SC_XMIT_BUSY 0x10000000 /* ppp_write_wakeup is active */ + +/* + * This is the format of the data buffer of a LQP packet. The packet data + * is sent/received to the peer. + */ + +struct ppp_lqp_packet_hdr { + unsigned long LastOutLQRs; /* Copied from PeerOutLQRs */ + unsigned long LastOutPackets; /* Copied from PeerOutPackets */ + unsigned long LastOutOctets; /* Copied from PeerOutOctets */ + unsigned long PeerInLQRs; /* Copied from SavedInLQRs */ + unsigned long PeerInPackets; /* Copied from SavedInPackets */ + unsigned long PeerInDiscards; /* Copied from SavedInDiscards */ + unsigned long PeerInErrors; /* Copied from SavedInErrors */ + unsigned long PeerInOctets; /* Copied from SavedInOctets */ + unsigned long PeerOutLQRs; /* Copied from OutLQRs, plus 1 */ + unsigned long PeerOutPackets; /* Current ifOutUniPackets, + 1 */ + unsigned long PeerOutOctets; /* Current ifOutOctets + LQR */ + }; + +/* + * This data is not sent to the remote. It is updated by the driver when + * a packet is received. + */ + +struct ppp_lqp_packet_trailer { + unsigned long SaveInLQRs; /* Current InLQRs on reception */ + unsigned long SaveInPackets; /* Current ifInUniPackets */ + unsigned long SaveInDiscards; /* Current ifInDiscards */ + unsigned long SaveInErrors; /* Current ifInErrors */ + unsigned long SaveInOctets; /* Current ifInOctects */ +}; + +/* + * PPP LQP packet. The packet is changed by the driver immediately prior + * to transmission and updated upon reception with the current values. + * So, it must be known to the driver as well as the pppd software. + */ + +struct ppp_lpq_packet { + unsigned long magic; /* current magic value */ + struct ppp_lqp_packet_hdr hdr; /* Header fields for structure */ + struct ppp_lqp_packet_trailer tail; /* Trailer fields (not sent) */ +}; + +/* + * PPP interface statistics. (used by LQP / pppstats) + */ + +struct ppp_stats { + unsigned long rbytes; /* bytes received */ + unsigned long rcomp; /* compressed packets received */ + unsigned long runcomp; /* uncompressed packets received */ + unsigned long rothers; /* non-ip frames received */ + unsigned long rerrors; /* received errors */ + unsigned long roverrun; /* "buffer overrun" counter */ + unsigned long tossed; /* packets discarded */ + unsigned long runts; /* frames too short to process */ + unsigned long rgiants; /* frames too large to process */ + unsigned long sbytes; /* bytes sent */ + unsigned long scomp; /* compressed packets sent */ + unsigned long suncomp; /* uncompressed packets sent */ + unsigned long sothers; /* non-ip frames sent */ + unsigned long serrors; /* transmitter errors */ + unsigned long sbusy; /* "transmitter busy" counter */ +}; + +/* + * Demand dial fields + */ + +struct ppp_ddinfo { + unsigned long ip_sjiffies; /* time when last IP frame sent */ + unsigned long ip_rjiffies; /* time when last IP frame recvd*/ + unsigned long nip_sjiffies; /* time when last NON-IP sent */ + unsigned long nip_rjiffies; /* time when last NON-IP recvd */ +}; + +#ifdef __KERNEL__ + +struct ppp { + int magic; /* magic value for structure */ + + /* Bitmapped flag fields. */ + char inuse; /* are we allocated? */ + char sending; /* "channel busy" indicator */ + char escape; /* 0x20 if prev char was PPP_ESC*/ + char toss; /* toss this frame */ + + unsigned int flags; /* miscellany */ + + unsigned long xmit_async_map[8]; /* 1 bit means that given control + character is quoted on output*/ + + unsigned long recv_async_map; /* 1 bit means that given control + character is ignored on input*/ + int mtu; /* maximum xmit frame size */ + int mru; /* maximum receive frame size */ + unsigned short fcs; /* FCS field of current frame */ + + /* Various fields. */ + int line; /* PPP channel number */ + struct tty_struct *tty; /* ptr to TTY structure */ + struct device *dev; /* easy for intr handling */ + struct slcompress *slcomp; /* for header compression */ + unsigned long last_xmit; /* time of last transmission */ + + /* These are pointers to the malloc()ed frame buffers. + These buffers are used while processing a packet. If a packet + has to hang around for the user process to read it, it lingers in + the user buffers below. */ + unsigned char *rbuff; /* receiver buffer */ + unsigned char *xbuff; /* transmitter buffer */ + unsigned char *cbuff; /* compression buffer */ + + /* These are the various pointers into the buffers. */ + unsigned char *rhead; /* RECV buffer pointer (head) */ + unsigned char *rend; /* RECV buffer pointer (end) */ + int rcount; /* PPP receive counter */ + unsigned char *xhead; /* XMIT buffer pointer (head) */ + unsigned char *xtail; /* XMIT buffer pointer (end) */ + + /* Structures for interfacing with the user process. */ +#define RBUFSIZE 4000 + unsigned char *us_rbuff; /* circular incoming packet buf.*/ + unsigned char *us_rbuff_end; /* end of allocated space */ + unsigned char *us_rbuff_head; /* head of waiting packets */ + unsigned char *us_rbuff_tail; /* tail of waiting packets */ + unsigned char us_rbuff_lock; /* lock: bit 0 head bit 1 tail */ + int inp_sig; /* input ready signal for pgrp */ + int inp_sig_pid; /* process to get notified */ + + /* items to support the select() function */ + struct wait_queue *write_wait; /* queue for reading processes */ + struct wait_queue *read_wait; /* queue for writing processes */ + + /* PPP interface statistics. */ + struct ppp_stats stats; /* statistic information */ + + /* PPP demand dial information. */ + struct ppp_ddinfo ddinfo; /* demand dial information */ +}; + +#endif /* __KERNEL__ */ +#endif /* _LINUX_PPP_H */ + + diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h new file mode 100644 index 000000000..70e25bf42 --- /dev/null +++ b/include/linux/proc_fs.h @@ -0,0 +1,104 @@ +#ifndef _LINUX_PROC_FS_H +#define _LINUX_PROC_FS_H + +/* + * The proc filesystem constants/structures + */ + +enum root_directory_inos { + PROC_ROOT_INO = 1, + PROC_LOADAVG, + PROC_UPTIME, + PROC_MEMINFO, + PROC_KMSG, + PROC_VERSION, + PROC_SELF, /* will change inode # */ + PROC_NET, +#ifdef CONFIG_DEBUG_MALLOC + PROC_MALLOC, +#endif + PROC_KCORE, + PROC_MODULES, + PROC_STAT, + PROC_DEVICES, + PROC_INTERRUPTS, + PROC_FILESYSTEMS, + PROC_KSYMS, + PROC_DMA +}; + +enum pid_directory_inos { + PROC_PID_INO = 2, + PROC_PID_MEM, + PROC_PID_CWD, + PROC_PID_ROOT, + PROC_PID_EXE, + PROC_PID_FD, + PROC_PID_ENVIRON, + PROC_PID_CMDLINE, + PROC_PID_STAT, + PROC_PID_STATM, + PROC_PID_MAPS +}; + +enum pid_subdirectory_inos { + PROC_PID_FD_DIR = 1 +}; + +enum net_directory_inos { + PROC_NET_UNIX = 128, +#ifdef CONFIG_INET + PROC_NET_ARP, + PROC_NET_ROUTE, + PROC_NET_DEV, + PROC_NET_RAW, + PROC_NET_TCP, + PROC_NET_UDP, + PROC_NET_SNMP, +#ifdef CONFIG_INET_RARP + PROC_NET_RARP, +#endif +#endif +#ifdef CONFIG_IPX + PROC_NET_IPX_ROUTE, + PROC_NET_IPX, +#endif +#ifdef CONFIG_AX25 + PROC_NET_AX25_ROUTE, + PROC_NET_AX25, +#ifdef CONFIG_NETROM + PROC_NET_NR_NODES, + PROC_NET_NR_NEIGH, + PROC_NET_NR, +#endif +#endif + PROC_NET_LAST +}; + +#define PROC_SUPER_MAGIC 0x9fa0 + +struct proc_dir_entry { + unsigned short low_ino; + unsigned short namelen; + char * name; +}; + +extern struct super_block *proc_read_super(struct super_block *,void *,int); +extern void proc_put_inode(struct inode *); +extern void proc_put_super(struct super_block *); +extern void proc_statfs(struct super_block *, struct statfs *); +extern void proc_read_inode(struct inode *); +extern void proc_write_inode(struct inode *); +extern int proc_match(int, const char *, struct proc_dir_entry *); + +extern struct inode_operations proc_root_inode_operations; +extern struct inode_operations proc_base_inode_operations; +extern struct inode_operations proc_net_inode_operations; +extern struct inode_operations proc_mem_inode_operations; +extern struct inode_operations proc_array_inode_operations; +extern struct inode_operations proc_kcore_inode_operations; +extern struct inode_operations proc_kmsg_inode_operations; +extern struct inode_operations proc_link_inode_operations; +extern struct inode_operations proc_fd_inode_operations; + +#endif diff --git a/include/linux/ptrace.h b/include/linux/ptrace.h new file mode 100644 index 000000000..6718860e0 --- /dev/null +++ b/include/linux/ptrace.h @@ -0,0 +1,69 @@ +#ifndef _LINUX_PTRACE_H +#define _LINUX_PTRACE_H +/* ptrace.h */ +/* structs and defines to help the user use the ptrace system call. */ + +/* has the defines to get at the registers. */ + +#define PTRACE_TRACEME 0 +#define PTRACE_PEEKTEXT 1 +#define PTRACE_PEEKDATA 2 +#define PTRACE_PEEKUSR 3 +#define PTRACE_POKETEXT 4 +#define PTRACE_POKEDATA 5 +#define PTRACE_POKEUSR 6 +#define PTRACE_CONT 7 +#define PTRACE_KILL 8 +#define PTRACE_SINGLESTEP 9 + +#define PTRACE_ATTACH 0x10 +#define PTRACE_DETACH 0x11 + +#define PTRACE_SYSCALL 24 + +/* use ptrace (3 or 6, pid, PT_EXCL, data); to read or write + the processes registers. */ + +#define EBX 0 +#define ECX 1 +#define EDX 2 +#define ESI 3 +#define EDI 4 +#define EBP 5 +#define EAX 6 +#define DS 7 +#define ES 8 +#define FS 9 +#define GS 10 +#define ORIG_EAX 11 +#define EIP 12 +#define CS 13 +#define EFL 14 +#define UESP 15 +#define SS 16 + + +/* this struct defines the way the registers are stored on the + stack during a system call. */ + +struct pt_regs { + long ebx; + long ecx; + long edx; + long esi; + long edi; + long ebp; + long eax; + unsigned short ds, __dsu; + unsigned short es, __esu; + unsigned short fs, __fsu; + unsigned short gs, __gsu; + long orig_eax; + long eip; + unsigned short cs, __csu; + long eflags; + long esp; + unsigned short ss, __ssu; +}; + +#endif diff --git a/include/linux/resource.h b/include/linux/resource.h new file mode 100644 index 000000000..93db09bc9 --- /dev/null +++ b/include/linux/resource.h @@ -0,0 +1,71 @@ +#ifndef _LINUX_RESOURCE_H +#define _LINUX_RESOURCE_H + +/* + * Resource control/accounting header file for linux + */ + +/* + * Definition of struct rusage taken from BSD 4.3 Reno + * + * We don't support all of these yet, but we might as well have them.... + * Otherwise, each time we add new items, programs which depend on this + * structure will lose. This reduces the chances of that happening. + */ +#define RUSAGE_SELF 0 +#define RUSAGE_CHILDREN (-1) +#define RUSAGE_BOTH (-2) /* sys_wait4() uses this */ + +struct rusage { + struct timeval ru_utime; /* user time used */ + struct timeval ru_stime; /* system time used */ + long ru_maxrss; /* maximum resident set size */ + long ru_ixrss; /* integral shared memory size */ + long ru_idrss; /* integral unshared data size */ + long ru_isrss; /* integral unshared stack size */ + long ru_minflt; /* page reclaims */ + long ru_majflt; /* page faults */ + long ru_nswap; /* swaps */ + long ru_inblock; /* block input operations */ + long ru_oublock; /* block output operations */ + long ru_msgsnd; /* messages sent */ + long ru_msgrcv; /* messages received */ + long ru_nsignals; /* signals received */ + long ru_nvcsw; /* voluntary context switches */ + long ru_nivcsw; /* involuntary " */ +}; + +/* + * Resource limits + */ + +#define RLIMIT_CPU 0 /* CPU time in ms */ +#define RLIMIT_FSIZE 1 /* Maximum filesize */ +#define RLIMIT_DATA 2 /* max data size */ +#define RLIMIT_STACK 3 /* max stack size */ +#define RLIMIT_CORE 4 /* max core file size */ +#define RLIMIT_RSS 5 /* max resident set size */ + +#ifdef notdef +#define RLIMIT_MEMLOCK 6 /* max locked-in-memory address space*/ +#define RLIMIT_NPROC 7 /* max number of processes */ +#define RLIMIT_NOFILE 8 /* max number of open files */ +#endif + +#define RLIM_NLIMITS 6 + +#define RLIM_INFINITY ((long)(~0UL>>1)) + +struct rlimit { + int rlim_cur; + int rlim_max; +}; + +#define PRIO_MIN (-99) +#define PRIO_MAX 14 + +#define PRIO_PROCESS 0 +#define PRIO_PGRP 1 +#define PRIO_USER 2 + +#endif diff --git a/include/linux/route.h b/include/linux/route.h new file mode 100644 index 000000000..3cadd206d --- /dev/null +++ b/include/linux/route.h @@ -0,0 +1,69 @@ +/* + * INET An implementation of the TCP/IP protocol suite for the LINUX + * operating system. INET is implemented using the BSD Socket + * interface as the means of communication with the user level. + * + * Global definitions for the IP router interface. + * + * Version: @(#)route.h 1.0.3 05/27/93 + * + * Authors: Original taken from Berkeley UNIX 4.3, (c) UCB 1986-1988 + * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> + * + * 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. + */ +#ifndef _LINUX_ROUTE_H +#define _LINUX_ROUTE_H + +#include <linux/if.h> + + +/* This structure gets passed by the SIOCADDRTOLD and SIOCDELRTOLD calls. */ + +struct old_rtentry { + unsigned long rt_genmask; + struct sockaddr rt_dst; + struct sockaddr rt_gateway; + short rt_flags; + short rt_refcnt; + unsigned long rt_use; + char *rt_dev; +}; + +/* This structure gets passed by the SIOCADDRT and SIOCDELRT calls. */ +struct rtentry { + unsigned long rt_hash; /* hash key for lookups */ + struct sockaddr rt_dst; /* target address */ + struct sockaddr rt_gateway; /* gateway addr (RTF_GATEWAY) */ + struct sockaddr rt_genmask; /* target network mask (IP) */ + short rt_flags; + short rt_refcnt; + unsigned long rt_use; + struct ifnet *rt_ifp; + short rt_metric; /* +1 for binary compatibility! */ + char *rt_dev; /* forcing the device at add */ + unsigned long rt_mss; /* per route MTU/Window */ + unsigned long rt_window; /* Window clamping */ +}; + + +#define RTF_UP 0x0001 /* route usable */ +#define RTF_GATEWAY 0x0002 /* destination is a gateway */ +#define RTF_HOST 0x0004 /* host entry (net otherwise) */ +#define RTF_REINSTATE 0x0008 /* reinstate route after tmout */ +#define RTF_DYNAMIC 0x0010 /* created dyn. (by redirect) */ +#define RTF_MODIFIED 0x0020 /* modified dyn. (by redirect) */ +#define RTF_MSS 0x0040 /* specific MSS for this route */ +#define RTF_WINDOW 0x0080 /* per route window clamping */ + +/* + * REMOVE THESE BY 1.2.0 !!!!!!!!!!!!!!!!! + */ + +#define RTF_MTU RTF_MSS +#define rt_mtu rt_mss + +#endif /* _LINUX_ROUTE_H */ diff --git a/include/linux/sbpcd.h b/include/linux/sbpcd.h new file mode 100644 index 000000000..1095175ae --- /dev/null +++ b/include/linux/sbpcd.h @@ -0,0 +1,468 @@ +/* + * sbpcd.h Specify interface address and interface type here. + */ + +/* + * the definitions for the first controller can get overridden by + * the kernel command line ("lilo boot option"). + * Examples: + * sbpcd=0x230,SoundBlaster + * or + * sbpcd=0x300,LaserMate + * or + * sbpcd=0x330,SPEA + * + * These strings are case sensitive !!! + */ + +/* + * put your CDROM port base address into CDROM_PORT + * and specify the type of your interface in SBPRO. + * + * SBPRO addresses typically are 0x0230 (=0x220+0x10), 0x0250, ... + * LASERMATE (CI-101P, WDH-7001C) addresses typically are 0x0300, 0x0310, ... + * SPEA addresses are 0x320, 0x330, 0x340, 0x350 + * there are some soundcards on the market with 0x0630, 0x0650, ... + * + * example: if your SBPRO audio address is 0x220, specify 0x230. + * + * + * set SBPRO to 1 for "true" SoundBlaster card + * set SBPRO to 0 for "poor" (no sound) interface cards + * and for "compatible" soundcards. + * set SBPRO to 2 for the SPEA Media FX card + * + * most "compatible" sound boards like Galaxy need to set SBPRO to 0 !!! + * if SBPRO gets set wrong, the drive will get found - but any + * data access will give errors (audio access will work). + * The OmniCD interface card from CreativeLabs needs SBPRO 1. + * + * mail to emoenke@gwdg.de if your "compatible" card needs SBPRO 1 + * (currently I do not know any "compatible" with SBPRO 1) + * then I can include better information with the next release. + */ +#if !(SBPCD_ISSUE-1) /* first (or if you have only one) interface board: */ +#define CDROM_PORT 0x0230 +#define SBPRO 1 +#endif + +/* + * If you have a "compatible" soundcard of type "SBPRO 0" or "SBPRO 2", + * enter your sound card's base address here if you want sbpcd to turn + * the CD sound channels on. + * + * Example: #define SOUND_BASE 0x220 enables the sound card's CD channels + * #define SOUND_BASE 0 leaves the soundcard untouched + */ +#define SOUND_BASE 0 + +/* ignore the rest if you have only one interface board & driver */ + +#if !(SBPCD_ISSUE-2) /* second interface board: */ +#define CDROM_PORT 0x0370 +#define SBPRO 0 +#endif +#if !(SBPCD_ISSUE-3) /* third interface board: */ +#define CDROM_PORT 0x0330 +#define SBPRO 0 +#endif +#if !(SBPCD_ISSUE-4) /* fourth interface board: */ +#define CDROM_PORT 0x0340 +#define SBPRO 0 +#endif + +/*==========================================================================*/ +/*==========================================================================*/ +/* + * nothing to change below here if you are not experimenting + */ +#ifndef _LINUX_SBPCD_H + +#define _LINUX_SBPCD_H + +/*==========================================================================*/ +/*==========================================================================*/ +/* + * Debug output levels + */ +#define DBG_INF 1 /* necessary information */ +#define DBG_BSZ 2 /* BLOCK_SIZE trace */ +#define DBG_REA 3 /* "read" status trace */ +#define DBG_CHK 4 /* "media check" trace */ +#define DBG_TIM 5 /* datarate timer test */ +#define DBG_INI 6 /* initialization trace */ +#define DBG_TOC 7 /* tell TocEntry values */ +#define DBG_IOC 8 /* ioctl trace */ +#define DBG_STA 9 /* "ResponseStatus" trace */ +#define DBG_ERR 10 /* "xx_ReadError" trace */ +#define DBG_CMD 11 /* "cmd_out" trace */ +#define DBG_WRN 12 /* give explanation before auto-probing */ +#define DBG_MUL 13 /* multi session code test */ +#define DBG_ID 14 /* "drive_id !=0" test code */ +#define DBG_IOX 15 /* some special information */ +#define DBG_DID 16 /* drive ID test */ +#define DBG_RES 17 /* drive reset info */ +#define DBG_SPI 18 /* SpinUp test */ +#define DBG_IOS 19 /* ioctl trace: "subchannel" */ +#define DBG_IO2 20 /* ioctl trace: general */ +#define DBG_UPC 21 /* show UPC information */ +#define DBG_XA 22 /* XA mode debugging */ +#define DBG_LCK 23 /* door (un)lock info */ +#define DBG_SQ 24 /* dump SubQ frame */ +#define DBG_AUD 25 /* "read audio" debugging */ +#define DBG_SEQ 26 /* Sequoia interface configuration trace */ +#define DBG_000 27 /* unnecessary information */ + +/*==========================================================================*/ +/*==========================================================================*/ + +/* + * bits of flags_cmd_out: + */ +#define f_respo3 0x100 +#define f_putcmd 0x80 +#define f_respo2 0x40 +#define f_lopsta 0x20 +#define f_getsta 0x10 +#define f_ResponseStatus 0x08 +#define f_obey_p_check 0x04 +#define f_bit1 0x02 +#define f_wait_if_busy 0x01 + +/* + * diskstate_flags: + */ +#define upc_bit 0x40 +#define volume_bit 0x20 +#define toc_bit 0x10 +#define cd_size_bit 0x04 +#define subq_bit 0x02 +#define frame_size_bit 0x01 + +/* + * disk states (bits of diskstate_flags): + */ +#define upc_valid (DriveStruct[d].diskstate_flags&upc_bit) +#define volume_valid (DriveStruct[d].diskstate_flags&volume_bit) +#define toc_valid (DriveStruct[d].diskstate_flags&toc_bit) +#define cd_size_valid (DriveStruct[d].diskstate_flags&cd_size_bit) +#define subq_valid (DriveStruct[d].diskstate_flags&subq_bit) +#define frame_size_valid (DriveStruct[d].diskstate_flags&frame_size_bit) + + +/* + * bits of the status_byte (result of xx_ReadStatus): + */ +#define p_door_closed 0x80 +#define p_caddy_in 0x40 +#define p_spinning 0x20 +#define p_check 0x10 +#define p_busy_new 0x08 +#define p_door_locked 0x04 +#define p_bit_1 0x02 +#define p_disk_ok 0x01 +/* + * "old" drives status result bits: + */ +#define p_caddin_old 0x40 +#define p_success_old 0x08 +#define p_busy_old 0x04 + +/* + * used drive states: + */ +#define st_door_closed (DriveStruct[d].status_byte&p_door_closed) +#define st_caddy_in (DriveStruct[d].status_byte&p_caddy_in) +#define st_spinning (DriveStruct[d].status_byte&p_spinning) +#define st_check (DriveStruct[d].status_byte&p_check) +#define st_busy (DriveStruct[d].status_byte&p_busy_new) +#define st_door_locked (DriveStruct[d].status_byte&p_door_locked) +#define st_diskok (DriveStruct[d].status_byte&p_disk_ok) + +/* + * bits of the CDi_status register: + */ +#define s_not_result_ready 0x04 /* 0: "result ready" */ +#define s_not_data_ready 0x02 /* 0: "data ready" */ +#define s_attention 0x01 /* 1: "attention required" */ +/* + * usable as: + */ +#define DRV_ATTN ((inb(CDi_status)&s_attention)!=0) +#define DATA_READY ((inb(CDi_status)&s_not_data_ready)==0) +#define RESULT_READY ((inb(CDi_status)&s_not_result_ready)==0) + +/* + * drive types (firmware versions): + */ +#define drv_old 0x10 /* CR-52x family */ +#define drv_199 0x11 /* <200 */ +#define drv_200 0x12 /* <201 */ +#define drv_201 0x13 /* <210 */ +#define drv_210 0x14 /* <211 */ +#define drv_211 0x15 /* <300 */ +#define drv_300 0x16 /* >=300 */ + +#define drv_lcs 0x20 /* Longshine family */ +#define drv_260 0x21 /* LCS-7260 */ + +#define drv_new 0x40 /* CR-56x family */ +#define drv_099 0x41 /* <100 */ +#define drv_100 0x42 /* >=100 */ + +#define old_drive (DriveStruct[d].drv_type&drv_old) +#define lcs_drive (DriveStruct[d].drv_type&drv_lcs) +#define new_drive (DriveStruct[d].drv_type&drv_new) + +/* + * audio states: + */ +#define audio_playing 2 +#define audio_pausing 1 + +/* + * drv_pattern, drv_options: + */ +#define speed_auto 0x80 +#define speed_300 0x40 +#define speed_150 0x20 +#define sax_a 0x04 +#define sax_xn2 0x02 +#define sax_xn1 0x01 + +/* + * values of cmd_type (0 else): + */ +#define READ_M1 0x01 /* "data mode 1": 2048 bytes per frame */ +#define READ_M2 0x02 /* "data mode 2": 12+2048+280 bytes per frame */ +#define READ_SC 0x04 /* "subchannel info": 96 bytes per frame */ +#define READ_AU 0x08 /* "audio frame": 2352 bytes per frame */ + +/* + * sense byte: used only if new_drive + * only during cmd 09 00 xx ah al 00 00 + * + * values: 00 + * 82 "raw audio" mode + * xx from infobuf[0] after 85 00 00 00 00 00 00 + */ + +/* audio status (bin) */ +#define aud_00 0x00 /* Audio status byte not supported or not valid */ +#define audx11 0x0b /* Audio play operation in progress */ +#define audx12 0x0c /* Audio play operation paused */ +#define audx13 0x0d /* Audio play operation successfully completed */ +#define audx14 0x0e /* Audio play operation stopped due to error */ +#define audx15 0x0f /* No current audio status to return */ + +/* audio status (bcd) */ +#define aud_11 0x11 /* Audio play operation in progress */ +#define aud_12 0x12 /* Audio play operation paused */ +#define aud_13 0x13 /* Audio play operation successfully completed */ +#define aud_14 0x14 /* Audio play operation stopped due to error */ +#define aud_15 0x15 /* No current audio status to return */ + +/*============================================================================ +============================================================================== + +COMMAND SET of "old" drives like CR-521, CR-522 + (the CR-562 family is different): + +No. Command Code +-------------------------------------------- + +Drive Commands: + 1 Seek 01 + 2 Read Data 02 + 3 Read XA-Data 03 + 4 Read Header 04 + 5 Spin Up 05 + 6 Spin Down 06 + 7 Diagnostic 07 + 8 Read UPC 08 + 9 Read ISRC 09 +10 Play Audio 0A +11 Play Audio MSF 0B +12 Play Audio Track/Index 0C + +Status Commands: +13 Read Status 81 +14 Read Error 82 +15 Read Drive Version 83 +16 Mode Select 84 +17 Mode Sense 85 +18 Set XA Parameter 86 +19 Read XA Parameter 87 +20 Read Capacity 88 +21 Read SUB_Q 89 +22 Read Disc Code 8A +23 Read Disc Information 8B +24 Read TOC 8C +25 Pause/Resume 8D +26 Read Packet 8E +27 Read Path Check 00 + + +all numbers (lba, msf-bin, msf-bcd, counts) to transfer high byte first + +mnemo 7-byte command #bytes response (r0...rn) +________ ____________________ ____ + +Read Status: +status: 81. (1) one-byte command, gives the main + status byte +Read Error: +check1: 82 00 00 00 00 00 00. (6) r1: audio status + +Read Packet: +check2: 8e xx 00 00 00 00 00. (xx) gets xx bytes response, relating + to commands 01 04 05 07 08 09 + +Play Audio: +play: 0a ll-bb-aa nn-nn-nn. (0) play audio, ll-bb-aa: starting block (lba), + nn-nn-nn: #blocks +Play Audio MSF: + 0b mm-ss-ff mm-ss-ff (0) play audio from/to + +Play Audio Track/Index: + 0c ... + +Pause/Resume: +pause: 8d pr 00 00 00 00 00. (0) pause (pr=00) + resume (pr=80) audio playing + +Mode Select: + 84 00 nn-nn ??-?? 00 (0) nn-nn: 2048 or 2340 + possibly defines transfer size + +set_vol: 84 83 00 00 sw le 00. (0) sw(itch): lrxxxxxx (off=1) + le(vel): min=0, max=FF, else half + (firmware 2.11) + +Mode Sense: +get_vol: 85 03 00 00 00 00 00. (2) tell current audio volume setting + +Read Disc Information: +tocdesc: 8b 00 00 00 00 00 00. (6) read the toc descriptor ("msf-bin"-format) + +Read TOC: +tocent: 8c fl nn 00 00 00 00. (8) read toc entry #nn + (fl=0:"lba"-, =2:"msf-bin"-format) + +Read Capacity: +capacit: 88 00 00 00 00 00 00. (5) "read CD-ROM capacity" + + +Read Path Check: +ping: 00 00 00 00 00 00 00. (2) r0=AA, r1=55 + ("ping" if the drive is connected) + +Read Drive Version: +ident: 83 00 00 00 00 00 00. (12) gives "MATSHITAn.nn" + (n.nn = 2.01, 2.11., 3.00, ...) + +Seek: +seek: 01 00 ll-bb-aa 00 00. (0) +seek: 01 02 mm-ss-ff 00 00. (0) + +Read Data: +read: 02 xx-xx-xx nn-nn fl. (??) read nn-nn blocks of 2048 bytes, + starting at block xx-xx-xx + fl=0: "lba"-, =2:"msf-bcd"-coded xx-xx-xx + +Read XA-Data: +read: 03 xx-xx-xx nn-nn fl. (??) read nn-nn blocks of 2340 bytes, + starting at block xx-xx-xx + fl=0: "lba"-, =2:"msf-bcd"-coded xx-xx-xx + +Read SUB_Q: + 89 fl 00 00 00 00 00. (13) r0: audio status, r4-r7: lba/msf, + fl=0: "lba", fl=2: "msf" + +Read Disc Code: + 8a 00 00 00 00 00 00. (14) possibly extended "check condition"-info + +Read Header: + 04 00 ll-bb-aa 00 00. (0) 4 bytes response with "check2" + 04 02 mm-ss-ff 00 00. (0) 4 bytes response with "check2" + +Spin Up: + 05 00 ll-bb-aa 00 00. (0) possibly implies a "seek" + +Spin Down: + 06 ... + +Diagnostic: + 07 00 ll-bb-aa 00 00. (2) 2 bytes response with "check2" + 07 02 mm-ss-ff 00 00. (2) 2 bytes response with "check2" + +Read UPC: + 08 00 ll-bb-aa 00 00. (16) + 08 02 mm-ss-ff 00 00. (16) + +Read ISRC: + 09 00 ll-bb-aa 00 00. (15) 15 bytes response with "check2" + 09 02 mm-ss-ff 00 00. (15) 15 bytes response with "check2" + +Set XA Parameter: + 86 ... + +Read XA Parameter: + 87 ... + +============================================================================== +============================================================================*/ + +/*==========================================================================*/ +/*==========================================================================*/ + +/* + * highest allowed drive number (MINOR+1) + */ +#define NR_SBPCD 4 + +/* + * we try to never disable interrupts - seems to work + */ +#define SBPCD_DIS_IRQ 0 + +/* + * "write byte to port" + */ +#define OUT(x,y) outb(y,x) + +/* + * use "REP INSB" for strobing the data in: + */ +#define READ_DATA(port, buf, nr) insb(port, buf, nr) + +/*==========================================================================*/ + +#define MIXER_CD_Volume 0x28 /* internal SB Pro register address */ + +/*==========================================================================*/ +/* + * Creative Labs Programmers did this: + */ +#define MAX_TRACKS 120 /* why more than 99? */ + +/*==========================================================================*/ +/* + * To make conversions easier (machine dependent!) + */ +typedef union _msf +{ + u_int n; + u_char c[4]; +} +MSF; + +typedef union _blk +{ + u_int n; + u_char c[4]; +} +BLK; + +/*==========================================================================*/ +#endif _LINUX_SBPCD_H diff --git a/include/linux/sched.h b/include/linux/sched.h new file mode 100644 index 000000000..3a38d57eb --- /dev/null +++ b/include/linux/sched.h @@ -0,0 +1,624 @@ +#ifndef _LINUX_SCHED_H +#define _LINUX_SCHED_H + +/* + * define DEBUG if you want the wait-queues to have some extra + * debugging code. It's not normally used, but might catch some + * wait-queue coding errors. + * + * #define DEBUG + */ + +#define HZ 100 + +/* + * System setup and hardware bug flags.. + */ +extern int hard_math; +extern int x86; +extern int ignore_irq13; +extern int wp_works_ok; /* doesn't work on a 386 */ +extern int hlt_works_ok; /* problems on some 486Dx4's and old 386's */ + +extern unsigned long intr_count; +extern unsigned long event; + +#define start_bh_atomic() \ +__asm__ __volatile__("incl _intr_count") + +#define end_bh_atomic() \ +__asm__ __volatile__("decl _intr_count") + +/* + * Bus types (default is ISA, but people can check others with these..) + * MCA_bus hardcoded to 0 for now. + */ +extern int EISA_bus; +#define MCA_bus 0 + +#include <linux/binfmts.h> +#include <linux/personality.h> +#include <linux/tasks.h> +#include <asm/system.h> + +/* + * User space process size: 3GB. This is hardcoded into a few places, + * so don't change it unless you know what you are doing. + */ +#define TASK_SIZE 0xc0000000 + +/* + * Size of io_bitmap in longwords: 32 is ports 0-0x3ff. + */ +#define IO_BITMAP_SIZE 32 + +/* + * These are the constant used to fake the fixed-point load-average + * counting. Some notes: + * - 11 bit fractions expand to 22 bits by the multiplies: this gives + * a load-average precision of 10 bits integer + 11 bits fractional + * - if you want to count load-averages more often, you need more + * precision, or rounding will get you. With 2-second counting freq, + * the EXP_n values would be 1981, 2034 and 2043 if still using only + * 11 bit fractions. + */ +extern unsigned long avenrun[]; /* Load averages */ + +#define FSHIFT 11 /* nr of bits of precision */ +#define FIXED_1 (1<<FSHIFT) /* 1.0 as fixed-point */ +#define LOAD_FREQ (5*HZ) /* 5 sec intervals */ +#define EXP_1 1884 /* 1/exp(5sec/1min) as fixed-point */ +#define EXP_5 2014 /* 1/exp(5sec/5min) */ +#define EXP_15 2037 /* 1/exp(5sec/15min) */ + +#define CALC_LOAD(load,exp,n) \ + load *= exp; \ + load += n*(FIXED_1-exp); \ + load >>= FSHIFT; + +#define CT_TO_SECS(x) ((x) / HZ) +#define CT_TO_USECS(x) (((x) % HZ) * 1000000/HZ) + +#define FIRST_TASK task[0] +#define LAST_TASK task[NR_TASKS-1] + +#include <linux/head.h> +#include <linux/fs.h> +#include <linux/mm.h> +#include <linux/signal.h> +#include <linux/time.h> +#include <linux/param.h> +#include <linux/resource.h> +#include <linux/vm86.h> +#include <linux/math_emu.h> +#include <linux/ptrace.h> + +#define TASK_RUNNING 0 +#define TASK_INTERRUPTIBLE 1 +#define TASK_UNINTERRUPTIBLE 2 +#define TASK_ZOMBIE 3 +#define TASK_STOPPED 4 +#define TASK_SWAPPING 5 + +#ifndef NULL +#define NULL ((void *) 0) +#endif + +#ifdef __KERNEL__ + +extern void sched_init(void); +extern void show_state(void); +extern void trap_init(void); + +asmlinkage void schedule(void); + +#endif /* __KERNEL__ */ + +struct i387_hard_struct { + long cwd; + long swd; + long twd; + long fip; + long fcs; + long foo; + long fos; + long st_space[20]; /* 8*10 bytes for each FP-reg = 80 bytes */ +}; + +struct i387_soft_struct { + long cwd; + long swd; + long twd; + long fip; + long fcs; + long foo; + long fos; + long top; + struct fpu_reg regs[8]; /* 8*16 bytes for each FP-reg = 128 bytes */ + unsigned char lookahead; + struct info *info; + unsigned long entry_eip; +}; + +union i387_union { + struct i387_hard_struct hard; + struct i387_soft_struct soft; +}; + +struct tss_struct { + unsigned short back_link,__blh; + unsigned long esp0; + unsigned short ss0,__ss0h; + unsigned long esp1; + unsigned short ss1,__ss1h; + unsigned long esp2; + unsigned short ss2,__ss2h; + unsigned long cr3; + unsigned long eip; + unsigned long eflags; + unsigned long eax,ecx,edx,ebx; + unsigned long esp; + unsigned long ebp; + unsigned long esi; + unsigned long edi; + unsigned short es, __esh; + unsigned short cs, __csh; + unsigned short ss, __ssh; + unsigned short ds, __dsh; + unsigned short fs, __fsh; + unsigned short gs, __gsh; + unsigned short ldt, __ldth; + unsigned short trace, bitmap; + unsigned long io_bitmap[IO_BITMAP_SIZE+1]; + unsigned long tr; + unsigned long cr2, trap_no, error_code; + union i387_union i387; +}; + +#define INIT_TSS { \ + 0,0, \ + sizeof(init_kernel_stack) + (long) &init_kernel_stack, \ + KERNEL_DS, 0, \ + 0,0,0,0,0,0, \ + (long) &swapper_pg_dir, \ + 0,0,0,0,0,0,0,0,0,0, \ + USER_DS,0,USER_DS,0,USER_DS,0,USER_DS,0,USER_DS,0,USER_DS,0, \ + _LDT(0),0, \ + 0, 0x8000, \ + {~0, }, /* ioperm */ \ + _TSS(0), 0, 0,0, \ + { { 0, }, } /* 387 state */ \ +} + +struct files_struct { + int count; + fd_set close_on_exec; + struct file * fd[NR_OPEN]; +}; + +#define INIT_FILES { \ + 0, \ + { { 0, } }, \ + { NULL, } \ +} + +struct fs_struct { + int count; + unsigned short umask; + struct inode * root, * pwd; +}; + +#define INIT_FS { \ + 0, \ + 0022, \ + NULL, NULL \ +} + +struct mm_struct { + int count; + unsigned long start_code, end_code, end_data; + unsigned long start_brk, brk, start_stack, start_mmap; + unsigned long arg_start, arg_end, env_start, env_end; + unsigned long rss; + unsigned long min_flt, maj_flt, cmin_flt, cmaj_flt; + int swappable:1; + unsigned long swap_address; + unsigned long old_maj_flt; /* old value of maj_flt */ + unsigned long dec_flt; /* page fault count of the last time */ + unsigned long swap_cnt; /* number of pages to swap on next pass */ + struct vm_area_struct * mmap; +}; + +#define INIT_MMAP { &init_task, 0, 0x40000000, PAGE_SHARED, } + +#define INIT_MM { \ + 0, \ + 0, 0, 0, \ + 0, 0, 0, 0, \ + 0, 0, 0, 0, \ + 0, \ +/* ?_flt */ 0, 0, 0, 0, \ + 0, \ +/* swap */ 0, 0, 0, 0, \ + &init_mmap } + +struct task_struct { +/* these are hardcoded - don't touch */ + volatile long state; /* -1 unrunnable, 0 runnable, >0 stopped */ + long counter; + long priority; + unsigned long signal; + unsigned long blocked; /* bitmap of masked signals */ + unsigned long flags; /* per process flags, defined below */ + int errno; + int debugreg[8]; /* Hardware debugging registers */ + struct exec_domain *exec_domain; +/* various fields */ + struct linux_binfmt *binfmt; + struct task_struct *next_task, *prev_task; + struct sigaction sigaction[32]; + unsigned long saved_kernel_stack; + unsigned long kernel_stack_page; + int exit_code, exit_signal; + unsigned long personality; + int dumpable:1; + int did_exec:1; + int pid,pgrp,session,leader; + int groups[NGROUPS]; + /* + * pointers to (original) parent process, youngest child, younger sibling, + * older sibling, respectively. (p->father can be replaced with + * p->p_pptr->pid) + */ + struct task_struct *p_opptr, *p_pptr, *p_cptr, *p_ysptr, *p_osptr; + struct wait_queue *wait_chldexit; /* for wait4() */ + unsigned short uid,euid,suid,fsuid; + unsigned short gid,egid,sgid,fsgid; + unsigned long timeout; + unsigned long it_real_value, it_prof_value, it_virt_value; + unsigned long it_real_incr, it_prof_incr, it_virt_incr; + long utime, stime, cutime, cstime, start_time; + struct rlimit rlim[RLIM_NLIMITS]; + unsigned short used_math; + char comm[16]; +/* virtual 86 mode stuff */ + struct vm86_struct * vm86_info; + unsigned long screen_bitmap; + unsigned long v86flags, v86mask, v86mode; +/* file system info */ + int link_count; + struct tty_struct *tty; /* NULL if no tty */ +/* ipc stuff */ + struct sem_undo *semundo; +/* ldt for this task - used by Wine. If NULL, default_ldt is used */ + struct desc_struct *ldt; +/* tss for this task */ + struct tss_struct tss; +/* filesystem information */ + struct fs_struct fs[1]; +/* open file information */ + struct files_struct files[1]; +/* memory management info */ + struct mm_struct mm[1]; +}; + +/* + * Per process flags + */ +#define PF_ALIGNWARN 0x00000001 /* Print alignment warning msgs */ + /* Not implemented yet, only for 486*/ +#define PF_PTRACED 0x00000010 /* set if ptrace (0) has been called. */ +#define PF_TRACESYS 0x00000020 /* tracing system calls */ + +/* + * cloning flags: + */ +#define CSIGNAL 0x000000ff /* signal mask to be sent at exit */ +#define COPYVM 0x00000100 /* set if VM copy desired (like normal fork()) */ +#define COPYFD 0x00000200 /* set if fd's should be copied, not shared (NI) */ + +/* + * INIT_TASK is used to set up the first task table, touch at + * your own risk!. Base=0, limit=0x1fffff (=2MB) + */ +#define INIT_TASK \ +/* state etc */ { 0,15,15,0,0,0,0, \ +/* debugregs */ { 0, }, \ +/* exec domain */&default_exec_domain, \ +/* binfmt */ NULL, \ +/* schedlink */ &init_task,&init_task, \ +/* signals */ {{ 0, },}, \ +/* stack */ 0,(unsigned long) &init_kernel_stack, \ +/* ec,brk... */ 0,0,0,0,0, \ +/* pid etc.. */ 0,0,0,0, \ +/* suppl grps*/ {NOGROUP,}, \ +/* proc links*/ &init_task,&init_task,NULL,NULL,NULL,NULL, \ +/* uid etc */ 0,0,0,0,0,0,0,0, \ +/* timeout */ 0,0,0,0,0,0,0,0,0,0,0,0, \ +/* rlimits */ { {LONG_MAX, LONG_MAX}, {LONG_MAX, LONG_MAX}, \ + {LONG_MAX, LONG_MAX}, {LONG_MAX, LONG_MAX}, \ + { 0, LONG_MAX}, {LONG_MAX, LONG_MAX}}, \ +/* math */ 0, \ +/* comm */ "swapper", \ +/* vm86_info */ NULL, 0, 0, 0, 0, \ +/* fs info */ 0,NULL, \ +/* ipc */ NULL, \ +/* ldt */ NULL, \ +/* tss */ INIT_TSS, \ +/* fs */ { INIT_FS }, \ +/* files */ { INIT_FILES }, \ +/* mm */ { INIT_MM } \ +} + +#ifdef __KERNEL__ + +extern struct task_struct init_task; +extern struct task_struct *task[NR_TASKS]; +extern struct task_struct *last_task_used_math; +extern struct task_struct *current; +extern unsigned long volatile jiffies; +extern unsigned long itimer_ticks; +extern unsigned long itimer_next; +extern struct timeval xtime; +extern int need_resched; + +#define CURRENT_TIME (xtime.tv_sec) + +extern void sleep_on(struct wait_queue ** p); +extern void interruptible_sleep_on(struct wait_queue ** p); +extern void wake_up(struct wait_queue ** p); +extern void wake_up_interruptible(struct wait_queue ** p); + +extern void notify_parent(struct task_struct * tsk); +extern int send_sig(unsigned long sig,struct task_struct * p,int priv); +extern int in_group_p(gid_t grp); + +extern int request_irq(unsigned int irq,void (*handler)(int), unsigned long flags, const char *device); +extern void free_irq(unsigned int irq); + +/* + * Entry into gdt where to find first TSS. GDT layout: + * 0 - nul + * 1 - kernel code segment + * 2 - kernel data segment + * 3 - user code segment + * 4 - user data segment + * ... + * 8 - TSS #0 + * 9 - LDT #0 + * 10 - TSS #1 + * 11 - LDT #1 + */ +#define FIRST_TSS_ENTRY 8 +#define FIRST_LDT_ENTRY (FIRST_TSS_ENTRY+1) +#define _TSS(n) ((((unsigned long) n)<<4)+(FIRST_TSS_ENTRY<<3)) +#define _LDT(n) ((((unsigned long) n)<<4)+(FIRST_LDT_ENTRY<<3)) +#define load_TR(n) __asm__("ltr %%ax": /* no output */ :"a" (_TSS(n))) +#define load_ldt(n) __asm__("lldt %%ax": /* no output */ :"a" (_LDT(n))) +#define store_TR(n) \ +__asm__("str %%ax\n\t" \ + "subl %2,%%eax\n\t" \ + "shrl $4,%%eax" \ + :"=a" (n) \ + :"0" (0),"i" (FIRST_TSS_ENTRY<<3)) +/* + * switch_to(n) should switch tasks to task nr n, first + * checking that n isn't the current task, in which case it does nothing. + * This also clears the TS-flag if the task we switched to has used + * tha math co-processor latest. + */ +#define switch_to(tsk) \ +__asm__("cli\n\t" \ + "xchgl %%ecx,_current\n\t" \ + "ljmp %0\n\t" \ + "sti\n\t" \ + "cmpl %%ecx,_last_task_used_math\n\t" \ + "jne 1f\n\t" \ + "clts\n" \ + "1:" \ + : /* no output */ \ + :"m" (*(((char *)&tsk->tss.tr)-4)), \ + "c" (tsk) \ + :"cx") + +#define _set_base(addr,base) \ +__asm__("movw %%dx,%0\n\t" \ + "rorl $16,%%edx\n\t" \ + "movb %%dl,%1\n\t" \ + "movb %%dh,%2" \ + : /* no output */ \ + :"m" (*((addr)+2)), \ + "m" (*((addr)+4)), \ + "m" (*((addr)+7)), \ + "d" (base) \ + :"dx") + +#define _set_limit(addr,limit) \ +__asm__("movw %%dx,%0\n\t" \ + "rorl $16,%%edx\n\t" \ + "movb %1,%%dh\n\t" \ + "andb $0xf0,%%dh\n\t" \ + "orb %%dh,%%dl\n\t" \ + "movb %%dl,%1" \ + : /* no output */ \ + :"m" (*(addr)), \ + "m" (*((addr)+6)), \ + "d" (limit) \ + :"dx") + +#define set_base(ldt,base) _set_base( ((char *)&(ldt)) , base ) +#define set_limit(ldt,limit) _set_limit( ((char *)&(ldt)) , (limit-1)>>12 ) + +/* + * The wait-queues are circular lists, and you have to be *very* sure + * to keep them correct. Use only these two functions to add/remove + * entries in the queues. + */ +extern inline void add_wait_queue(struct wait_queue ** p, struct wait_queue * wait) +{ + unsigned long flags; + +#ifdef DEBUG + if (wait->next) { + unsigned long pc; + __asm__ __volatile__("call 1f\n" + "1:\tpopl %0":"=r" (pc)); + printk("add_wait_queue (%08x): wait->next = %08x\n",pc,(unsigned long) wait->next); + } +#endif + save_flags(flags); + cli(); + if (!*p) { + wait->next = wait; + *p = wait; + } else { + wait->next = (*p)->next; + (*p)->next = wait; + } + restore_flags(flags); +} + +extern inline void remove_wait_queue(struct wait_queue ** p, struct wait_queue * wait) +{ + unsigned long flags; + struct wait_queue * tmp; +#ifdef DEBUG + unsigned long ok = 0; +#endif + + save_flags(flags); + cli(); + if ((*p == wait) && +#ifdef DEBUG + (ok = 1) && +#endif + ((*p = wait->next) == wait)) { + *p = NULL; + } else { + tmp = wait; + while (tmp->next != wait) { + tmp = tmp->next; +#ifdef DEBUG + if (tmp == *p) + ok = 1; +#endif + } + tmp->next = wait->next; + } + wait->next = NULL; + restore_flags(flags); +#ifdef DEBUG + if (!ok) { + printk("removed wait_queue not on list.\n"); + printk("list = %08x, queue = %08x\n",(unsigned long) p, (unsigned long) wait); + __asm__("call 1f\n1:\tpopl %0":"=r" (ok)); + printk("eip = %08x\n",ok); + } +#endif +} + +extern inline void select_wait(struct wait_queue ** wait_address, select_table * p) +{ + struct select_table_entry * entry; + + if (!p || !wait_address) + return; + if (p->nr >= __MAX_SELECT_TABLE_ENTRIES) + return; + entry = p->entry + p->nr; + entry->wait_address = wait_address; + entry->wait.task = current; + entry->wait.next = NULL; + add_wait_queue(wait_address,&entry->wait); + p->nr++; +} + +extern void __down(struct semaphore * sem); + +/* + * These are not yet interrupt-safe + */ +extern inline void down(struct semaphore * sem) +{ + if (sem->count <= 0) + __down(sem); + sem->count--; +} + +extern inline void up(struct semaphore * sem) +{ + sem->count++; + wake_up(&sem->wait); +} + +static inline unsigned long _get_base(char * addr) +{ + unsigned long __base; + __asm__("movb %3,%%dh\n\t" + "movb %2,%%dl\n\t" + "shll $16,%%edx\n\t" + "movw %1,%%dx" + :"=&d" (__base) + :"m" (*((addr)+2)), + "m" (*((addr)+4)), + "m" (*((addr)+7))); + return __base; +} + +#define get_base(ldt) _get_base( ((char *)&(ldt)) ) + +static inline unsigned long get_limit(unsigned long segment) +{ + unsigned long __limit; + __asm__("lsll %1,%0" + :"=r" (__limit):"r" (segment)); + return __limit+1; +} + +#define REMOVE_LINKS(p) do { unsigned long flags; \ + save_flags(flags) ; cli(); \ + (p)->next_task->prev_task = (p)->prev_task; \ + (p)->prev_task->next_task = (p)->next_task; \ + restore_flags(flags); \ + if ((p)->p_osptr) \ + (p)->p_osptr->p_ysptr = (p)->p_ysptr; \ + if ((p)->p_ysptr) \ + (p)->p_ysptr->p_osptr = (p)->p_osptr; \ + else \ + (p)->p_pptr->p_cptr = (p)->p_osptr; \ + } while (0) + +#define SET_LINKS(p) do { unsigned long flags; \ + save_flags(flags); cli(); \ + (p)->next_task = &init_task; \ + (p)->prev_task = init_task.prev_task; \ + init_task.prev_task->next_task = (p); \ + init_task.prev_task = (p); \ + restore_flags(flags); \ + (p)->p_ysptr = NULL; \ + if (((p)->p_osptr = (p)->p_pptr->p_cptr) != NULL) \ + (p)->p_osptr->p_ysptr = p; \ + (p)->p_pptr->p_cptr = p; \ + } while (0) + +#define for_each_task(p) \ + for (p = &init_task ; (p = p->next_task) != &init_task ; ) + +/* + * This is the ldt that every process will get unless we need + * something other than this. + */ +extern struct desc_struct default_ldt; + +/* This special macro can be used to load a debugging register */ + +#define loaddebug(register) \ + __asm__("movl %0,%%edx\n\t" \ + "movl %%edx,%%db" #register "\n\t" \ + : /* no output */ \ + :"m" (current->debugreg[register]) \ + :"dx"); + +#endif /* __KERNEL__ */ + +#endif diff --git a/include/linux/scsicam.h b/include/linux/scsicam.h new file mode 100644 index 000000000..d78dc71c4 --- /dev/null +++ b/include/linux/scsicam.h @@ -0,0 +1,16 @@ +/* + * scsicam.h - SCSI CAM support functions, use for HDIO_GETGEO, etc. + * + * Copyright 1993, 1994 Drew Eckhardt + * Visionary Computing + * (Unix and Linux consulting and custom programming) + * drew@Colorado.EDU + * +1 (303) 786-7975 + * + * For more information, please consult the SCSI-CAM draft. + */ + +#ifndef SCSICAM_H +#define SCSICAM_H +extern int scsicam_bios_param (Disk *disk, int dev, int *ip); +#endif /* def SCSICAM_H */ diff --git a/include/linux/sem.h b/include/linux/sem.h new file mode 100644 index 000000000..52189879b --- /dev/null +++ b/include/linux/sem.h @@ -0,0 +1,97 @@ +#ifndef _LINUX_SEM_H +#define _LINUX_SEM_H +#include <linux/ipc.h> + +/* semop flags */ +#define SEM_UNDO 010000 /* undo the operation on exit */ + +/* semctl Command Definitions. */ +#define GETPID 11 /* get sempid */ +#define GETVAL 12 /* get semval */ +#define GETALL 13 /* get all semval's */ +#define GETNCNT 14 /* get semncnt */ +#define GETZCNT 15 /* get semzcnt */ +#define SETVAL 16 /* set semval */ +#define SETALL 17 /* set all semval's */ + +/* One semid data structure for each set of semaphores in the system. */ +struct semid_ds { + struct ipc_perm sem_perm; /* permissions .. see ipc.h */ + time_t sem_otime; /* last semop time */ + time_t sem_ctime; /* last change time */ + struct sem *sem_base; /* ptr to first semaphore in array */ + struct wait_queue *eventn; + struct wait_queue *eventz; + struct sem_undo *undo; /* undo requests on this array */ + ushort sem_nsems; /* no. of semaphores in array */ +}; + +/* semop system calls takes an array of these. */ +struct sembuf { + ushort sem_num; /* semaphore index in array */ + short sem_op; /* semaphore operation */ + short sem_flg; /* operation flags */ +}; + +/* arg for semctl system calls. */ +union semun { + int val; /* value for SETVAL */ + struct semid_ds *buf; /* buffer for IPC_STAT & IPC_SET */ + ushort *array; /* array for GETALL & SETALL */ + struct seminfo *__buf; /* buffer for IPC_INFO */ + void *__pad; +}; + +struct seminfo { + int semmap; + int semmni; + int semmns; + int semmnu; + int semmsl; + int semopm; + int semume; + int semusz; + int semvmx; + int semaem; +}; + +#define SEMMNI 128 /* ? max # of semaphore identifiers */ +#define SEMMSL 32 /* <= 512 max num of semaphores per id */ +#define SEMMNS (SEMMNI*SEMMSL) /* ? max # of semaphores in system */ +#define SEMOPM 32 /* ~ 100 max num of ops per semop call */ +#define SEMVMX 32767 /* semaphore maximum value */ + +/* unused */ +#define SEMUME SEMOPM /* max num of undo entries per process */ +#define SEMMNU SEMMNS /* num of undo structures system wide */ +#define SEMAEM (SEMVMX >> 1) /* adjust on exit max value */ +#define SEMMAP SEMMNS /* # of entries in semaphore map */ +#define SEMUSZ 20 /* sizeof struct sem_undo */ + +#ifdef __KERNEL__ + +/* One semaphore structure for each semaphore in the system. */ +struct sem { + short sempid; /* pid of last operation */ + ushort semval; /* current value */ + ushort semncnt; /* num procs awaiting increase in semval */ + ushort semzcnt; /* num procs awaiting semval = 0 */ +}; + +/* ipcs ctl cmds */ +#define SEM_STAT 18 +#define SEM_INFO 19 + +/* per process undo requests */ +/* this gets linked into the task_struct */ +struct sem_undo { + struct sem_undo *proc_next; + struct sem_undo *id_next; + int semid; + short semadj; /* semval adjusted by exit */ + ushort sem_num; /* semaphore index in array semid */ +}; + +#endif /* __KERNEL__ */ + +#endif /* _LINUX_SEM_H */ diff --git a/include/linux/serial.h b/include/linux/serial.h new file mode 100644 index 000000000..1877f42b2 --- /dev/null +++ b/include/linux/serial.h @@ -0,0 +1,139 @@ +/* + * include/linux/serial.h + * + * Copyright (C) 1992 by Theodore Ts'o. + * + * Redistribution of this file is permitted under the terms of the GNU + * Public License (GPL) + */ + +#ifndef _LINUX_SERIAL_H +#define _LINUX_SERIAL_H + +struct serial_struct { + int type; + int line; + int port; + int irq; + int flags; + int xmit_fifo_size; + int custom_divisor; + int baud_base; + unsigned short close_delay; + char reserved_char[2]; + int hub6; + int reserved[5]; +}; + +/* + * These are the supported serial types. + */ +#define PORT_UNKNOWN 0 +#define PORT_8250 1 +#define PORT_16450 2 +#define PORT_16550 3 +#define PORT_16550A 4 +#define PORT_MAX 4 + +/* + * Definitions for async_struct (and serial_struct) flags field + */ +#define ASYNC_HUP_NOTIFY 0x0001 /* Notify getty on hangups and closes + on the callout port */ +#define ASYNC_FOURPORT 0x0002 /* Set OU1, OUT2 per AST Fourport settings */ +#define ASYNC_SAK 0x0004 /* Secure Attention Key (Orange book) */ +#define ASYNC_SPLIT_TERMIOS 0x0008 /* Separate termios for dialin/callout */ + +#define ASYNC_SPD_MASK 0x0030 +#define ASYNC_SPD_HI 0x0010 /* Use 56000 instead of 38400 bps */ + +#define ASYNC_SPD_VHI 0x0020 /* Use 115200 instead of 38400 bps */ +#define ASYNC_SPD_CUST 0x0030 /* Use user-specified divisor */ + +#define ASYNC_SKIP_TEST 0x0040 /* Skip UART test during autoconfiguration */ +#define ASYNC_AUTO_IRQ 0x0080 /* Do automatic IRQ during autoconfiguration */ +#define ASYNC_SESSION_LOCKOUT 0x0100 /* Lock out cua opens based on session */ +#define ASYNC_PGRP_LOCKOUT 0x0200 /* Lock out cua opens based on pgrp */ +#define ASYNC_CALLOUT_NOHUP 0x0400 /* Don't do hangups for cua device */ + +#define ASYNC_FLAGS 0x0FFF /* Possible legal async flags */ +#define ASYNC_USR_MASK 0x0430 /* Legal flags that non-privileged + * users can set or reset */ + +/* Internal flags used only by kernel/chr_drv/serial.c */ +#define ASYNC_INITIALIZED 0x80000000 /* Serial port was initialized */ +#define ASYNC_CALLOUT_ACTIVE 0x40000000 /* Call out device is active */ +#define ASYNC_NORMAL_ACTIVE 0x20000000 /* Normal device is active */ +#define ASYNC_BOOT_AUTOCONF 0x10000000 /* Autoconfigure port on bootup */ +#define ASYNC_CLOSING 0x08000000 /* Serial port is closing */ +#define ASYNC_CTS_FLOW 0x04000000 /* Do CTS flow control */ +#define ASYNC_CHECK_CD 0x02000000 /* i.e., CLOCAL */ + +#ifdef __KERNEL__ +/* + * This is our internal structure for each serial port's state. + * + * Many fields are paralleled by the structure used by the serial_struct + * structure. + * + * For definitions of the flags field, see tty.h + */ + +struct async_struct { + int magic; + int baud_base; + int port; + int irq; + int flags; /* defined in tty.h */ + int hub6; /* HUB6 plus one */ + int type; /* UART type */ + struct tty_struct *tty; + int read_status_mask; + int ignore_status_mask; + int timeout; + int xmit_fifo_size; + int custom_divisor; + int x_char; /* xon/xoff character */ + int close_delay; + int IER; /* Interrupt Enable Register */ + int MCR; /* Modem control register */ + int MCR_noint; /* MCR with interrupts off */ + int event; + unsigned long last_active; + int line; + int count; /* # of fd on device */ + int blocked_open; /* # of blocked opens */ + long session; /* Session of opening process */ + long pgrp; /* pgrp of opening process */ + unsigned char *xmit_buf; + int xmit_head; + int xmit_tail; + int xmit_cnt; + struct tq_struct tqueue; + struct termios normal_termios; + struct termios callout_termios; + struct wait_queue *open_wait; + struct wait_queue *close_wait; + struct async_struct *next_port; /* For the linked list */ + struct async_struct *prev_port; +}; + +#define SERIAL_MAGIC 0x5301 + +/* + * The size of the serial xmit buffer is 1 page, or 4096 bytes + */ +#define SERIAL_XMIT_SIZE 4096 + +/* + * Events are used to schedule things to happen at timer-interrupt + * time, instead of at rs interrupt time. + */ +#define RS_EVENT_WRITE_WAKEUP 0 +#define RS_EVENT_HANGUP 1 + +/* Export to allow PCMCIA to use this - Dave Hinds */ +extern int register_serial(struct serial_struct *req); +extern void unregister_serial(int line); +#endif /* __KERNEL__ */ +#endif /* _LINUX_SERIAL_H */ diff --git a/include/linux/serial_reg.h b/include/linux/serial_reg.h new file mode 100644 index 000000000..5e983fc1c --- /dev/null +++ b/include/linux/serial_reg.h @@ -0,0 +1,113 @@ +/* + * include/linux/serial.h + * + * Copyright (C) 1992, 1994 by Theodore Ts'o. + * + * Redistribution of this file is permitted under the terms of the GNU + * Public License (GPL) + * + * These are the UART port assignments, expressed as offsets from the base + * register. These assignments should hold for any serial port based on + * a 8250, 16450, or 16550(A). + */ + +#ifndef _LINUX_SERIAL_REG_H +#define _LINUX_SERIAL_REG_H + +#define UART_RX 0 /* In: Receive buffer (DLAB=0) */ +#define UART_TX 0 /* Out: Transmit buffer (DLAB=0) */ +#define UART_DLL 0 /* Out: Divisor Latch Low (DLAB=1) */ +#define UART_DLM 1 /* Out: Divisor Latch High (DLAB=1) */ +#define UART_IER 1 /* Out: Interrupt Enable Register */ +#define UART_IIR 2 /* In: Interrupt ID Register */ +#define UART_FCR 2 /* Out: FIFO Control Register */ +#define UART_LCR 3 /* Out: Line Control Register */ +#define UART_MCR 4 /* Out: Modem Control Register */ +#define UART_LSR 5 /* In: Line Status Register */ +#define UART_MSR 6 /* In: Modem Status Register */ +#define UART_SCR 7 /* I/O: Scratch Register */ + +/* + * These are the definitions for the FIFO Control Register + */ +#define UART_FCR_ENABLE_FIFO 0x01 /* Enable the FIFO */ +#define UART_FCR_CLEAR_RCVR 0x02 /* Clear the RCVR FIFO */ +#define UART_FCR_CLEAR_XMIT 0x04 /* Clear the XMIT FIFO */ +#define UART_FCR_DMA_SELECT 0x08 /* For DMA applications */ +#define UART_FCR_TRIGGER_MASK 0xC0 /* Mask for the FIFO trigger range */ +#define UART_FCR_TRIGGER_1 0x00 /* Mask for trigger set at 1 */ +#define UART_FCR_TRIGGER_4 0x40 /* Mask for trigger set at 4 */ +#define UART_FCR_TRIGGER_8 0x80 /* Mask for trigger set at 8 */ +#define UART_FCR_TRIGGER_14 0xC0 /* Mask for trigger set at 14 */ + +/* + * These are the definitions for the Line Control Register + * + * Note: if the word length is 5 bits (UART_LCR_WLEN5), then setting + * UART_LCR_STOP will select 1.5 stop bits, not 2 stop bits. + */ +#define UART_LCR_DLAB 0x80 /* Divisor latch access bit */ +#define UART_LCR_SBC 0x40 /* Set break control */ +#define UART_LCR_SPAR 0x20 /* Stick parity (?) */ +#define UART_LCR_EPAR 0x10 /* Even parity select */ +#define UART_LCR_PARITY 0x08 /* Parity Enable */ +#define UART_LCR_STOP 0x04 /* Stop bits: 0=1 stop bit, 1= 2 stop bits */ +#define UART_LCR_WLEN5 0x00 /* Wordlength: 5 bits */ +#define UART_LCR_WLEN6 0x01 /* Wordlength: 6 bits */ +#define UART_LCR_WLEN7 0x02 /* Wordlength: 7 bits */ +#define UART_LCR_WLEN8 0x03 /* Wordlength: 8 bits */ + +/* + * These are the definitions for the Line Status Register + */ +#define UART_LSR_TEMT 0x40 /* Transmitter empty */ +#define UART_LSR_THRE 0x20 /* Transmit-hold-register empty */ +#define UART_LSR_BI 0x10 /* Break interrupt indicator */ +#define UART_LSR_FE 0x08 /* Frame error indicator */ +#define UART_LSR_PE 0x04 /* Parity error indicator */ +#define UART_LSR_OE 0x02 /* Overrun error indicator */ +#define UART_LSR_DR 0x01 /* Receiver data ready */ + +/* + * These are the definitions for the Interrupt Identification Register + */ +#define UART_IIR_NO_INT 0x01 /* No interrupts pending */ +#define UART_IIR_ID 0x06 /* Mask for the interrupt ID */ + +#define UART_IIR_MSI 0x00 /* Modem status interrupt */ +#define UART_IIR_THRI 0x02 /* Transmitter holding register empty */ +#define UART_IIR_RDI 0x04 /* Receiver data interrupt */ +#define UART_IIR_RLSI 0x06 /* Receiver line status interrupt */ + +/* + * These are the definitions for the Interrupt Enable Register + */ +#define UART_IER_MSI 0x08 /* Enable Modem status interrupt */ +#define UART_IER_RLSI 0x04 /* Enable receiver line status interrupt */ +#define UART_IER_THRI 0x02 /* Enable Transmitter holding register int. */ +#define UART_IER_RDI 0x01 /* Enable receiver data interrupt */ + +/* + * These are the definitions for the Modem Control Register + */ +#define UART_MCR_LOOP 0x10 /* Enable loopback test mode */ +#define UART_MCR_OUT2 0x08 /* Out2 complement */ +#define UART_MCR_OUT1 0x04 /* Out1 complement */ +#define UART_MCR_RTS 0x02 /* RTS complement */ +#define UART_MCR_DTR 0x01 /* DTR complement */ + +/* + * These are the definitions for the Modem Status Register + */ +#define UART_MSR_DCD 0x80 /* Data Carrier Detect */ +#define UART_MSR_RI 0x40 /* Ring Indicator */ +#define UART_MSR_DSR 0x20 /* Data Set Ready */ +#define UART_MSR_CTS 0x10 /* Clear to Send */ +#define UART_MSR_DDCD 0x08 /* Delta DCD */ +#define UART_MSR_TERI 0x04 /* Trailing edge ring indicator */ +#define UART_MSR_DDSR 0x02 /* Delta DSR */ +#define UART_MSR_DCTS 0x01 /* Delta CTS */ +#define UART_MSR_ANY_DELTA 0x0F /* Any of the delta bits! */ + +#endif /* _LINUX_SERIAL_REG_H */ + diff --git a/include/linux/shm.h b/include/linux/shm.h new file mode 100644 index 000000000..c8e391906 --- /dev/null +++ b/include/linux/shm.h @@ -0,0 +1,99 @@ +#ifndef _LINUX_SHM_H_ +#define _LINUX_SHM_H_ +#include <linux/ipc.h> + +struct shmid_ds { + struct ipc_perm shm_perm; /* operation perms */ + int shm_segsz; /* size of segment (bytes) */ + time_t shm_atime; /* last attach time */ + time_t shm_dtime; /* last detach time */ + time_t shm_ctime; /* last change time */ + unsigned short shm_cpid; /* pid of creator */ + unsigned short shm_lpid; /* pid of last operator */ + short shm_nattch; /* no. of current attaches */ + /* the following are private */ + unsigned short shm_npages; /* size of segment (pages) */ + unsigned long *shm_pages; /* array of ptrs to frames -> SHMMAX */ + struct vm_area_struct *attaches; /* descriptors for attaches */ +}; + +/* permission flag for shmget */ +#define SHM_R 0400 /* or S_IRUGO from <linux/stat.h> */ +#define SHM_W 0200 /* or S_IWUGO from <linux/stat.h> */ + +/* mode for attach */ +#define SHM_RDONLY 010000 /* read-only access */ +#define SHM_RND 020000 /* round attach address to SHMLBA boundary */ +#define SHM_REMAP 040000 /* take-over region on attach */ + +/* super user shmctl commands */ +#define SHM_LOCK 11 +#define SHM_UNLOCK 12 + +struct shminfo { + int shmmax; + int shmmin; + int shmmni; + int shmseg; + int shmall; +}; + +/* address range for shared memory attaches if no address passed to shmat() */ +#define SHM_RANGE_START 0x50000000 +#define SHM_RANGE_END 0x60000000 + +/* format of page table entries that correspond to shared memory pages + currently out in swap space (see also mm/swap.c): + bit 0 (PAGE_PRESENT) is = 0 + bits 7..1 (SWP_TYPE) are = SHM_SWP_TYPE + bits 31..8 are used like this: + bits 14..8 (SHM_ID) the id of the shared memory segment + bits 29..15 (SHM_IDX) the index of the page within the shared memory segment + (actually only bits 24..15 get used since SHMMAX is so low) + bit 31 (SHM_READ_ONLY) flag whether the page belongs to a read-only attach +*/ + +#define SHM_ID_SHIFT 8 +/* Keep _SHM_ID_BITS as low as possible since SHMMNI depends on it and + there is a static array of size SHMMNI. */ +#define _SHM_ID_BITS 7 +#define SHM_ID_MASK ((1<<_SHM_ID_BITS)-1) + +#define SHM_IDX_SHIFT (SHM_ID_SHIFT+_SHM_ID_BITS) +#define _SHM_IDX_BITS 15 +#define SHM_IDX_MASK ((1<<_SHM_IDX_BITS)-1) + +#define SHM_READ_ONLY (1<<31) + +/* We must have SHM_ID_SHIFT + _SHM_ID_BITS + _SHM_IDX_BITS + 1 <= 32 + and SHMMAX <= (PAGE_SIZE << _SHM_IDX_BITS). */ + +#define SHMMAX 0x3fa000 /* max shared seg size (bytes) */ +#define SHMMIN 1 /* really PAGE_SIZE */ /* min shared seg size (bytes) */ +#define SHMMNI (1<<_SHM_ID_BITS) /* max num of segs system wide */ +#define SHMALL (1<<(_SHM_IDX_BITS+_SHM_ID_BITS))/* max shm system wide (pages) */ +#define SHMLBA 0x1000 /* attach addr a multiple of this */ +#define SHMSEG SHMMNI /* max shared segs per process */ + +#ifdef __KERNEL__ + +/* shm_mode upper byte flags */ +#define SHM_DEST 01000 /* segment will be destroyed on last detach */ +#define SHM_LOCKED 02000 /* segment will not be swapped */ + +/* ipcs ctl commands */ +#define SHM_STAT 13 +#define SHM_INFO 14 +struct shm_info { + int used_ids; + ulong shm_tot; /* total allocated shm */ + ulong shm_rss; /* total resident shm */ + ulong shm_swp; /* total swapped shm */ + ulong swap_attempts; + ulong swap_successes; +}; + +#endif /* __KERNEL__ */ + +#endif /* _LINUX_SHM_H_ */ + diff --git a/include/linux/signal.h b/include/linux/signal.h new file mode 100644 index 000000000..ed625098f --- /dev/null +++ b/include/linux/signal.h @@ -0,0 +1,108 @@ +#ifndef _LINUX_SIGNAL_H +#define _LINUX_SIGNAL_H + +typedef unsigned int sigset_t; /* 32 bits */ + +#define _NSIG 32 +#define NSIG _NSIG + +#define SIGHUP 1 +#define SIGINT 2 +#define SIGQUIT 3 +#define SIGILL 4 +#define SIGTRAP 5 +#define SIGABRT 6 +#define SIGIOT 6 +#define SIGBUS 7 +#define SIGFPE 8 +#define SIGKILL 9 +#define SIGUSR1 10 +#define SIGSEGV 11 +#define SIGUSR2 12 +#define SIGPIPE 13 +#define SIGALRM 14 +#define SIGTERM 15 +#define SIGSTKFLT 16 +#define SIGCHLD 17 +#define SIGCONT 18 +#define SIGSTOP 19 +#define SIGTSTP 20 +#define SIGTTIN 21 +#define SIGTTOU 22 +#define SIGIO 23 +#define SIGPOLL SIGIO +#define SIGURG SIGIO +#define SIGXCPU 24 +#define SIGXFSZ 25 +#define SIGVTALRM 26 +#define SIGPROF 27 +#define SIGWINCH 28 +/* +#define SIGLOST 29 +*/ +#define SIGPWR 30 +#define SIGUNUSED 31 + +/* + * sa_flags values: SA_STACK is not currently supported, but will allow the + * usage of signal stacks by using the (now obsolete) sa_restorer field in + * the sigaction structure as a stack pointer. This is now possible due to + * the changes in signal handling. LBT 010493. + * SA_INTERRUPT is a no-op, but left due to historical reasons. Use the + * SA_RESTART flag to get restarting signals (which were the default long ago) + */ +#define SA_NOCLDSTOP 1 +#define SA_STACK 0x08000000 +#define SA_RESTART 0x10000000 +#define SA_INTERRUPT 0x20000000 +#define SA_NOMASK 0x40000000 +#define SA_ONESHOT 0x80000000 + +#define SIG_BLOCK 0 /* for blocking signals */ +#define SIG_UNBLOCK 1 /* for unblocking signals */ +#define SIG_SETMASK 2 /* for setting the signal mask */ + +/* Type of a signal handler. */ +typedef void (*__sighandler_t)(int); + +#define SIG_DFL ((__sighandler_t)0) /* default signal handling */ +#define SIG_IGN ((__sighandler_t)1) /* ignore signal */ +#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */ + +struct sigaction { + __sighandler_t sa_handler; + sigset_t sa_mask; + int sa_flags; + void (*sa_restorer)(void); +}; + +#ifdef __KERNEL__ + +struct sigcontext_struct { + unsigned short gs, __gsh; + unsigned short fs, __fsh; + unsigned short es, __esh; + unsigned short ds, __dsh; + unsigned long edi; + unsigned long esi; + unsigned long ebp; + unsigned long esp; + unsigned long ebx; + unsigned long edx; + unsigned long ecx; + unsigned long eax; + unsigned long trapno; + unsigned long err; + unsigned long eip; + unsigned short cs, __csh; + unsigned long eflags; + unsigned long esp_at_signal; + unsigned short ss, __ssh; + unsigned long i387; + unsigned long oldmask; + unsigned long cr2; +}; + +#endif + +#endif diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h new file mode 100644 index 000000000..fca7ba7cd --- /dev/null +++ b/include/linux/skbuff.h @@ -0,0 +1,144 @@ +/* + * Definitions for the 'struct sk_buff' memory handlers. + * + * Authors: + * Alan Cox, <gw4pts@gw4pts.ampr.org> + * Florian La Roche, <rzsfl@rz.uni-sb.de> + * + * 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. + */ + +#ifndef _LINUX_SKBUFF_H +#define _LINUX_SKBUFF_H +#include <linux/malloc.h> +#include <linux/wait.h> +#include <linux/time.h> + +#define CONFIG_SKB_CHECK 1 + +#define HAVE_ALLOC_SKB /* For the drivers to know */ + + +#define FREE_READ 1 +#define FREE_WRITE 0 + + +struct sk_buff_head { + struct sk_buff * volatile next; + struct sk_buff * volatile prev; +#if CONFIG_SKB_CHECK + int magic_debug_cookie; +#endif +}; + + +struct sk_buff { + struct sk_buff * volatile next; + struct sk_buff * volatile prev; +#if CONFIG_SKB_CHECK + int magic_debug_cookie; +#endif + struct sk_buff * volatile link3; + struct sock *sk; + volatile unsigned long when; /* used to compute rtt's */ + struct timeval stamp; + struct device *dev; + struct sk_buff *mem_addr; + union { + struct tcphdr *th; + struct ethhdr *eth; + struct iphdr *iph; + struct udphdr *uh; + unsigned char *raw; + unsigned long seq; + } h; + struct iphdr *ip_hdr; /* For IPPROTO_RAW */ + unsigned long mem_len; + unsigned long len; + unsigned long fraglen; + struct sk_buff *fraglist; /* Fragment list */ + unsigned long truesize; + unsigned long saddr; + unsigned long daddr; + unsigned long raddr; /* next hop addr */ + volatile char acked, + used, + free, + arp; + unsigned char tries,lock,localroute,pkt_type; +#define PACKET_HOST 0 /* To us */ +#define PACKET_BROADCAST 1 +#define PACKET_MULTICAST 2 +#define PACKET_OTHERHOST 3 /* Unmatched promiscuous */ + unsigned short users; /* User count - see datagram.c (and soon seqpacket.c/stream.c) */ +#ifdef CONFIG_SLAVE_BALANCING + unsigned short in_dev_queue; +#endif + unsigned long padding[0]; + unsigned char data[0]; +}; + +#define SK_WMEM_MAX 32767 +#define SK_RMEM_MAX 32767 + +#ifdef CONFIG_SKB_CHECK +#define SK_FREED_SKB 0x0DE2C0DE +#define SK_GOOD_SKB 0xDEC0DED1 +#define SK_HEAD_SKB 0x12231298 +#endif + +#ifdef __KERNEL__ +/* + * Handling routines are only of interest to the kernel + */ + +#if 0 +extern void print_skb(struct sk_buff *); +#endif +extern void kfree_skb(struct sk_buff *skb, int rw); +extern void skb_queue_head_init(struct sk_buff_head *list); +extern void skb_queue_head(struct sk_buff_head *list,struct sk_buff *buf); +extern void skb_queue_tail(struct sk_buff_head *list,struct sk_buff *buf); +extern struct sk_buff * skb_dequeue(struct sk_buff_head *list); +extern void skb_insert(struct sk_buff *old,struct sk_buff *newsk); +extern void skb_append(struct sk_buff *old,struct sk_buff *newsk); +extern void skb_unlink(struct sk_buff *buf); +extern struct sk_buff * skb_peek_copy(struct sk_buff_head *list); +extern struct sk_buff * alloc_skb(unsigned int size, int priority); +extern void kfree_skbmem(struct sk_buff *skb, unsigned size); +extern struct sk_buff * skb_clone(struct sk_buff *skb, int priority); +extern void skb_device_lock(struct sk_buff *skb); +extern void skb_device_unlock(struct sk_buff *skb); +extern void dev_kfree_skb(struct sk_buff *skb, int mode); +extern int skb_device_locked(struct sk_buff *skb); +/* + * Peek an sk_buff. Unlike most other operations you _MUST_ + * be careful with this one. A peek leaves the buffer on the + * list and someone else may run off with it. For an interrupt + * type system cli() peek the buffer copy the data and sti(); + */ +static __inline__ struct sk_buff *skb_peek(struct sk_buff_head *list_) +{ + struct sk_buff *list = (struct sk_buff *)list_; + return (list->next != list)? list->next : NULL; +} + +#if CONFIG_SKB_CHECK +extern int skb_check(struct sk_buff *skb,int,int, char *); +#define IS_SKB(skb) skb_check((skb), 0, __LINE__,__FILE__) +#define IS_SKB_HEAD(skb) skb_check((skb), 1, __LINE__,__FILE__) +#else +#define IS_SKB(skb) 0 +#define IS_SKB_HEAD(skb) 0 +#endif + +extern struct sk_buff * skb_recv_datagram(struct sock *sk,unsigned flags,int noblock, int *err); +extern int datagram_select(struct sock *sk, int sel_type, select_table *wait); +extern void skb_copy_datagram(struct sk_buff *from, int offset, char *to,int size); +extern void skb_free_datagram(struct sk_buff *skb); + +#endif /* __KERNEL__ */ +#endif /* _LINUX_SKBUFF_H */ diff --git a/include/linux/socket.h b/include/linux/socket.h new file mode 100644 index 000000000..224880172 --- /dev/null +++ b/include/linux/socket.h @@ -0,0 +1,93 @@ +#ifndef _LINUX_SOCKET_H +#define _LINUX_SOCKET_H + +#include <linux/sockios.h> /* the SIOCxxx I/O controls */ + + +struct sockaddr { + unsigned short sa_family; /* address family, AF_xxx */ + char sa_data[14]; /* 14 bytes of protocol address */ +}; + +struct linger { + int l_onoff; /* Linger active */ + int l_linger; /* How long to linger for */ +}; + +/* Socket types. */ +#define SOCK_STREAM 1 /* stream (connection) socket */ +#define SOCK_DGRAM 2 /* datagram (conn.less) socket */ +#define SOCK_RAW 3 /* raw socket */ +#define SOCK_RDM 4 /* reliably-delivered message */ +#define SOCK_SEQPACKET 5 /* sequential packet socket */ +#define SOCK_PACKET 10 /* linux specific way of */ + /* getting packets at the dev */ + /* level. For writing rarp and */ + /* other similar things on the */ + /* user level. */ + +/* Supported address families. */ +#define AF_UNSPEC 0 +#define AF_UNIX 1 +#define AF_INET 2 +#define AF_AX25 3 +#define AF_IPX 4 + +#define AF_MAX 8 /* For now.. */ + +/* Protocol families, same as address families. */ +#define PF_UNSPEC AF_UNSPEC +#define PF_UNIX AF_UNIX +#define PF_INET AF_INET +#define PF_AX25 AF_AX25 +#define PF_IPX AF_IPX + +#define PF_MAX AF_MAX +/* Flags we can use with send/ and recv. */ +#define MSG_OOB 1 +#define MSG_PEEK 2 +#define MSG_DONTROUTE 4 + +/* Setsockoptions(2) level. Thanks to BSD these must match IPPROTO_xxx */ +#define SOL_SOCKET 1 +#define SOL_IP 0 +#define SOL_IPX 256 +#define SOL_AX25 257 +#define SOL_TCP 6 +#define SOL_UDP 17 + +/* For setsockoptions(2) */ +#define SO_DEBUG 1 +#define SO_REUSEADDR 2 +#define SO_TYPE 3 +#define SO_ERROR 4 +#define SO_DONTROUTE 5 +#define SO_BROADCAST 6 +#define SO_SNDBUF 7 +#define SO_RCVBUF 8 +#define SO_KEEPALIVE 9 +#define SO_OOBINLINE 10 +#define SO_NO_CHECK 11 +#define SO_PRIORITY 12 +#define SO_LINGER 13 + +/* IP options */ +#define IP_TOS 1 +#define IPTOS_LOWDELAY 0x10 +#define IPTOS_THROUGHPUT 0x08 +#define IPTOS_RELIABILITY 0x04 +#define IP_TTL 2 + +/* IPX options */ +#define IPX_TYPE 1 + +/* TCP options - this way around because someone left a set in the c library includes */ +#define TCP_NODELAY 1 +#define TCP_MAXSEG 2 + +/* The various priorities. */ +#define SOPRI_INTERACTIVE 0 +#define SOPRI_NORMAL 1 +#define SOPRI_BACKGROUND 2 + +#endif /* _LINUX_SOCKET_H */ diff --git a/include/linux/sockios.h b/include/linux/sockios.h new file mode 100644 index 000000000..f4161494d --- /dev/null +++ b/include/linux/sockios.h @@ -0,0 +1,94 @@ +/* + * INET An implementation of the TCP/IP protocol suite for the LINUX + * operating system. INET is implemented using the BSD Socket + * interface as the means of communication with the user level. + * + * Definitions of the socket-level I/O control calls. + * + * Version: @(#)sockios.h 1.0.2 03/09/93 + * + * Authors: Ross Biro, <bir7@leland.Stanford.Edu> + * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> + * + * 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. + */ +#ifndef _LINUX_SOCKIOS_H +#define _LINUX_SOCKIOS_H + +/* This section will go away soon! */ + +/* Socket-level I/O control calls. */ +#define FIOSETOWN 0x8901 +#define SIOCSPGRP 0x8902 +#define FIOGETOWN 0x8903 +#define SIOCGPGRP 0x8904 +#define SIOCATMARK 0x8905 +#define SIOCGSTAMP 0x8906 /* Get stamp */ + +/* Routing table calls. */ +#define SIOCADDRT 0x890B /* add routing table entry */ +#define SIOCDELRT 0x890C /* delete routing table entry */ + +/* Socket configuration controls. */ +#define SIOCGIFNAME 0x8910 /* get iface name */ +#define SIOCSIFLINK 0x8911 /* set iface channel */ +#define SIOCGIFCONF 0x8912 /* get iface list */ +#define SIOCGIFFLAGS 0x8913 /* get flags */ +#define SIOCSIFFLAGS 0x8914 /* set flags */ +#define SIOCGIFADDR 0x8915 /* get PA address */ +#define SIOCSIFADDR 0x8916 /* set PA address */ +#define SIOCGIFDSTADDR 0x8917 /* get remote PA address */ +#define SIOCSIFDSTADDR 0x8918 /* set remote PA address */ +#define SIOCGIFBRDADDR 0x8919 /* get broadcast PA address */ +#define SIOCSIFBRDADDR 0x891a /* set broadcast PA address */ +#define SIOCGIFNETMASK 0x891b /* get network PA mask */ +#define SIOCSIFNETMASK 0x891c /* set network PA mask */ +#define SIOCGIFMETRIC 0x891d /* get metric */ +#define SIOCSIFMETRIC 0x891e /* set metric */ +#define SIOCGIFMEM 0x891f /* get memory address (BSD) */ +#define SIOCSIFMEM 0x8920 /* set memory address (BSD) */ +#define SIOCGIFMTU 0x8921 /* get MTU size */ +#define SIOCSIFMTU 0x8922 /* set MTU size */ +#define OLD_SIOCGIFHWADDR 0x8923 /* get hardware address */ +#define SIOCSIFHWADDR 0x8924 /* set hardware address (NI) */ +#define SIOCGIFENCAP 0x8925 /* get/set slip encapsulation */ +#define SIOCSIFENCAP 0x8926 +#define SIOCGIFHWADDR 0x8927 /* Get hardware address */ +#define SIOCGIFSLAVE 0x8929 /* Driver slaving support */ +#define SIOCSIFSLAVE 0x8930 + +/* Routing table calls (oldrtent - don't use) */ +#define SIOCADDRTOLD 0x8940 /* add routing table entry */ +#define SIOCDELRTOLD 0x8941 /* delete routing table entry */ + +/* ARP cache control calls. */ +#define SIOCDARP 0x8950 /* delete ARP table entry */ +#define SIOCGARP 0x8951 /* get ARP table entry */ +#define SIOCSARP 0x8952 /* set ARP table entry */ + +/* RARP cache control calls. */ +#define SIOCDRARP 0x8960 /* delete RARP table entry */ +#define SIOCGRARP 0x8961 /* get RARP table entry */ +#define SIOCSRARP 0x8962 /* set RARP table entry */ + +/* Driver configuration calls */ + +#define SIOCGIFMAP 0x8970 /* Get device parameters */ +#define SIOCSIFMAP 0x8971 /* Set device parameters */ + +/* Device private ioctl calls */ + +/* + * These 16 ioctls are available to devices via the do_ioctl() device + * vector. Each device should include this file and redefine these names + * as their own. Because these are device dependent it is a good idea + * _NOT_ to issue them to random objects and hope. + */ + +#define SIOCDEVPRIVATE 0x89F0 /* to 89FF */ + + +#endif /* _LINUX_SOCKIOS_H */ diff --git a/include/linux/soundcard.h b/include/linux/soundcard.h new file mode 100644 index 000000000..262e3f198 --- /dev/null +++ b/include/linux/soundcard.h @@ -0,0 +1,967 @@ +#ifndef SOUNDCARD_H +#define SOUNDCARD_H +/* + * Copyright by Hannu Savolainen 1993 + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * + */ + + /* + * If you make modifications to this file, please contact me before + * distributing the modified version. There is already enough + * diversity in the world. + * + * Regards, + * Hannu Savolainen + * hannu@voxware.pp.fi + */ + +#define SOUND_VERSION 300 +#define VOXWARE + +#include <linux/ioctl.h> + +/* + * Supported card ID numbers (Should be somewhere else?) + */ + +#define SNDCARD_ADLIB 1 +#define SNDCARD_SB 2 +#define SNDCARD_PAS 3 +#define SNDCARD_GUS 4 +#define SNDCARD_MPU401 5 +#define SNDCARD_SB16 6 +#define SNDCARD_SB16MIDI 7 +#define SNDCARD_UART6850 8 +#define SNDCARD_GUS16 9 +#define SNDCARD_MSS 10 +#define SNDCARD_PSS 11 +#define SNDCARD_SSCAPE 12 + +/*********************************** + * IOCTL Commands for /dev/sequencer + */ + +#ifndef _IOWR +/* @(#)ioctlp.h */ + +/* Ioctl's have the command encoded in the lower word, + * and the size of any in or out parameters in the upper + * word. The high 2 bits of the upper word are used + * to encode the in/out status of the parameter; for now + * we restrict parameters to at most 128 bytes. + */ +/* #define IOCTYPE (0xff<<8) */ +#define IOCPARM_MASK 0x7f /* parameters must be < 128 bytes */ +#define IOC_VOID 0x00000000 /* no parameters */ +#define IOC_OUT 0x20000000 /* copy out parameters */ +#define IOC_IN 0x40000000 /* copy in parameters */ +#define IOC_INOUT (IOC_IN|IOC_OUT) +/* the 0x20000000 is so we can distinguish new ioctl's from old */ +#define _IO(x,y) ((int)(IOC_VOID|(x<<8)|y)) +#define _IOR(x,y,t) ((int)(IOC_OUT|((sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y)) +#define _IOW(x,y,t) ((int)(IOC_IN|((sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y)) +/* this should be _IORW, but stdio got there first */ +#define _IOWR(x,y,t) ((int)(IOC_INOUT|((sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y)) +#endif /* !_IOWR */ + +#define SNDCTL_SEQ_RESET _IO ('Q', 0) +#define SNDCTL_SEQ_SYNC _IO ('Q', 1) +#define SNDCTL_SYNTH_INFO _IOWR('Q', 2, struct synth_info) +#define SNDCTL_SEQ_CTRLRATE _IOWR('Q', 3, int) /* Set/get timer resolution (HZ) */ +#define SNDCTL_SEQ_GETOUTCOUNT _IOR ('Q', 4, int) +#define SNDCTL_SEQ_GETINCOUNT _IOR ('Q', 5, int) +#define SNDCTL_SEQ_PERCMODE _IOW ('Q', 6, int) +#define SNDCTL_FM_LOAD_INSTR _IOW ('Q', 7, struct sbi_instrument) /* Valid for FM only */ +#define SNDCTL_SEQ_TESTMIDI _IOW ('Q', 8, int) +#define SNDCTL_SEQ_RESETSAMPLES _IOW ('Q', 9, int) +#define SNDCTL_SEQ_NRSYNTHS _IOR ('Q',10, int) +#define SNDCTL_SEQ_NRMIDIS _IOR ('Q',11, int) +#define SNDCTL_MIDI_INFO _IOWR('Q',12, struct midi_info) +#define SNDCTL_SEQ_TRESHOLD _IOW ('Q',13, int) +#define SNDCTL_SYNTH_MEMAVL _IOWR('Q',14, int) /* in=dev#, out=memsize */ +#define SNDCTL_FM_4OP_ENABLE _IOW ('Q',15, int) /* in=dev# */ +#define SNDCTL_PMGR_ACCESS _IOWR('Q',16, struct patmgr_info) +#define SNDCTL_SEQ_PANIC _IO ('Q',17) + +#define SNDCTL_TMR_TIMEBASE _IOWR('T', 1, int) +#define SNDCTL_TMR_START _IO ('T', 2) +#define SNDCTL_TMR_STOP _IO ('T', 3) +#define SNDCTL_TMR_CONTINUE _IO ('T', 4) +#define SNDCTL_TMR_TEMPO _IOWR('T', 5, int) +#define SNDCTL_TMR_SOURCE _IOWR('T', 6, int) +# define TMR_INTERNAL 0x00000001 +# define TMR_EXTERNAL 0x00000002 +# define TMR_MODE_MIDI 0x00000010 +# define TMR_MODE_FSK 0x00000020 +# define TMR_MODE_CLS 0x00000040 +# define TMR_MODE_SMPTE 0x00000080 +#define SNDCTL_TMR_METRONOME _IOW ('T', 7, int) +#define SNDCTL_TMR_SELECT _IOW ('T', 8, int) + +/* + * Sample loading mechanism for internal synthesizers (/dev/sequencer) + * The following patch_info structure has been designed to support + * Gravis UltraSound. It tries to be universal format for uploading + * sample based patches but is probably too limited. + */ + +struct patch_info { + short key; /* Use GUS_PATCH here */ +#define GUS_PATCH 0x04fd +#define OBSOLETE_GUS_PATCH 0x02fd + short device_no; /* Synthesizer number */ + short instr_no; /* Midi pgm# */ + + unsigned long mode; +/* + * The least significant byte has the same format than the GUS .PAT + * files + */ +#define WAVE_16_BITS 0x01 /* bit 0 = 8 or 16 bit wave data. */ +#define WAVE_UNSIGNED 0x02 /* bit 1 = Signed - Unsigned data. */ +#define WAVE_LOOPING 0x04 /* bit 2 = looping enabled-1. */ +#define WAVE_BIDIR_LOOP 0x08 /* bit 3 = Set is bidirectional looping. */ +#define WAVE_LOOP_BACK 0x10 /* bit 4 = Set is looping backward. */ +#define WAVE_SUSTAIN_ON 0x20 /* bit 5 = Turn sustaining on. (Env. pts. 3)*/ +#define WAVE_ENVELOPES 0x40 /* bit 6 = Enable envelopes - 1 */ + /* (use the env_rate/env_offs fields). */ +/* Linux specific bits */ +#define WAVE_VIBRATO 0x00010000 /* The vibrato info is valid */ +#define WAVE_TREMOLO 0x00020000 /* The tremolo info is valid */ +#define WAVE_SCALE 0x00040000 /* The scaling info is valid */ +/* Other bits must be zeroed */ + + long len; /* Size of the wave data in bytes */ + long loop_start, loop_end; /* Byte offsets from the beginning */ + +/* + * The base_freq and base_note fields are used when computing the + * playback speed for a note. The base_note defines the tone frequency + * which is heard if the sample is played using the base_freq as the + * playback speed. + * + * The low_note and high_note fields define the minimum and maximum note + * frequencies for which this sample is valid. It is possible to define + * more than one samples for a instrument number at the same time. The + * low_note and high_note fields are used to select the most suitable one. + * + * The fields base_note, high_note and low_note should contain + * the note frequency multiplied by 1000. For example value for the + * middle A is 440*1000. + */ + + unsigned int base_freq; + unsigned long base_note; + unsigned long high_note; + unsigned long low_note; + int panning; /* -128=left, 127=right */ + int detuning; + +/* New fields introduced in version 1.99.5 */ + + /* Envelope. Enabled by mode bit WAVE_ENVELOPES */ + unsigned char env_rate[ 6 ]; /* GUS HW ramping rate */ + unsigned char env_offset[ 6 ]; /* 255 == 100% */ + + /* + * The tremolo, vibrato and scale info are not supported yet. + * Enable by setting the mode bits WAVE_TREMOLO, WAVE_VIBRATO or + * WAVE_SCALE + */ + + unsigned char tremolo_sweep; + unsigned char tremolo_rate; + unsigned char tremolo_depth; + + unsigned char vibrato_sweep; + unsigned char vibrato_rate; + unsigned char vibrato_depth; + + int scale_frequency; + unsigned int scale_factor; /* from 0 to 2048 or 0 to 2 */ + + int volume; + int spare[4]; + char data[1]; /* The waveform data starts here */ + }; + + +struct sysex_info { + short key; /* Use GUS_PATCH here */ +#define SYSEX_PATCH 0x05fd + short device_no; /* Synthesizer number */ + long len; /* Size of the sysex data in bytes */ + unsigned char data[1]; /* Sysex data starts here */ + }; + +/* + * Patch management interface (/dev/sequencer, /dev/patmgr#) + * Don't use these calls if you want to maintain compatibility with + * the future versions of the driver. + */ + +#define PS_NO_PATCHES 0 /* No patch support on device */ +#define PS_MGR_NOT_OK 1 /* Plain patch support (no mgr) */ +#define PS_MGR_OK 2 /* Patch manager supported */ +#define PS_MANAGED 3 /* Patch manager running */ + +#define SNDCTL_PMGR_IFACE _IOWR('P', 1, struct patmgr_info) + +/* + * The patmgr_info is a fixed size structure which is used for two + * different purposes. The intended use is for communication between + * the application using /dev/sequencer and the patch manager daemon + * associated with a synthesizer device (ioctl(SNDCTL_PMGR_ACCESS)). + * + * This structure is also used with ioctl(SNDCTL_PGMR_IFACE) which allows + * a patch manager daemon to read and write device parameters. This + * ioctl available through /dev/sequencer also. Avoid using it since it's + * extremely hardware dependent. In addition access trough /dev/sequencer + * may confuse the patch manager daemon. + */ + +struct patmgr_info { /* Note! size must be < 4k since kmalloc() is used */ + unsigned long key; /* Don't worry. Reserved for communication + between the patch manager and the driver. */ +#define PM_K_EVENT 1 /* Event from the /dev/sequencer driver */ +#define PM_K_COMMAND 2 /* Request from a application */ +#define PM_K_RESPONSE 3 /* From patmgr to application */ +#define PM_ERROR 4 /* Error returned by the patmgr */ + int device; + int command; + +/* + * Commands 0x000 to 0xfff reserved for patch manager programs + */ +#define PM_GET_DEVTYPE 1 /* Returns type of the patch mgr interface of dev */ +#define PMTYPE_FM2 1 /* 2 OP fm */ +#define PMTYPE_FM4 2 /* Mixed 4 or 2 op FM (OPL-3) */ +#define PMTYPE_WAVE 3 /* Wave table synthesizer (GUS) */ +#define PM_GET_NRPGM 2 /* Returns max # of midi programs in parm1 */ +#define PM_GET_PGMMAP 3 /* Returns map of loaded midi programs in data8 */ +#define PM_GET_PGM_PATCHES 4 /* Return list of patches of a program (parm1) */ +#define PM_GET_PATCH 5 /* Return patch header of patch parm1 */ +#define PM_SET_PATCH 6 /* Set patch header of patch parm1 */ +#define PM_READ_PATCH 7 /* Read patch (wave) data */ +#define PM_WRITE_PATCH 8 /* Write patch (wave) data */ + +/* + * Commands 0x1000 to 0xffff are for communication between the patch manager + * and the client + */ +#define _PM_LOAD_PATCH 0x100 + +/* + * Commands above 0xffff reserved for device specific use + */ + + long parm1; + long parm2; + long parm3; + + union { + unsigned char data8[4000]; + unsigned short data16[2000]; + unsigned long data32[1000]; + struct patch_info patch; + } data; + }; + +/* + * When a patch manager daemon is present, it will be informed by the + * driver when something important happens. For example when the + * /dev/sequencer is opened or closed. A record with key == PM_K_EVENT is + * returned. The command field contains the event type: + */ +#define PM_E_OPENED 1 /* /dev/sequencer opened */ +#define PM_E_CLOSED 2 /* /dev/sequencer closed */ +#define PM_E_PATCH_RESET 3 /* SNDCTL_RESETSAMPLES called */ +#define PM_E_PATCH_LOADED 4 /* A patch has been loaded by appl */ + +/* + * /dev/sequencer input events. + * + * The data written to the /dev/sequencer is a stream of events. Events + * are records of 4 or 8 bytes. The first byte defines the size. + * Any number of events can be written with a write call. There + * is a set of macros for sending these events. Use these macros if you + * want to maximize portability of your program. + * + * Events SEQ_WAIT, SEQ_MIDIPUTC and SEQ_ECHO. Are also input events. + * (All input events are currently 4 bytes long. Be prepared to support + * 8 byte events also. If you receive any event having first byte >= 128, + * it's a 8 byte event. + * + * The events are documented at the end of this file. + * + * Normal events (4 bytes) + * There is also a 8 byte version of most of the 4 byte events. The + * 8 byte one is recommended. + */ +#define SEQ_NOTEOFF 0 +#define SEQ_FMNOTEOFF SEQ_NOTEOFF /* Just old name */ +#define SEQ_NOTEON 1 +#define SEQ_FMNOTEON SEQ_NOTEON +#define SEQ_WAIT TMR_WAIT_ABS +#define SEQ_PGMCHANGE 3 +#define SEQ_FMPGMCHANGE SEQ_PGMCHANGE +#define SEQ_SYNCTIMER TMR_START +#define SEQ_MIDIPUTC 5 +#define SEQ_DRUMON 6 /*** OBSOLETE ***/ +#define SEQ_DRUMOFF 7 /*** OBSOLETE ***/ +#define SEQ_ECHO TMR_ECHO /* For synching programs with output */ +#define SEQ_AFTERTOUCH 9 +#define SEQ_CONTROLLER 10 + +/******************************************* + * Midi controller numbers + ******************************************* + * Controllers 0 to 31 (0x00 to 0x1f) and + * 32 to 63 (0x20 to 0x3f) are continuous + * controllers. + * In the MIDI 1.0 these controllers are sent using + * two messages. Controller numbers 0 to 31 are used + * to send the LSB and the controller numbers 32 to 63 + * are for the LSB. + * + * This driver uses just the numbers 0 to 31 to store both + * the LSB and MSB. The controller value is a unsigned short + * and it's valid range is between 0 and 16383 (0x0000 to 0x3fff). + * The driver sends the controller value using two messages when + * necessary. + */ + +#define CTL_BANK_SELECT 0x00 +#define CTL_MODWHEEL 0x01 +#define CTL_BREATH 0x02 +/* undefined 0x03 */ +#define CTL_FOOT 0x04 +#define CTL_PORTAMENTO_TIME 0x05 +#define CTL_DATA_ENTRY 0x06 +#define CTL_MAIN_VOLUME 0x07 +#define CTL_BALANCE 0x08 +/* undefined 0x09 */ +#define CTL_PAN 0x0a +#define CTL_EXPRESSION 0x0b +/* undefined 0x0c */ +/* undefined 0x0d */ +/* undefined 0x0e */ +/* undefined 0x0f */ +#define CTL_GENERAL_PURPOSE1 0x10 +#define CTL_GENERAL_PURPOSE2 0x11 +#define CTL_GENERAL_PURPOSE3 0x12 +#define CTL_GENERAL_PURPOSE4 0x13 +/* undefined 0x14 - 0x1f */ + +/* undefined 0x20 */ +/* The controller numbers 0x21 to 0x3f are reserved for the */ +/* least significant bytes of the controllers 0x00 to 0x1f. */ +/* These controllers are not recognised by the driver. */ + +/* Controllers 64 to 69 (0x40 to 0x45) are on/off switches. */ +/* 0=OFF and 127=ON (intermediate values are possible) */ +#define CTL_DAMPER_PEDAL 0x40 +#define CTL_SUSTAIN 0x40 /* Alias */ +#define CTL_HOLD 0x40 /* Alias */ +#define CTL_PORTAMENTO 0x41 +#define CTL_SOSTENUTO 0x42 +#define CTL_SOFT_PEDAL 0x43 +/* undefined 0x44 */ +#define CTL_HOLD2 0x45 +/* undefined 0x46 - 0x4f */ + +#define CTL_GENERAL_PURPOSE5 0x50 +#define CTL_GENERAL_PURPOSE6 0x51 +#define CTL_GENERAL_PURPOSE7 0x52 +#define CTL_GENERAL_PURPOSE8 0x53 +/* undefined 0x54 - 0x5a */ +#define CTL_EXT_EFF_DEPTH 0x5b +#define CTL_TREMOLO_DEPTH 0x5c +#define CTL_CHORUS_DEPTH 0x5d +#define CTL_DETUNE_DEPTH 0x5e +#define CTL_CELESTE_DEPTH 0x5e /* Alias for the above one */ +#define CTL_PHASER_DEPTH 0x5f +#define CTL_DATA_INCREMENT 0x60 +#define CTL_DATA_DECREMENT 0x61 +#define CTL_NONREG_PARM_NUM_LSB 0x62 +#define CTL_NONREG_PARM_NUM_MSB 0x63 +#define CTL_REGIST_PARM_NUM_LSB 0x64 +#define CTL_REGIST_PARM_NUM_MSB 0x65 +/* undefined 0x66 - 0x78 */ +/* reserved 0x79 - 0x7f */ + +/* Pseudo controllers (not midi compatible) */ +#define CTRL_PITCH_BENDER 255 +#define CTRL_PITCH_BENDER_RANGE 254 +#define CTRL_EXPRESSION 253 /* Obsolete */ +#define CTRL_MAIN_VOLUME 252 /* Obsolete */ +#define SEQ_BALANCE 11 +#define SEQ_VOLMODE 12 + +/* + * Volume mode decides how volumes are used + */ + +#define VOL_METHOD_ADAGIO 1 +#define VOL_METHOD_LINEAR 2 + +/* + * Note! SEQ_WAIT, SEQ_MIDIPUTC and SEQ_ECHO are used also as + * input events. + */ + +/* + * Event codes 0xf0 to 0xfc are reserved for future extensions. + */ + +#define SEQ_FULLSIZE 0xfd /* Long events */ +/* + * SEQ_FULLSIZE events are used for loading patches/samples to the + * synthesizer devices. These events are passed directly to the driver + * of the associated synthesizer device. There is no limit to the size + * of the extended events. These events are not queued but executed + * immediately when the write() is called (execution can take several + * seconds of time). + * + * When a SEQ_FULLSIZE message is written to the device, it must + * be written using exactly one write() call. Other events cannot + * be mixed to the same write. + * + * For FM synths (YM3812/OPL3) use struct sbi_instrument and write it to the + * /dev/sequencer. Don't write other data together with the instrument structure + * Set the key field of the structure to FM_PATCH. The device field is used to + * route the patch to the corresponding device. + * + * For Gravis UltraSound use struct patch_info. Initialize the key field + * to GUS_PATCH. + */ +#define SEQ_PRIVATE 0xfe /* Low level HW dependent events (8 bytes) */ +#define SEQ_EXTENDED 0xff /* Extended events (8 bytes) OBSOLETE */ + +/* + * Record for FM patches + */ + +typedef unsigned char sbi_instr_data[32]; + +struct sbi_instrument { + unsigned short key; /* Initialize to FM_PATCH or OPL3_PATCH */ +#define FM_PATCH 0x01fd +#define OPL3_PATCH 0x03fd + short device; /* Synth# (0-4) */ + int channel; /* Program# to be initialized */ + sbi_instr_data operators; /* Register settings for operator cells (.SBI format) */ + }; + +struct synth_info { /* Read only */ + char name[30]; + int device; /* 0-N. INITIALIZE BEFORE CALLING */ + int synth_type; +#define SYNTH_TYPE_FM 0 +#define SYNTH_TYPE_SAMPLE 1 +#define SYNTH_TYPE_MIDI 2 /* Midi interface */ + + int synth_subtype; +#define FM_TYPE_ADLIB 0x00 +#define FM_TYPE_OPL3 0x01 + +#define SAMPLE_TYPE_GUS 0x10 + + int perc_mode; /* No longer supported */ + int nr_voices; + int nr_drums; /* Obsolete field */ + int instr_bank_size; + unsigned long capabilities; +#define SYNTH_CAP_PERCMODE 0x00000001 /* No longer used */ +#define SYNTH_CAP_OPL3 0x00000002 /* Set if OPL3 supported */ +#define SYNTH_CAP_INPUT 0x00000004 /* Input (MIDI) device */ + int dummies[19]; /* Reserve space */ + }; + +struct sound_timer_info { + char name[30]; + int caps; + }; + +#define MIDI_CAP_MPU401 1 /* MPU-401 intelligent mode */ + +struct midi_info { + char name[30]; + int device; /* 0-N. INITIALIZE BEFORE CALLING */ + unsigned long capabilities; /* To be defined later */ + int dev_type; + int dummies[18]; /* Reserve space */ + }; + +/******************************************** + * ioctl commands for the /dev/midi## + */ +typedef struct { + unsigned char cmd; + char nr_args, nr_returns; + unsigned char data[30]; + } mpu_command_rec; + +#define SNDCTL_MIDI_PRETIME _IOWR('m', 0, int) +#define SNDCTL_MIDI_MPUMODE _IOWR('m', 1, int) +#define SNDCTL_MIDI_MPUCMD _IOWR('m', 2, mpu_command_rec) + +/******************************************** + * IOCTL commands for /dev/dsp and /dev/audio + */ + +#define SNDCTL_DSP_RESET _IO ('P', 0) +#define SNDCTL_DSP_SYNC _IO ('P', 1) +#define SNDCTL_DSP_SPEED _IOWR('P', 2, int) +#define SNDCTL_DSP_STEREO _IOWR('P', 3, int) +#define SNDCTL_DSP_GETBLKSIZE _IOWR('P', 4, int) +#define SNDCTL_DSP_SAMPLESIZE SNDCTL_DSP_SETFMT +#define SOUND_PCM_WRITE_CHANNELS _IOWR('P', 6, int) +#define SOUND_PCM_WRITE_FILTER _IOWR('P', 7, int) +#define SNDCTL_DSP_POST _IO ('P', 8) +#define SNDCTL_DSP_SUBDIVIDE _IOWR('P', 9, int) +#define SNDCTL_DSP_SETFRAGMENT _IOWR('P',10, int) + +/* Audio data formats (Note! U8=8 and S16_LE=16 for compatibility) */ +#define SNDCTL_DSP_GETFMTS _IOR ('P',11, int) /* Returns a mask */ +#define SNDCTL_DSP_SETFMT _IOWR('P',5, int) /* Selects ONE fmt*/ +# define AFMT_QUERY 0x00000000 /* Return current fmt */ +# define AFMT_MU_LAW 0x00000001 +# define AFMT_A_LAW 0x00000002 +# define AFMT_IMA_ADPCM 0x00000004 +# define AFMT_U8 0x00000008 +# define AFMT_S16_LE 0x00000010 /* Little endian signed 16*/ +# define AFMT_S16_BE 0x00000020 /* Big endian signed 16 */ +# define AFMT_S8 0x00000040 +# define AFMT_U16_LE 0x00000080 /* Little endian U16 */ +# define AFMT_U16_BE 0x00000100 /* Big endian U16 */ + +#define SOUND_PCM_READ_RATE _IOR ('P', 2, int) +#define SOUND_PCM_READ_CHANNELS _IOR ('P', 6, int) +#define SOUND_PCM_READ_BITS _IOR ('P', 5, int) +#define SOUND_PCM_READ_FILTER _IOR ('P', 7, int) + +/* Some alias names */ +#define SOUND_PCM_WRITE_BITS SNDCTL_DSP_SETFMT +#define SOUND_PCM_WRITE_RATE SNDCTL_DSP_SPEED +#define SOUND_PCM_POST SNDCTL_DSP_POST +#define SOUND_PCM_RESET SNDCTL_DSP_RESET +#define SOUND_PCM_SYNC SNDCTL_DSP_SYNC +#define SOUND_PCM_SUBDIVIDE SNDCTL_DSP_SUBDIVIDE +#define SOUND_PCM_SETFRAGMENT SNDCTL_DSP_SETFRAGMENT +#define SOUND_PCM_GETFMTS SNDCTL_DSP_GETFMTS +#define SOUND_PCM_SETFMT SNDCTL_DSP_SETFMT + +/********************************************* + * IOCTL /dev/pss (experimental PSS API by marc.hoffman@analog.com. + * likely to change in near future. + */ +#define SNDCTL_PSS_RESET _IO ('C', 0) +#define SNDCTL_PSS_SETUP_REGISTERS _IO ('C', 1) +#define SNDCTL_PSS_SPEAKER _IOW ('C', 2, struct pss_speaker) + +struct pss_speaker { + int volume; + int bass; + int treb; + int mode; +}; + +/********************************************* + * IOCTL commands for /dev/mixer + */ + +/* + * Mixer devices + * + * There can be up to 20 different analog mixer channels. The + * SOUND_MIXER_NRDEVICES gives the currently supported maximum. + * The SOUND_MIXER_READ_DEVMASK returns a bitmask which tells + * the devices supported by the particular mixer. + */ + +#define SOUND_MIXER_NRDEVICES 12 +#define SOUND_MIXER_VOLUME 0 +#define SOUND_MIXER_BASS 1 +#define SOUND_MIXER_TREBLE 2 +#define SOUND_MIXER_SYNTH 3 +#define SOUND_MIXER_PCM 4 +#define SOUND_MIXER_SPEAKER 5 +#define SOUND_MIXER_LINE 6 +#define SOUND_MIXER_MIC 7 +#define SOUND_MIXER_CD 8 +#define SOUND_MIXER_IMIX 9 /* Recording monitor */ +#define SOUND_MIXER_ALTPCM 10 +#define SOUND_MIXER_RECLEV 11 /* Recording level */ + +/* Some on/off settings (SOUND_SPECIAL_MIN - SOUND_SPECIAL_MAX) */ +/* Not counted to SOUND_MIXER_NRDEVICES, but use the same number space */ +#define SOUND_ONOFF_MIN 28 +#define SOUND_ONOFF_MAX 30 +#define SOUND_MIXER_MUTE 28 /* 0 or 1 */ +#define SOUND_MIXER_ENHANCE 29 /* Enhanced stereo (0, 40, 60 or 80) */ +#define SOUND_MIXER_LOUD 30 /* 0 or 1 */ + +/* Note! Number 31 cannot be used since the sign bit is reserved */ + +#define SOUND_DEVICE_LABELS {"Vol ", "Bass ", "Trebl", "Synth", "Pcm ", "Spkr ", "Line ", \ + "Mic ", "CD ", "Mix ", "Pcm2 ", "rec"} + +#define SOUND_DEVICE_NAMES {"vol", "bass", "treble", "synth", "pcm", "speaker", "line", \ + "mic", "cd", "mix", "pcm2", "rec"} + +/* Device bitmask identifiers */ + +#define SOUND_MIXER_RECSRC 0xff /* Arg contains a bit for each recording source */ +#define SOUND_MIXER_DEVMASK 0xfe /* Arg contains a bit for each supported device */ +#define SOUND_MIXER_RECMASK 0xfd /* Arg contains a bit for each supported recording source */ +#define SOUND_MIXER_CAPS 0xfc + #define SOUND_CAP_EXCL_INPUT 0x00000001 /* Only one recording source at a time */ +#define SOUND_MIXER_STEREODEVS 0xfb /* Mixer channels supporting stereo */ + +/* Device mask bits */ + +#define SOUND_MASK_VOLUME (1 << SOUND_MIXER_VOLUME) +#define SOUND_MASK_BASS (1 << SOUND_MIXER_BASS) +#define SOUND_MASK_TREBLE (1 << SOUND_MIXER_TREBLE) +#define SOUND_MASK_SYNTH (1 << SOUND_MIXER_SYNTH) +#define SOUND_MASK_PCM (1 << SOUND_MIXER_PCM) +#define SOUND_MASK_SPEAKER (1 << SOUND_MIXER_SPEAKER) +#define SOUND_MASK_LINE (1 << SOUND_MIXER_LINE) +#define SOUND_MASK_MIC (1 << SOUND_MIXER_MIC) +#define SOUND_MASK_CD (1 << SOUND_MIXER_CD) +#define SOUND_MASK_IMIX (1 << SOUND_MIXER_IMIX) +#define SOUND_MASK_ALTPCM (1 << SOUND_MIXER_ALTPCM) +#define SOUND_MASK_RECLEV (1 << SOUND_MIXER_RECLEV) + +#define SOUND_MASK_MUTE (1 << SOUND_MIXER_MUTE) +#define SOUND_MASK_ENHANCE (1 << SOUND_MIXER_ENHANCE) +#define SOUND_MASK_LOUD (1 << SOUND_MIXER_LOUD) + +#define MIXER_READ(dev) _IOR('M', dev, int) +#define SOUND_MIXER_READ_VOLUME MIXER_READ(SOUND_MIXER_VOLUME) +#define SOUND_MIXER_READ_BASS MIXER_READ(SOUND_MIXER_BASS) +#define SOUND_MIXER_READ_TREBLE MIXER_READ(SOUND_MIXER_TREBLE) +#define SOUND_MIXER_READ_SYNTH MIXER_READ(SOUND_MIXER_SYNTH) +#define SOUND_MIXER_READ_PCM MIXER_READ(SOUND_MIXER_PCM) +#define SOUND_MIXER_READ_SPEAKER MIXER_READ(SOUND_MIXER_SPEAKER) +#define SOUND_MIXER_READ_LINE MIXER_READ(SOUND_MIXER_LINE) +#define SOUND_MIXER_READ_MIC MIXER_READ(SOUND_MIXER_MIC) +#define SOUND_MIXER_READ_CD MIXER_READ(SOUND_MIXER_CD) +#define SOUND_MIXER_READ_IMIX MIXER_READ(SOUND_MIXER_IMIX) +#define SOUND_MIXER_READ_ALTPCM MIXER_READ(SOUND_MIXER_ALTPCM) +#define SOUND_MIXER_READ_RECLEV MIXER_READ(SOUND_MIXER_RECLEV) +#define SOUND_MIXER_READ_MUTE MIXER_READ(SOUND_MIXER_MUTE) +#define SOUND_MIXER_READ_ENHANCE MIXER_READ(SOUND_MIXER_ENHANCE) +#define SOUND_MIXER_READ_LOUD MIXER_READ(SOUND_MIXER_LOUD) + +#define SOUND_MIXER_READ_RECSRC MIXER_READ(SOUND_MIXER_RECSRC) +#define SOUND_MIXER_READ_DEVMASK MIXER_READ(SOUND_MIXER_DEVMASK) +#define SOUND_MIXER_READ_RECMASK MIXER_READ(SOUND_MIXER_RECMASK) +#define SOUND_MIXER_READ_STEREODEVS MIXER_READ(SOUND_MIXER_STEREODEVS) +#define SOUND_MIXER_READ_CAPS MIXER_READ(SOUND_MIXER_CAPS) + +#define MIXER_WRITE(dev) _IOWR('M', dev, int) +#define SOUND_MIXER_WRITE_VOLUME MIXER_WRITE(SOUND_MIXER_VOLUME) +#define SOUND_MIXER_WRITE_BASS MIXER_WRITE(SOUND_MIXER_BASS) +#define SOUND_MIXER_WRITE_TREBLE MIXER_WRITE(SOUND_MIXER_TREBLE) +#define SOUND_MIXER_WRITE_SYNTH MIXER_WRITE(SOUND_MIXER_SYNTH) +#define SOUND_MIXER_WRITE_PCM MIXER_WRITE(SOUND_MIXER_PCM) +#define SOUND_MIXER_WRITE_SPEAKER MIXER_WRITE(SOUND_MIXER_SPEAKER) +#define SOUND_MIXER_WRITE_LINE MIXER_WRITE(SOUND_MIXER_LINE) +#define SOUND_MIXER_WRITE_MIC MIXER_WRITE(SOUND_MIXER_MIC) +#define SOUND_MIXER_WRITE_CD MIXER_WRITE(SOUND_MIXER_CD) +#define SOUND_MIXER_WRITE_IMIX MIXER_WRITE(SOUND_MIXER_IMIX) +#define SOUND_MIXER_WRITE_ALTPCM MIXER_WRITE(SOUND_MIXER_ALTPCM) +#define SOUND_MIXER_WRITE_RECLEV MIXER_WRITE(SOUND_MIXER_RECLEV) +#define SOUND_MIXER_WRITE_MUTE MIXER_WRITE(SOUND_MIXER_MUTE) +#define SOUND_MIXER_WRITE_ENHANCE MIXER_WRITE(SOUND_MIXER_ENHANCE) +#define SOUND_MIXER_WRITE_LOUD MIXER_WRITE(SOUND_MIXER_LOUD) + +#define SOUND_MIXER_WRITE_RECSRC MIXER_WRITE(SOUND_MIXER_RECSRC) + +/* + * Level 2 event types for /dev/sequencer + */ + +/* + * The 4 most significant bits of byte 0 specify the class of + * the event: + * + * 0x8X = system level events, + * 0x9X = device/port specific events, event[1] = device/port, + * The last 4 bits give the subtype: + * 0x02 = Channel event (event[3] = chn). + * 0x01 = note event (event[4] = note). + * (0x01 is not used alone but always with bit 0x02). + * event[2] = MIDI message code (0x80=note off etc.) + * + */ + +#define EV_SEQ_LOCAL 0x80 +#define EV_TIMING 0x81 +#define EV_CHN_COMMON 0x92 +#define EV_CHN_VOICE 0x93 +/* + * Event types 200 to 220 are reserved for application use. + * These numbers will not be used by the driver. + */ + +/* + * Events for event type EV_CHN_VOICE + */ + +#define MIDI_NOTEOFF 0x80 +#define MIDI_NOTEON 0x90 +#define MIDI_KEY_PRESSURE 0xA0 + +/* + * Events for event type EV_CHN_COMMON + */ + +#define MIDI_CTL_CHANGE 0xB0 +#define MIDI_PGM_CHANGE 0xC0 +#define MIDI_CHN_PRESSURE 0xD0 +#define MIDI_PITCH_BEND 0xE0 + +#define MIDI_SYSTEM_PREFIX 0xF0 + +/* + * Timer event types + */ +#define TMR_WAIT_REL 1 /* Time relative to the prev time */ +#define TMR_WAIT_ABS 2 /* Absolute time since TMR_START */ +#define TMR_STOP 3 +#define TMR_START 4 +#define TMR_CONTINUE 5 +#define TMR_TEMPO 6 +#define TMR_ECHO 8 +#define TMR_CLOCK 9 /* MIDI clock */ +#define TMR_SPP 10 /* Song position pointer */ +#define TMR_TIMESIG 11 /* Time signature */ + +#if (!defined(__KERNEL__) && !defined(KERNEL) && !defined(INKERNEL) && !defined(_KERNEL)) || defined(USE_SEQ_MACROS) +/* + * Some convenience macros to simplify programming of the + * /dev/sequencer interface + * + * These macros define the API which should be used when possible. + */ + +#ifndef USE_SIMPLE_MACROS +void seqbuf_dump(void); /* This function must be provided by programs */ + +/* Sample seqbuf_dump() implementation: + * + * SEQ_DEFINEBUF (2048); -- Defines a buffer for 2048 bytes + * + * int seqfd; -- The file descriptor for /dev/sequencer. + * + * void + * seqbuf_dump () + * { + * if (_seqbufptr) + * if (write (seqfd, _seqbuf, _seqbufptr) == -1) + * { + * perror ("write /dev/sequencer"); + * exit (-1); + * } + * _seqbufptr = 0; + * } + */ + +#define SEQ_DEFINEBUF(len) unsigned char _seqbuf[len]; int _seqbuflen = len;int _seqbufptr = 0 +#define SEQ_USE_EXTBUF() extern unsigned char _seqbuf[]; extern int _seqbuflen;extern int _seqbufptr +#define SEQ_DECLAREBUF() SEQ_USE_EXTBUF() +#define SEQ_PM_DEFINES struct patmgr_info _pm_info +#define _SEQ_NEEDBUF(len) if ((_seqbufptr+(len)) > _seqbuflen) seqbuf_dump() +#define _SEQ_ADVBUF(len) _seqbufptr += len +#define SEQ_DUMPBUF seqbuf_dump +#else +/* + * This variation of the sequencer macros is used just to format one event + * using fixed buffer. + * + * The program using the macro library must define the following macros before + * using this library. + * + * #define _seqbuf name of the buffer (unsigned char[]) + * #define _SEQ_ADVBUF(len) If the applic needs to know the exact + * size of the event, this macro can be used. + * Otherwise this must be defined as empty. + * #define _seqbufptr Define the name of index variable or 0 if + * not required. + */ +#define _SEQ_NEEDBUF(len) /* empty */ +#endif + +#define PM_LOAD_PATCH(dev, bank, pgm) (SEQ_DUMPBUF(), _pm_info.command = _PM_LOAD_PATCH, \ + _pm_info.device=dev, _pm_info.data.data8[0]=pgm, \ + _pm_info.parm1 = bank, _pm_info.parm2 = 1, \ + ioctl(seqfd, SNDCTL_PMGR_ACCESS, &_pm_info)) +#define PM_LOAD_PATCHES(dev, bank, pgm) (SEQ_DUMPBUF(), _pm_info.command = _PM_LOAD_PATCH, \ + _pm_info.device=dev, memcpy(_pm_info.data.data8, pgm, 128), \ + _pm_info.parm1 = bank, _pm_info.parm2 = 128, \ + ioctl(seqfd, SNDCTL_PMGR_ACCESS, &_pm_info)) + +#define SEQ_VOLUME_MODE(dev, mode) {_SEQ_NEEDBUF(8);\ + _seqbuf[_seqbufptr] = SEQ_EXTENDED;\ + _seqbuf[_seqbufptr+1] = SEQ_VOLMODE;\ + _seqbuf[_seqbufptr+2] = (dev);\ + _seqbuf[_seqbufptr+3] = (mode);\ + _seqbuf[_seqbufptr+4] = 0;\ + _seqbuf[_seqbufptr+5] = 0;\ + _seqbuf[_seqbufptr+6] = 0;\ + _seqbuf[_seqbufptr+7] = 0;\ + _SEQ_ADVBUF(8);} + +/* + * Midi voice messages + */ + +#define _CHN_VOICE(dev, event, chn, note, parm) \ + {_SEQ_NEEDBUF(8);\ + _seqbuf[_seqbufptr] = EV_CHN_VOICE;\ + _seqbuf[_seqbufptr+1] = (dev);\ + _seqbuf[_seqbufptr+2] = (event);\ + _seqbuf[_seqbufptr+3] = (chn);\ + _seqbuf[_seqbufptr+4] = (note);\ + _seqbuf[_seqbufptr+5] = (parm);\ + _seqbuf[_seqbufptr+6] = (0);\ + _seqbuf[_seqbufptr+7] = 0;\ + _SEQ_ADVBUF(8);} + +#define SEQ_START_NOTE(dev, chn, note, vol) \ + _CHN_VOICE(dev, MIDI_NOTEON, chn, note, vol) + +#define SEQ_STOP_NOTE(dev, chn, note, vol) \ + _CHN_VOICE(dev, MIDI_NOTEOFF, chn, note, vol) + +#define SEQ_KEY_PRESSURE(dev, chn, note, pressure) \ + _CHN_VOICE(dev, MIDI_KEY_PRESSURE, chn, note, pressure) + +/* + * Midi channel messages + */ + +#define _CHN_COMMON(dev, event, chn, p1, p2, w14) \ + {_SEQ_NEEDBUF(8);\ + _seqbuf[_seqbufptr] = EV_CHN_COMMON;\ + _seqbuf[_seqbufptr+1] = (dev);\ + _seqbuf[_seqbufptr+2] = (event);\ + _seqbuf[_seqbufptr+3] = (chn);\ + _seqbuf[_seqbufptr+4] = (p1);\ + _seqbuf[_seqbufptr+5] = (p2);\ + *(short *)&_seqbuf[_seqbufptr+6] = (w14);\ + _SEQ_ADVBUF(8);} + +#define SEQ_CHN_PRESSURE(dev, chn, pressure) \ + _CHN_COMMON(dev, MIDI_CHN_PRESSURE, chn, pressure, 0, 0) + +#define SEQ_SET_PATCH(dev, chn, patch) \ + _CHN_COMMON(dev, MIDI_PGM_CHANGE, chn, patch, 0, 0) + +#define SEQ_CONTROL(dev, chn, controller, value) \ + _CHN_COMMON(dev, MIDI_CTL_CHANGE, chn, controller, 0, value) + +#define SEQ_BENDER(dev, chn, value) \ + _CHN_COMMON(dev, MIDI_PITCH_BEND, chn, 0, 0, value) + + +#define SEQ_V2_X_CONTROL(dev, voice, controller, value) {_SEQ_NEEDBUF(8);\ + _seqbuf[_seqbufptr] = SEQ_EXTENDED;\ + _seqbuf[_seqbufptr+1] = SEQ_CONTROLLER;\ + _seqbuf[_seqbufptr+2] = (dev);\ + _seqbuf[_seqbufptr+3] = (voice);\ + _seqbuf[_seqbufptr+4] = (controller);\ + *(short *)&_seqbuf[_seqbufptr+5] = (value);\ + _seqbuf[_seqbufptr+7] = 0;\ + _SEQ_ADVBUF(8);} +/* + * The following 5 macros are incorrectly implemented and obsolete. + * Use SEQ_BENDER and SEQ_CONTROL (with proper controller) instead. + */ +#define SEQ_PITCHBEND(dev, voice, value) SEQ_V2_X_CONTROL(dev, voice, CTRL_PITCH_BENDER, value) +#define SEQ_BENDER_RANGE(dev, voice, value) SEQ_V2_X_CONTROL(dev, voice, CTRL_PITCH_BENDER_RANGE, value) +#define SEQ_EXPRESSION(dev, voice, value) SEQ_CONTROL(dev, voice, CTL_EXPRESSION, value*128) +#define SEQ_MAIN_VOLUME(dev, voice, value) SEQ_CONTROL(dev, voice, CTL_MAIN_VOLUME, (value*16383)/100) +#define SEQ_PANNING(dev, voice, pos) SEQ_CONTROL(dev, voice, CTL_PAN, (pos+128) / 2) +#if 0 +#define SEQ_PANNING(dev, voice, pos) {_SEQ_NEEDBUF(8);\ + _seqbuf[_seqbufptr] = SEQ_EXTENDED;\ + _seqbuf[_seqbufptr+1] = SEQ_BALANCE;\ + _seqbuf[_seqbufptr+2] = (dev);\ + _seqbuf[_seqbufptr+3] = (voice);\ + (char)_seqbuf[_seqbufptr+4] = (pos);\ + _seqbuf[_seqbufptr+5] = 0;\ + _seqbuf[_seqbufptr+6] = 0;\ + _seqbuf[_seqbufptr+7] = 1;\ + _SEQ_ADVBUF(8);} +#endif + +/* + * Timing and synchronization macros + */ + +#define _TIMER_EVENT(ev, parm) {_SEQ_NEEDBUF(8);\ + _seqbuf[_seqbufptr+0] = EV_TIMING; \ + _seqbuf[_seqbufptr+1] = (ev); \ + _seqbuf[_seqbufptr+2] = 0;\ + _seqbuf[_seqbufptr+3] = 0;\ + *(unsigned int *)&_seqbuf[_seqbufptr+4] = (parm); \ + _SEQ_ADVBUF(8);} + +#define SEQ_START_TIMER() _TIMER_EVENT(TMR_START, 0) +#define SEQ_STOP_TIMER() _TIMER_EVENT(TMR_STOP, 0) +#define SEQ_CONTINUE_TIMER() _TIMER_EVENT(TMR_CONTINUE, 0) +#define SEQ_WAIT_TIME(ticks) _TIMER_EVENT(TMR_WAIT_ABS, ticks) +#define SEQ_DELTA_TIME(ticks) _TIMER_EVENT(TMR_WAIT_REL, ticks) +#define SEQ_ECHO_BACK(key) _TIMER_EVENT(TMR_ECHO, key) +#define SEQ_SET_TEMPO(value) _TIMER_EVENT(TMR_TEMPO, value) +#define SEQ_SONGPOS(pos) _TIMER_EVENT(TMR_SPP, pos) +#define SEQ_TIME_SIGNATURE(sig) _TIMER_EVENT(TMR_TIMESIG, sig) + +/* + * Events for the level 1 interface only + */ + +#define SEQ_MIDIOUT(device, byte) {_SEQ_NEEDBUF(4);\ + _seqbuf[_seqbufptr] = SEQ_MIDIPUTC;\ + _seqbuf[_seqbufptr+1] = (byte);\ + _seqbuf[_seqbufptr+2] = (device);\ + _seqbuf[_seqbufptr+3] = 0;\ + _SEQ_ADVBUF(4);} + +/* + * Patch loading. + */ +#define SEQ_WRPATCH(patchx, len) {if (_seqbufptr) seqbuf_dump();\ + if (write(seqfd, (char*)(patchx), len)==-1) \ + perror("Write patch: /dev/sequencer");} +#define SEQ_WRPATCH2(patchx, len) (seqbuf_dump(), write(seqfd, (char*)(patchx), len)) + +#endif +long soundcard_init(long mem_start); +#endif diff --git a/include/linux/stat.h b/include/linux/stat.h new file mode 100644 index 000000000..86fbd821b --- /dev/null +++ b/include/linux/stat.h @@ -0,0 +1,88 @@ +#ifndef _LINUX_STAT_H +#define _LINUX_STAT_H + +#ifdef __KERNEL__ + +struct old_stat { + unsigned short st_dev; + unsigned short st_ino; + unsigned short st_mode; + unsigned short st_nlink; + unsigned short st_uid; + unsigned short st_gid; + unsigned short st_rdev; + unsigned long st_size; + unsigned long st_atime; + unsigned long st_mtime; + unsigned long st_ctime; +}; + +struct new_stat { + unsigned short st_dev; + unsigned short __pad1; + unsigned long st_ino; + unsigned short st_mode; + unsigned short st_nlink; + unsigned short st_uid; + unsigned short st_gid; + unsigned short st_rdev; + unsigned short __pad2; + unsigned long st_size; + unsigned long st_blksize; + unsigned long st_blocks; + unsigned long st_atime; + unsigned long __unused1; + unsigned long st_mtime; + unsigned long __unused2; + unsigned long st_ctime; + unsigned long __unused3; + unsigned long __unused4; + unsigned long __unused5; +}; + +#endif + +#define S_IFMT 00170000 +#define S_IFSOCK 0140000 +#define S_IFLNK 0120000 +#define S_IFREG 0100000 +#define S_IFBLK 0060000 +#define S_IFDIR 0040000 +#define S_IFCHR 0020000 +#define S_IFIFO 0010000 +#define S_ISUID 0004000 +#define S_ISGID 0002000 +#define S_ISVTX 0001000 + +#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) +#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) +#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) +#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) +#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) +#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) + +#define S_IRWXU 00700 +#define S_IRUSR 00400 +#define S_IWUSR 00200 +#define S_IXUSR 00100 + +#define S_IRWXG 00070 +#define S_IRGRP 00040 +#define S_IWGRP 00020 +#define S_IXGRP 00010 + +#define S_IRWXO 00007 +#define S_IROTH 00004 +#define S_IWOTH 00002 +#define S_IXOTH 00001 + +#ifdef __KERNEL__ +#define S_IRWXUGO (S_IRWXU|S_IRWXG|S_IRWXO) +#define S_IALLUGO (S_ISUID|S_ISGID|S_ISVTX|S_IRWXUGO) +#define S_IRUGO (S_IRUSR|S_IRGRP|S_IROTH) +#define S_IWUGO (S_IWUSR|S_IWGRP|S_IWOTH) +#define S_IXUGO (S_IXUSR|S_IXGRP|S_IXOTH) +#endif + +#endif diff --git a/include/linux/stddef.h b/include/linux/stddef.h new file mode 100644 index 000000000..c6221e712 --- /dev/null +++ b/include/linux/stddef.h @@ -0,0 +1,15 @@ +#ifndef _LINUX_STDDEF_H +#define _LINUX_STDDEF_H + +#ifndef _SIZE_T +#define _SIZE_T +typedef unsigned int size_t; +#endif + +#undef NULL +#define NULL ((void *)0) + +#undef offsetof +#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) + +#endif diff --git a/include/linux/string.h b/include/linux/string.h new file mode 100644 index 000000000..13e8da56e --- /dev/null +++ b/include/linux/string.h @@ -0,0 +1,31 @@ +#ifndef _LINUX_STRING_H_ +#define _LINUX_STRING_H_ + +#include <linux/types.h> /* for size_t */ + +#ifndef NULL +#define NULL ((void *) 0) +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Include machine specific inline routines + */ +#include <asm/string.h> + +#ifdef __USE_PORTABLE_STRINGS_H_ +/* + * include/generic/string.h imports all the string functions, + * for which no appropriate assembler replacements have been provided. + */ +#include <asm-generic/string.h> +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _LINUX_STRING_H_ */ diff --git a/include/linux/sys.h b/include/linux/sys.h new file mode 100644 index 000000000..6ec269dde --- /dev/null +++ b/include/linux/sys.h @@ -0,0 +1,37 @@ +#ifndef _LINUX_SYS_H +#define _LINUX_SYS_H + +/* + * system call entry points ... but not all are defined + */ +#define NR_syscalls 256 + +/* + * These are system calls with the same entry-point + */ +#define _sys_clone _sys_fork + +/* + * These are system calls that will be removed at some time + * due to newer versions existing.. + * (please be careful - ibcs2 may need some of these). + */ +#ifdef notdef +#define _sys_waitpid _sys_old_syscall /* _sys_wait4 */ +#define _sys_olduname _sys_old_syscall /* _sys_newuname */ +#define _sys_uname _sys_old_syscall /* _sys_newuname */ +#define _sys_stat _sys_old_syscall /* _sys_newstat */ +#define _sys_fstat _sys_old_syscall /* _sys_newfstat */ +#define _sys_lstat _sys_old_syscall /* _sys_newlstat */ +#define _sys_signal _sys_old_syscall /* _sys_sigaction */ +#define _sys_sgetmask _sys_old_syscall /* _sys_sigprocmask */ +#define _sys_ssetmask _sys_old_syscall /* _sys_sigprocmask */ +#endif + +/* + * These are system calls that haven't been implemented yet + * but have an entry in the table for future expansion.. + */ +#define _sys_quotactl _sys_ni_syscall + +#endif diff --git a/include/linux/sysv_fs.h b/include/linux/sysv_fs.h new file mode 100644 index 000000000..1583e7389 --- /dev/null +++ b/include/linux/sysv_fs.h @@ -0,0 +1,411 @@ +#ifndef _LINUX_SYSV_FS_H +#define _LINUX_SYSV_FS_H + +/* + * The SystemV/Coherent filesystem constants/structures/macros + */ + + +/* This code assumes + - a little endian processor like 386, + - sizeof(short) = 2, sizeof(int) = 4, sizeof(long) = 4, + - alignof(short) = 2, alignof(long) = 4. +*/ + +#ifdef __GNUC__ +#define __packed2__ __attribute__ ((packed, aligned(2))) +#else +#error I want gcc! +#endif + +#include <linux/stat.h> /* declares S_IFLNK etc. */ +#include <linux/sched.h> /* declares wake_up() */ +#include <linux/sysv_fs_sb.h> /* defines the sv_... shortcuts */ + + +/* Layout on disk */ +/* ============== */ + + +/* The block size is sb->sv_block_size which may be smaller than BLOCK_SIZE. */ + +/* zones (= data allocation units) are blocks */ + +/* On Coherent FS, 32 bit quantities are stored using (I quote the Coherent + manual) a "canonical byte ordering". This is the PDP-11 byte ordering: + x = 2^24 * byte3 + 2^16 * byte2 + 2^8 * byte1 + byte0 is stored + as { byte2, byte3, byte0, byte1 }. We need conversions. +*/ + +typedef unsigned long coh_ulong; + +static inline coh_ulong to_coh_ulong (unsigned long x) +{ + return ((x & 0xffff) << 16) | ((x & 0xffff0000) >> 16); +} + +static inline unsigned long from_coh_ulong (coh_ulong x) +{ + return ((x & 0xffff) << 16) | ((x & 0xffff0000) >> 16); +} + +/* inode numbers are 16 bit */ + +typedef unsigned short sysv_ino_t; + +/* Block numbers are 24 bit, sometimes stored in 32 bit. + On Coherent FS, they are always stored in PDP-11 manner: the least + significant 16 bits come last. +*/ + +typedef unsigned long sysv_zone_t; + +/* Among the blocks ... */ +/* Xenix FS, Coherent FS: block 0 is the boot block, block 1 the super-block. + SystemV FS: block 0 contains both the boot sector and the super-block. */ +/* The first inode zone is sb->sv_firstinodezone (1 or 2). */ + +/* Among the inodes ... */ +/* 0 is non-existent */ +#define SYSV_BADBL_INO 1 /* inode of bad blocks file */ +#define SYSV_ROOT_INO 2 /* inode of root directory */ + + +/* Xenix super-block data on disk */ +#define XENIX_NICINOD 100 /* number of inode cache entries */ +#define XENIX_NICFREE 100 /* number of free block list chunk entries */ +struct xenix_super_block { + unsigned short s_isize; /* index of first data zone */ + unsigned long s_fsize __packed2__; /* total number of zones of this fs */ + /* the start of the free block list: */ + unsigned short s_nfree; /* number of free blocks in s_free, <= XENIX_NICFREE */ + unsigned long s_free[XENIX_NICFREE]; /* first free block list chunk */ + /* the cache of free inodes: */ + unsigned short s_ninode; /* number of free inodes in s_inode, <= XENIX_NICINOD */ + sysv_ino_t s_inode[XENIX_NICINOD]; /* some free inodes */ + /* locks, not used by Linux: */ + char s_flock; /* lock during free block list manipulation */ + char s_ilock; /* lock during inode cache manipulation */ + char s_fmod; /* super-block modified flag */ + char s_ronly; /* flag whether fs is mounted read-only */ + unsigned long s_time __packed2__; /* time of last super block update */ + unsigned long s_tfree __packed2__; /* total number of free zones */ + unsigned short s_tinode; /* total number of free inodes */ + short s_dinfo[4]; /* device information ?? */ + char s_fname[6]; /* file system volume name */ + char s_fpack[6]; /* file system pack name */ + char s_clean; /* set to 0x46 when filesystem is properly unmounted */ + char s_fill[371]; + long s_magic; /* version of file system */ + long s_type; /* type of file system: 1 for 512 byte blocks + 2 for 1024 byte blocks */ +}; + +/* Xenix free list block on disk */ +struct xenix_freelist_chunk { + unsigned short fl_nfree; /* number of free blocks in fl_free, <= XENIX_NICFREE] */ + unsigned long fl_free[XENIX_NICFREE] __packed2__; +}; + +/* SystemV FS comes in two variants: + * sysv2: System V Release 2 (e.g. Microport), structure elements aligned(2). + * sysv4: System V Release 4 (e.g. Consensys), structure elements aligned(4). + */ +#define SYSV_NICINOD 100 /* number of inode cache entries */ +#define SYSV_NICFREE 50 /* number of free block list chunk entries */ + +/* SystemV4 super-block data on disk */ +struct sysv4_super_block { + unsigned short s_isize; /* index of first data zone */ + unsigned long s_fsize; /* total number of zones of this fs */ + /* the start of the free block list: */ + unsigned short s_nfree; /* number of free blocks in s_free, <= SYSV_NICFREE */ + unsigned long s_free[SYSV_NICFREE]; /* first free block list chunk */ + /* the cache of free inodes: */ + unsigned short s_ninode; /* number of free inodes in s_inode, <= SYSV_NICINOD */ + sysv_ino_t s_inode[SYSV_NICINOD]; /* some free inodes */ + /* locks, not used by Linux: */ + char s_flock; /* lock during free block list manipulation */ + char s_ilock; /* lock during inode cache manipulation */ + char s_fmod; /* super-block modified flag */ + char s_ronly; /* flag whether fs is mounted read-only */ + unsigned long s_time; /* time of last super block update */ + short s_dinfo[4]; /* device information ?? */ + unsigned long s_tfree; /* total number of free zones */ + unsigned short s_tinode; /* total number of free inodes */ + char s_fname[6]; /* file system volume name */ + char s_fpack[6]; /* file system pack name */ + long s_fill[12]; + long s_state; /* file system state */ + long s_magic; /* version of file system */ + long s_type; /* type of file system: 1 for 512 byte blocks + 2 for 1024 byte blocks */ +}; + +/* SystemV4 free list block on disk */ +struct sysv4_freelist_chunk { + unsigned short fl_nfree; /* number of free blocks in fl_free, <= SYSV_NICFREE] */ + unsigned long fl_free[SYSV_NICFREE]; +}; + +/* SystemV2 super-block data on disk */ +struct sysv2_super_block { + unsigned short s_isize; /* index of first data zone */ + unsigned long s_fsize __packed2__; /* total number of zones of this fs */ + /* the start of the free block list: */ + unsigned short s_nfree; /* number of free blocks in s_free, <= SYSV_NICFREE */ + unsigned long s_free[SYSV_NICFREE]; /* first free block list chunk */ + /* the cache of free inodes: */ + unsigned short s_ninode; /* number of free inodes in s_inode, <= SYSV_NICINOD */ + sysv_ino_t s_inode[SYSV_NICINOD]; /* some free inodes */ + /* locks, not used by Linux: */ + char s_flock; /* lock during free block list manipulation */ + char s_ilock; /* lock during inode cache manipulation */ + char s_fmod; /* super-block modified flag */ + char s_ronly; /* flag whether fs is mounted read-only */ + unsigned long s_time __packed2__; /* time of last super block update */ + short s_dinfo[4]; /* device information ?? */ + unsigned long s_tfree __packed2__; /* total number of free zones */ + unsigned short s_tinode; /* total number of free inodes */ + char s_fname[6]; /* file system volume name */ + char s_fpack[6]; /* file system pack name */ + long s_fill[14]; + long s_state; /* file system state */ + long s_magic; /* version of file system */ + long s_type; /* type of file system: 1 for 512 byte blocks + 2 for 1024 byte blocks */ +}; + +/* SystemV2 free list block on disk */ +struct sysv2_freelist_chunk { + unsigned short fl_nfree; /* number of free blocks in fl_free, <= SYSV_NICFREE] */ + unsigned long fl_free[SYSV_NICFREE] __packed2__; +}; + +/* Coherent super-block data on disk */ +#define COH_NICINOD 100 /* number of inode cache entries */ +#define COH_NICFREE 64 /* number of free block list chunk entries */ +struct coh_super_block { + unsigned short s_isize; /* index of first data zone */ + coh_ulong s_fsize __packed2__; /* total number of zones of this fs */ + /* the start of the free block list: */ + unsigned short s_nfree; /* number of free blocks in s_free, <= COH_NICFREE */ + coh_ulong s_free[COH_NICFREE] __packed2__; /* first free block list chunk */ + /* the cache of free inodes: */ + unsigned short s_ninode; /* number of free inodes in s_inode, <= COH_NICINOD */ + sysv_ino_t s_inode[COH_NICINOD]; /* some free inodes */ + /* locks, not used by Linux: */ + char s_flock; /* lock during free block list manipulation */ + char s_ilock; /* lock during inode cache manipulation */ + char s_fmod; /* super-block modified flag */ + char s_ronly; /* flag whether fs is mounted read-only */ + coh_ulong s_time __packed2__; /* time of last super block update */ + coh_ulong s_tfree __packed2__; /* total number of free zones */ + unsigned short s_tinode; /* total number of free inodes */ + unsigned short s_interleave_m; /* interleave factor */ + unsigned short s_interleave_n; + char s_fname[6]; /* file system volume name */ + char s_fpack[6]; /* file system pack name */ + unsigned long s_unique; /* zero, not used */ +}; + +/* Coherent free list block on disk */ +struct coh_freelist_chunk { + unsigned short fl_nfree; /* number of free blocks in fl_free, <= COH_NICFREE] */ + unsigned long fl_free[COH_NICFREE] __packed2__; +}; + + +/* SystemV/Coherent inode data on disk */ + +struct sysv_inode { + unsigned short i_mode; + unsigned short i_nlink; + unsigned short i_uid; + unsigned short i_gid; + unsigned long i_size; + union { /* directories, regular files, ... */ + char i_addb[3*(10+1+1+1)+1]; /* zone numbers: max. 10 data blocks, + * then 1 indirection block, + * then 1 double indirection block, + * then 1 triple indirection block. + * Then maybe a "file generation number" ?? + */ + /* devices */ + dev_t i_rdev; + /* named pipes on Coherent */ + struct { + char p_addp[30]; + short p_pnc; + short p_prx; + short p_pwx; + } i_p; + } i_a; + unsigned long i_atime; /* time of last access */ + unsigned long i_mtime; /* time of last modification */ + unsigned long i_ctime; /* time of creation */ +}; + +/* The admissible values for i_mode are listed in <linux/stat.h> : + * #define S_IFMT 00170000 mask for type + * #define S_IFREG 0100000 type = regular file + * #define S_IFBLK 0060000 type = block device + * #define S_IFDIR 0040000 type = directory + * #define S_IFCHR 0020000 type = character device + * #define S_IFIFO 0010000 type = named pipe + * #define S_ISUID 0004000 set user id + * #define S_ISGID 0002000 set group id + * #define S_ISVTX 0001000 save swapped text even after use + * Additionally for SystemV: + * #define S_IFLNK 0120000 type = symbolic link + * #define S_IFNAM 0050000 type = XENIX special named file ?? + * Additionally for Coherent: + * #define S_IFMPB 0070000 type = multiplexed block device ?? + * #define S_IFMPC 0030000 type = multiplexed character device ?? + * + * Since Coherent doesn't know about symbolic links, we use a kludgey + * implementation of symbolic links: i_mode = COH_KLUDGE_SYMLINK_MODE + * denotes a symbolic link. When a regular file should get this mode by + * accident, it is automatically converted to COH_KLUDGE_NOT_SYMLINK. + * We use S_IFREG because only regular files (and Coherent pipes...) can have + * data blocks with arbitrary contents associated with them, and S_ISVTX + * ("save swapped text after use") because it is unused on both Linux and + * Coherent: Linux does much more intelligent paging, and Coherent hasn't + * virtual memory at all. + * Same trick for Xenix. + */ +#define COH_KLUDGE_SYMLINK_MODE (S_IFREG | S_ISVTX) +#define COH_KLUDGE_NOT_SYMLINK (S_IFREG | S_ISVTX | S_IRUSR) /* force read access */ +extern inline mode_t from_coh_imode(unsigned short mode) +{ + if (mode == COH_KLUDGE_SYMLINK_MODE) + return (S_IFLNK | 0777); + else + return mode; +} +extern inline unsigned short to_coh_imode(mode_t mode) +{ + if (S_ISLNK(mode)) + return COH_KLUDGE_SYMLINK_MODE; + else if (mode == COH_KLUDGE_SYMLINK_MODE) + return COH_KLUDGE_NOT_SYMLINK; + else + return mode; +} + +/* Admissible values for i_nlink: 0.._LINK_MAX */ +#define XENIX_LINK_MAX 126 /* ?? */ +#define SYSV_LINK_MAX 126 /* 127? 251? */ +#define COH_LINK_MAX 10000 /* max number of hard links to an inode */ + +/* The number of inodes per block is + sb->sv_inodes_per_block = block_size / sizeof(struct sysv_inode) */ +/* The number of indirect pointers per block is + sb->sv_ind_per_block = block_size / sizeof(unsigned long) */ + + +/* SystemV/Coherent directory entry on disk */ + +#define SYSV_NAMELEN 14 /* max size of name in struct sysv_dir_entry */ + +struct sysv_dir_entry { + sysv_ino_t inode; + char name[SYSV_NAMELEN]; /* up to 14 characters, the rest are zeroes */ +}; + +#define SYSV_DIRSIZE sizeof(struct sysv_dir_entry) /* size of every directory entry */ + + +#ifdef __KERNEL__ + +/* Operations */ +/* ========== */ + + +/* identify the FS in memory */ +#define FSTYPE_XENIX 1 +#define FSTYPE_SYSV4 2 +#define FSTYPE_SYSV2 3 +#define FSTYPE_COH 4 + +#define SYSV_MAGIC_BASE 0x012FF7B3 + +#define XENIX_SUPER_MAGIC (SYSV_MAGIC_BASE+FSTYPE_XENIX) +#define SYSV4_SUPER_MAGIC (SYSV_MAGIC_BASE+FSTYPE_SYSV4) +#define SYSV2_SUPER_MAGIC (SYSV_MAGIC_BASE+FSTYPE_SYSV2) +#define COH_SUPER_MAGIC (SYSV_MAGIC_BASE+FSTYPE_COH) + +/* sv_get_hash_table(sb,dev,block) is equivalent to get_hash_table(dev,block,block_size) */ +static inline struct buffer_head * +sv_get_hash_table (struct super_block *sb, int dev, unsigned int block) +{ + return get_hash_table (dev, block + sb->sv_block_base, sb->sv_block_size); +} + +/* sv_getblk(sb,dev,block) is equivalent to getblk(dev,block,block_size) */ +static inline struct buffer_head * +sv_getblk (struct super_block *sb, int dev, unsigned int block) +{ + return getblk (dev, block + sb->sv_block_base, sb->sv_block_size); +} + +/* sv_bread(sb,dev,block) is equivalent to bread(dev,block,block_size) */ +static inline struct buffer_head * +sv_bread (struct super_block *sb, int dev, unsigned int block) +{ + return bread (dev, block + sb->sv_block_base, sb->sv_block_size); +} + + +/* + * Function prototypes + */ + +extern int sysv_lookup(struct inode * dir,const char * name, int len, + struct inode ** result); +extern int sysv_create(struct inode * dir,const char * name, int len, int mode, + struct inode ** result); +extern int sysv_mkdir(struct inode * dir, const char * name, int len, int mode); +extern int sysv_rmdir(struct inode * dir, const char * name, int len); +extern int sysv_unlink(struct inode * dir, const char * name, int len); +extern int sysv_symlink(struct inode * inode, const char * name, int len, + const char * symname); +extern int sysv_link(struct inode * oldinode, struct inode * dir, const char * name, int len); +extern int sysv_mknod(struct inode * dir, const char * name, int len, int mode, int rdev); +extern int sysv_rename(struct inode * old_dir, const char * old_name, int old_len, + struct inode * new_dir, const char * new_name, int new_len); +extern struct inode * sysv_new_inode(const struct inode * dir); +extern void sysv_free_inode(struct inode * inode); +extern unsigned long sysv_count_free_inodes(struct super_block *sb); +extern int sysv_new_block(struct super_block * sb); +extern void sysv_free_block(struct super_block * sb, unsigned int block); +extern unsigned long sysv_count_free_blocks(struct super_block *sb); + +extern int sysv_bmap(struct inode *,int); + +extern struct buffer_head * sysv_getblk(struct inode *, unsigned int, int); +extern struct buffer_head * sysv_file_bread(struct inode *, int, int); +extern int sysv_file_read(struct inode *, struct file *, char *, int); + +extern void sysv_truncate(struct inode *); +extern void sysv_put_super(struct super_block *); +extern struct super_block *sysv_read_super(struct super_block *,void *,int); +extern void sysv_write_super(struct super_block *); +extern void sysv_read_inode(struct inode *); +extern int sysv_notify_change(struct inode *, struct iattr *); +extern void sysv_write_inode(struct inode *); +extern void sysv_put_inode(struct inode *); +extern void sysv_statfs(struct super_block *, struct statfs *); +extern int sysv_sync_inode(struct inode *); +extern int sysv_sync_file(struct inode *, struct file *); +extern int sysv_mmap(struct inode *, struct file *, struct vm_area_struct *); + +extern struct inode_operations sysv_file_inode_operations; +extern struct inode_operations sysv_file_inode_operations_with_bmap; +extern struct inode_operations sysv_dir_inode_operations; +extern struct inode_operations sysv_symlink_inode_operations; + +#endif /* __KERNEL__ */ + +#endif + diff --git a/include/linux/sysv_fs_i.h b/include/linux/sysv_fs_i.h new file mode 100644 index 000000000..56a63f1ef --- /dev/null +++ b/include/linux/sysv_fs_i.h @@ -0,0 +1,16 @@ +#ifndef _SYSV_FS_I +#define _SYSV_FS_I + +/* + * SystemV/Coherent FS inode data in memory + */ +struct sysv_inode_info { + unsigned long i_data[10+1+1+1]; /* zone numbers: max. 10 data blocks, + * then 1 indirection block, + * then 1 double indirection block, + * then 1 triple indirection block. + */ +}; + +#endif + diff --git a/include/linux/sysv_fs_sb.h b/include/linux/sysv_fs_sb.h new file mode 100644 index 000000000..c95e071b2 --- /dev/null +++ b/include/linux/sysv_fs_sb.h @@ -0,0 +1,120 @@ +#ifndef _SYSV_FS_SB +#define _SYSV_FS_SB + +/* + * SystemV/Coherent super-block data in memory + * The SystemV/Coherent superblock contains dynamic data (it gets modified + * while the system is running). This is in contrast to the Minix and Berkeley + * filesystems (where the superblock is never modified). This affects the + * sync() operation: we must keep the superblock in a disk buffer and use this + * one as our "working copy". + */ + +struct sysv_sb_info { + int s_type; /* file system type: FSTYPE_{XENIX|SYSV|COH} */ + unsigned int s_block_size; /* zone size, = 512 or = 1024 */ + unsigned int s_block_size_1; /* block_size - 1 */ + unsigned int s_block_size_bits; /* log2(block_size) */ + unsigned int s_block_size_ratio; /* BLOCK_SIZE / block_size */ + unsigned int s_block_size_ratio_bits; /* log2(block_size_ratio) */ + char s_convert; /* flag whether byte ordering requires conversion */ + char s_kludge_symlinks; /* flag whether symlinks have a kludgey mode */ + char s_truncate; /* if 1: names > SYSV_NAMELEN chars are truncated */ + /* if 0: they are disallowed (ENAMETOOLONG) */ + nlink_t s_link_max; /* max number of hard links to a file */ + unsigned int s_inodes_per_block; /* number of inodes per block */ + unsigned int s_inodes_per_block_1; /* inodes_per_block - 1 */ + unsigned int s_inodes_per_block_bits; /* log2(inodes_per_block) */ + unsigned int s_ind_per_block; /* number of indirections per block */ + unsigned int s_ind_per_block_1; /* ind_per_block - 1 */ + unsigned int s_ind_per_block_bits; /* log2(ind_per_block) */ + unsigned int s_ind_per_block_2; /* ind_per_block ^ 2 */ + unsigned int s_ind_per_block_2_1; /* ind_per_block ^ 2 - 1 */ + unsigned int s_ind_per_block_2_bits; /* log2(ind_per_block^2) */ + unsigned int s_ind_per_block_3; /* ind_per_block ^ 3 */ + unsigned int s_ind_per_block_block_size_1; /* ind_per_block*block_size - 1 */ + unsigned int s_ind_per_block_block_size_bits; /* log2(ind_per_block*block_size) */ + unsigned int s_ind_per_block_2_block_size_1; /* ind_per_block^2 * block_size - 1 */ + unsigned int s_ind_per_block_2_block_size_bits; /* log2(ind_per_block^2 * block_size) */ + unsigned int s_ind0_size; /* 10 * block_size */ + unsigned int s_ind1_size; /* (10 + ipb) * block_size */ + unsigned int s_ind2_size; /* (10 + ipb + ipb^2) * block_size */ + unsigned int s_toobig_block; /* 10 + ipb + ipb^2 + ipb^3 */ + unsigned int s_block_base; /* physical block number of block 0 */ + unsigned short s_fic_size; /* free inode cache size, NICINOD */ + unsigned short s_flc_size; /* free block list chunk size, NICFREE */ + /* The superblock is kept in one or two disk buffers: */ + struct buffer_head *s_bh1; + struct buffer_head *s_bh2; + /* These are pointers into the disk buffer, to compensate for + different superblock layout. */ + char * s_sbd1; /* entire superblock data, for part 1 */ + char * s_sbd2; /* entire superblock data, for part 2 */ + unsigned short *s_sb_fic_count; /* pointer to s_sbd->s_ninode */ + unsigned short *s_sb_fic_inodes; /* pointer to s_sbd->s_inode */ + unsigned short *s_sb_total_free_inodes; /* pointer to s_sbd->s_tinode */ + unsigned short *s_sb_flc_count; /* pointer to s_sbd->s_nfree */ + unsigned long *s_sb_flc_blocks; /* pointer to s_sbd->s_free */ + unsigned long *s_sb_total_free_blocks;/* pointer to s_sbd->s_tfree */ + unsigned long *s_sb_time; /* pointer to s_sbd->s_time */ + /* We keep those superblock entities that don't change here; + this saves us an indirection and perhaps a conversion. */ + unsigned long s_firstinodezone; /* index of first inode zone */ + unsigned long s_firstdatazone; /* same as s_sbd->s_isize */ + unsigned long s_ninodes; /* total number of inodes */ + unsigned long s_ndatazones; /* total number of data zones */ + unsigned long s_nzones; /* same as s_sbd->s_fsize */ +}; +/* The fields s_block_size_ratio, s_ind_per_block_2_1, s_toobig_block are currently unused. */ + +/* sv_ == u.sysv_sb.s_ */ +#define sv_type u.sysv_sb.s_type +#define sv_block_size u.sysv_sb.s_block_size +#define sv_block_size_1 u.sysv_sb.s_block_size_1 +#define sv_block_size_bits u.sysv_sb.s_block_size_bits +#define sv_block_size_ratio u.sysv_sb.s_block_size_ratio +#define sv_block_size_ratio_bits u.sysv_sb.s_block_size_ratio_bits +#define sv_convert u.sysv_sb.s_convert +#define sv_kludge_symlinks u.sysv_sb.s_kludge_symlinks +#define sv_truncate u.sysv_sb.s_truncate +#define sv_link_max u.sysv_sb.s_link_max +#define sv_inodes_per_block u.sysv_sb.s_inodes_per_block +#define sv_inodes_per_block_1 u.sysv_sb.s_inodes_per_block_1 +#define sv_inodes_per_block_bits u.sysv_sb.s_inodes_per_block_bits +#define sv_ind_per_block u.sysv_sb.s_ind_per_block +#define sv_ind_per_block_1 u.sysv_sb.s_ind_per_block_1 +#define sv_ind_per_block_bits u.sysv_sb.s_ind_per_block_bits +#define sv_ind_per_block_2 u.sysv_sb.s_ind_per_block_2 +#define sv_ind_per_block_2_1 u.sysv_sb.s_ind_per_block_2_1 +#define sv_ind_per_block_2_bits u.sysv_sb.s_ind_per_block_2_bits +#define sv_ind_per_block_3 u.sysv_sb.s_ind_per_block_3 +#define sv_ind_per_block_block_size_1 u.sysv_sb.s_ind_per_block_block_size_1 +#define sv_ind_per_block_block_size_bits u.sysv_sb.s_ind_per_block_block_size_bits +#define sv_ind_per_block_2_block_size_1 u.sysv_sb.s_ind_per_block_2_block_size_1 +#define sv_ind_per_block_2_block_size_bits u.sysv_sb.s_ind_per_block_2_block_size_bits +#define sv_ind0_size u.sysv_sb.s_ind0_size +#define sv_ind1_size u.sysv_sb.s_ind1_size +#define sv_ind2_size u.sysv_sb.s_ind2_size +#define sv_toobig_block u.sysv_sb.s_toobig_block +#define sv_block_base u.sysv_sb.s_block_base +#define sv_fic_size u.sysv_sb.s_fic_size +#define sv_flc_size u.sysv_sb.s_flc_size +#define sv_bh1 u.sysv_sb.s_bh1 +#define sv_bh2 u.sysv_sb.s_bh2 +#define sv_sbd1 u.sysv_sb.s_sbd1 +#define sv_sbd2 u.sysv_sb.s_sbd2 +#define sv_sb_fic_count u.sysv_sb.s_sb_fic_count +#define sv_sb_fic_inodes u.sysv_sb.s_sb_fic_inodes +#define sv_sb_total_free_inodes u.sysv_sb.s_sb_total_free_inodes +#define sv_sb_flc_count u.sysv_sb.s_sb_flc_count +#define sv_sb_flc_blocks u.sysv_sb.s_sb_flc_blocks +#define sv_sb_total_free_blocks u.sysv_sb.s_sb_total_free_blocks +#define sv_sb_time u.sysv_sb.s_sb_time +#define sv_firstinodezone u.sysv_sb.s_firstinodezone +#define sv_firstdatazone u.sysv_sb.s_firstdatazone +#define sv_ninodes u.sysv_sb.s_ninodes +#define sv_ndatazones u.sysv_sb.s_ndatazones +#define sv_nzones u.sysv_sb.s_nzones + +#endif + diff --git a/include/linux/tasks.h b/include/linux/tasks.h new file mode 100644 index 000000000..12facf200 --- /dev/null +++ b/include/linux/tasks.h @@ -0,0 +1,9 @@ +#ifndef _LINUX_TASKS_H +#define _LINUX_TASKS_H + +/* + * This is the maximum nr of tasks - change it if you need to + */ +#define NR_TASKS 128 + +#endif diff --git a/include/linux/tcp.h b/include/linux/tcp.h new file mode 100644 index 000000000..4acc22cae --- /dev/null +++ b/include/linux/tcp.h @@ -0,0 +1,83 @@ +/* + * INET An implementation of the TCP/IP protocol suite for the LINUX + * operating system. INET is implemented using the BSD Socket + * interface as the means of communication with the user level. + * + * Definitions for the TCP protocol. + * + * Version: @(#)tcp.h 1.0.2 04/28/93 + * + * Author: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> + * + * 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. + */ +#ifndef _LINUX_TCP_H +#define _LINUX_TCP_H + +#include <asm/types.h> + +#define HEADER_SIZE 64 /* maximum header size */ + + +struct tcphdr { + u16 source; + u16 dest; + u32 seq; + u32 ack_seq; +#if defined(__i386__) + u16 res1:4, + doff:4, + fin:1, + syn:1, + rst:1, + psh:1, + ack:1, + urg:1, + res2:2; +#elif defined(__mc68000__) + u16 res2:2, + urg:1, + ack:1, + psh:1, + rst:1, + syn:1, + fin:1, + doff:4, + res1:4; +#elif defined(__alpha__) + u16 res1:4, + doff:4, + fin:1, + syn:1, + rst:1, + psh:1, + ack:1, + urg:1, + res2:2; +#else +#error "Adjust this structure for your cpu alignment rules" +#endif + u16 window; + u16 check; + u16 urg_ptr; +}; + + +enum { + TCP_ESTABLISHED = 1, + TCP_SYN_SENT, + TCP_SYN_RECV, + TCP_FIN_WAIT1, + TCP_FIN_WAIT2, + TCP_TIME_WAIT, + TCP_CLOSE, + TCP_CLOSE_WAIT, + TCP_LAST_ACK, + TCP_LISTEN, + TCP_CLOSING /* now a valid state */ +}; + +#endif /* _LINUX_TCP_H */ diff --git a/include/linux/termios.h b/include/linux/termios.h new file mode 100644 index 000000000..c06864acd --- /dev/null +++ b/include/linux/termios.h @@ -0,0 +1,254 @@ +#ifndef _LINUX_TERMIOS_H +#define _LINUX_TERMIOS_H + +#include <linux/types.h> + +/* 0x54 is just a magic number to make these relatively unique ('T') */ + +#define TCGETS 0x5401 +#define TCSETS 0x5402 +#define TCSETSW 0x5403 +#define TCSETSF 0x5404 +#define TCGETA 0x5405 +#define TCSETA 0x5406 +#define TCSETAW 0x5407 +#define TCSETAF 0x5408 +#define TCSBRK 0x5409 +#define TCXONC 0x540A +#define TCFLSH 0x540B +#define TIOCEXCL 0x540C +#define TIOCNXCL 0x540D +#define TIOCSCTTY 0x540E +#define TIOCGPGRP 0x540F +#define TIOCSPGRP 0x5410 +#define TIOCOUTQ 0x5411 +#define TIOCSTI 0x5412 +#define TIOCGWINSZ 0x5413 +#define TIOCSWINSZ 0x5414 +#define TIOCMGET 0x5415 +#define TIOCMBIS 0x5416 +#define TIOCMBIC 0x5417 +#define TIOCMSET 0x5418 +#define TIOCGSOFTCAR 0x5419 +#define TIOCSSOFTCAR 0x541A +#define FIONREAD 0x541B +#define TIOCINQ FIONREAD +#define TIOCLINUX 0x541C +#define TIOCCONS 0x541D +#define TIOCGSERIAL 0x541E +#define TIOCSSERIAL 0x541F +#define TIOCPKT 0x5420 +#define FIONBIO 0x5421 +#define TIOCNOTTY 0x5422 +#define TIOCSETD 0x5423 +#define TIOCGETD 0x5424 +#define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ +#define FIONCLEX 0x5450 /* these numbers need to be adjusted. */ +#define FIOCLEX 0x5451 +#define FIOASYNC 0x5452 +#define TIOCSERCONFIG 0x5453 +#define TIOCSERGWILD 0x5454 +#define TIOCSERSWILD 0x5455 +#define TIOCGLCKTRMIOS 0x5456 +#define TIOCSLCKTRMIOS 0x5457 +#define TIOCSERGSTRUCT 0x5458 /* For debugging only */ +#define TIOCSERGETLSR 0x5459 /* Get line status register */ + +/* Used for packet mode */ +#define TIOCPKT_DATA 0 +#define TIOCPKT_FLUSHREAD 1 +#define TIOCPKT_FLUSHWRITE 2 +#define TIOCPKT_STOP 4 +#define TIOCPKT_START 8 +#define TIOCPKT_NOSTOP 16 +#define TIOCPKT_DOSTOP 32 + +struct winsize { + unsigned short ws_row; + unsigned short ws_col; + unsigned short ws_xpixel; + unsigned short ws_ypixel; +}; + +#define NCC 8 +struct termio { + unsigned short c_iflag; /* input mode flags */ + unsigned short c_oflag; /* output mode flags */ + unsigned short c_cflag; /* control mode flags */ + unsigned short c_lflag; /* local mode flags */ + unsigned char c_line; /* line discipline */ + unsigned char c_cc[NCC]; /* control characters */ +}; + +#define NCCS 19 +struct termios { + tcflag_t c_iflag; /* input mode flags */ + tcflag_t c_oflag; /* output mode flags */ + tcflag_t c_cflag; /* control mode flags */ + tcflag_t c_lflag; /* local mode flags */ + cc_t c_line; /* line discipline */ + cc_t c_cc[NCCS]; /* control characters */ +}; + +/* c_cc characters */ +#define VINTR 0 +#define VQUIT 1 +#define VERASE 2 +#define VKILL 3 +#define VEOF 4 +#define VTIME 5 +#define VMIN 6 +#define VSWTC 7 +#define VSTART 8 +#define VSTOP 9 +#define VSUSP 10 +#define VEOL 11 +#define VREPRINT 12 +#define VDISCARD 13 +#define VWERASE 14 +#define VLNEXT 15 +#define VEOL2 16 + +/* c_iflag bits */ +#define IGNBRK 0000001 +#define BRKINT 0000002 +#define IGNPAR 0000004 +#define PARMRK 0000010 +#define INPCK 0000020 +#define ISTRIP 0000040 +#define INLCR 0000100 +#define IGNCR 0000200 +#define ICRNL 0000400 +#define IUCLC 0001000 +#define IXON 0002000 +#define IXANY 0004000 +#define IXOFF 0010000 +#define IMAXBEL 0020000 + +/* c_oflag bits */ +#define OPOST 0000001 +#define OLCUC 0000002 +#define ONLCR 0000004 +#define OCRNL 0000010 +#define ONOCR 0000020 +#define ONLRET 0000040 +#define OFILL 0000100 +#define OFDEL 0000200 +#define NLDLY 0000400 +#define NL0 0000000 +#define NL1 0000400 +#define CRDLY 0003000 +#define CR0 0000000 +#define CR1 0001000 +#define CR2 0002000 +#define CR3 0003000 +#define TABDLY 0014000 +#define TAB0 0000000 +#define TAB1 0004000 +#define TAB2 0010000 +#define TAB3 0014000 +#define XTABS 0014000 +#define BSDLY 0020000 +#define BS0 0000000 +#define BS1 0020000 +#define VTDLY 0040000 +#define VT0 0000000 +#define VT1 0040000 +#define FFDLY 0100000 +#define FF0 0000000 +#define FF1 0100000 + +/* c_cflag bit meaning */ +#define CBAUD 0010017 +#define B0 0000000 /* hang up */ +#define B50 0000001 +#define B75 0000002 +#define B110 0000003 +#define B134 0000004 +#define B150 0000005 +#define B200 0000006 +#define B300 0000007 +#define B600 0000010 +#define B1200 0000011 +#define B1800 0000012 +#define B2400 0000013 +#define B4800 0000014 +#define B9600 0000015 +#define B19200 0000016 +#define B38400 0000017 +#define EXTA B19200 +#define EXTB B38400 +#define CSIZE 0000060 +#define CS5 0000000 +#define CS6 0000020 +#define CS7 0000040 +#define CS8 0000060 +#define CSTOPB 0000100 +#define CREAD 0000200 +#define PARENB 0000400 +#define PARODD 0001000 +#define HUPCL 0002000 +#define CLOCAL 0004000 +#define CBAUDEX 0010000 +#define B57600 0010001 +#define B115200 0010002 +#define CIBAUD 002003600000 /* input baud rate (not used) */ +#define CRTSCTS 020000000000 /* flow control */ + +/* c_lflag bits */ +#define ISIG 0000001 +#define ICANON 0000002 +#define XCASE 0000004 +#define ECHO 0000010 +#define ECHOE 0000020 +#define ECHOK 0000040 +#define ECHONL 0000100 +#define NOFLSH 0000200 +#define TOSTOP 0000400 +#define ECHOCTL 0001000 +#define ECHOPRT 0002000 +#define ECHOKE 0004000 +#define FLUSHO 0010000 +#define PENDIN 0040000 +#define IEXTEN 0100000 + +/* modem lines */ +#define TIOCM_LE 0x001 +#define TIOCM_DTR 0x002 +#define TIOCM_RTS 0x004 +#define TIOCM_ST 0x008 +#define TIOCM_SR 0x010 +#define TIOCM_CTS 0x020 +#define TIOCM_CAR 0x040 +#define TIOCM_RNG 0x080 +#define TIOCM_DSR 0x100 +#define TIOCM_CD TIOCM_CAR +#define TIOCM_RI TIOCM_RNG + +/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */ +#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */ + + +/* tcflow() and TCXONC use these */ +#define TCOOFF 0 +#define TCOON 1 +#define TCIOFF 2 +#define TCION 3 + +/* tcflush() and TCFLSH use these */ +#define TCIFLUSH 0 +#define TCOFLUSH 1 +#define TCIOFLUSH 2 + +/* tcsetattr uses these */ +#define TCSANOW 0 +#define TCSADRAIN 1 +#define TCSAFLUSH 2 + +/* line disciplines */ +#define N_TTY 0 +#define N_SLIP 1 +#define N_MOUSE 2 +#define N_PPP 3 + +#endif diff --git a/include/linux/time.h b/include/linux/time.h new file mode 100644 index 000000000..65891b748 --- /dev/null +++ b/include/linux/time.h @@ -0,0 +1,35 @@ +#ifndef _LINUX_TIME_H +#define _LINUX_TIME_H + +struct timeval { + long tv_sec; /* seconds */ + long tv_usec; /* microseconds */ +}; + +struct timezone { + int tz_minuteswest; /* minutes west of Greenwich */ + int tz_dsttime; /* type of dst correction */ +}; + +#define NFDBITS __NFDBITS + +#define FD_SETSIZE __FD_SETSIZE +#define FD_SET(fd,fdsetp) __FD_SET(fd,fdsetp) +#define FD_CLR(fd,fdsetp) __FD_CLR(fd,fdsetp) +#define FD_ISSET(fd,fdsetp) __FD_ISSET(fd,fdsetp) +#define FD_ZERO(fdsetp) __FD_ZERO(fdsetp) + +/* + * Names of the interval timers, and structure + * defining a timer setting. + */ +#define ITIMER_REAL 0 +#define ITIMER_VIRTUAL 1 +#define ITIMER_PROF 2 + +struct itimerval { + struct timeval it_interval; /* timer interval */ + struct timeval it_value; /* current value */ +}; + +#endif diff --git a/include/linux/timer.h b/include/linux/timer.h new file mode 100644 index 000000000..a28616a2a --- /dev/null +++ b/include/linux/timer.h @@ -0,0 +1,89 @@ +#ifndef _LINUX_TIMER_H +#define _LINUX_TIMER_H + +/* + * DON'T CHANGE THESE!! Most of them are hardcoded into some assembly language + * as well as being defined here. + */ + +/* + * The timers are: + * + * BLANK_TIMER console screen-saver timer + * + * BEEP_TIMER console beep timer + * + * RS_TIMER timer for the RS-232 ports + * + * HD_TIMER harddisk timer + * + * HD_TIMER2 (atdisk2 patches) + * + * FLOPPY_TIMER floppy disk timer (not used right now) + * + * SCSI_TIMER scsi.c timeout timer + * + * NET_TIMER tcp/ip timeout timer + * + * COPRO_TIMER 387 timeout for buggy hardware.. + * + * QIC02_TAPE_TIMER timer for QIC-02 tape driver (it's not hardcoded) + * + * MCD_TIMER Mitsumi CD-ROM Timer + */ + +#define BLANK_TIMER 0 +#define BEEP_TIMER 1 +#define RS_TIMER 2 + +#define HD_TIMER 16 +#define FLOPPY_TIMER 17 +#define SCSI_TIMER 18 +#define NET_TIMER 19 +#define SOUND_TIMER 20 +#define COPRO_TIMER 21 + +#define QIC02_TAPE_TIMER 22 /* hhb */ +#define MCD_TIMER 23 + +#define HD_TIMER2 24 + +struct timer_struct { + unsigned long expires; + void (*fn)(void); +}; + +extern unsigned long timer_active; +extern struct timer_struct timer_table[32]; + +/* + * This is completely separate from the above, and is the + * "new and improved" way of handling timers more dynamically. + * Hopefully efficient and general enough for most things. + * + * The "hardcoded" timers above are still useful for well- + * defined problems, but the timer-list is probably better + * when you need multiple outstanding timers or similar. + * + * The "data" field is in case you want to use the same + * timeout function for several timeouts. You can use this + * to distinguish between the different invocations. + */ +struct timer_list { + struct timer_list *next; + struct timer_list *prev; + unsigned long expires; + unsigned long data; + void (*function)(unsigned long); +}; + +extern void add_timer(struct timer_list * timer); +extern int del_timer(struct timer_list * timer); + +extern inline void init_timer(struct timer_list * timer) +{ + timer->next = NULL; + timer->prev = NULL; +} + +#endif diff --git a/include/linux/times.h b/include/linux/times.h new file mode 100644 index 000000000..569349ef4 --- /dev/null +++ b/include/linux/times.h @@ -0,0 +1,11 @@ +#ifndef _LINUX_TIMES_H +#define _LINUX_TIMES_H + +struct tms { + clock_t tms_utime; + clock_t tms_stime; + clock_t tms_cutime; + clock_t tms_cstime; +}; + +#endif diff --git a/include/linux/timex.h b/include/linux/timex.h new file mode 100644 index 000000000..ce82e020f --- /dev/null +++ b/include/linux/timex.h @@ -0,0 +1,139 @@ +/***************************************************************************** + * * + * Copyright (c) David L. Mills 1993 * + * * + * Permission to use, copy, modify, and distribute this software and its * + * documentation for any purpose and without fee is hereby granted, provided * + * that the above copyright notice appears in all copies and that both the * + * copyright notice and this permission notice appear in supporting * + * documentation, and that the name University of Delaware not be used in * + * advertising or publicity pertaining to distribution of the software * + * without specific, written prior permission. The University of Delaware * + * makes no representations about the suitability this software for any * + * purpose. It is provided "as is" without express or implied warranty. * + * * + *****************************************************************************/ + +/* + * Modification history timex.h + * + * 17 Sep 93 David L. Mills + * Created file $NTP/include/sys/timex.h + * 07 Oct 93 Torsten Duwe + * Derived linux/timex.h + */ +#ifndef _LINUX_TIMEX_H +#define _LINUX_TIMEX_H + +/* + * The following defines establish the engineering parameters of the PLL + * model. The HZ variable establishes the timer interrupt frequency, 100 Hz + * for the SunOS kernel, 256 Hz for the Ultrix kernel and 1024 Hz for the + * OSF/1 kernel. The SHIFT_HZ define expresses the same value as the + * nearest power of two in order to avoid hardware multiply operations. + */ +#define SHIFT_HZ 7 /* log2(HZ) */ + +/* + * The SHIFT_KG and SHIFT_KF defines establish the damping of the PLL + * and are chosen by analysis for a slightly underdamped convergence + * characteristic. The MAXTC define establishes the maximum time constant + * of the PLL. With the parameters given and the default time constant of + * zero, the PLL will converge in about 15 minutes. + */ +#define SHIFT_KG 8 /* shift for phase increment */ +#define SHIFT_KF 20 /* shift for frequency increment */ +#define MAXTC 6 /* maximum time constant (shift) */ + +/* + * The SHIFT_SCALE define establishes the decimal point of the time_phase + * variable which serves as a an extension to the low-order bits of the + * system clock variable. The SHIFT_UPDATE define establishes the decimal + * point of the time_offset variable which represents the current offset + * with respect to standard time. The FINEUSEC define represents 1 usec in + * scaled units. + */ +#define SHIFT_SCALE 24 /* shift for phase scale factor */ +#define SHIFT_UPDATE (SHIFT_KG + MAXTC) /* shift for offset scale factor */ +#define FINEUSEC (1 << SHIFT_SCALE) /* 1 us in scaled units */ + +#define MAXPHASE 128000 /* max phase error (us) */ +#define MAXFREQ 100 /* max frequency error (ppm) */ +#define MINSEC 16 /* min interval between updates (s) */ +#define MAXSEC 1200 /* max interval between updates (s) */ + +#define CLOCK_TICK_RATE 1193180 /* Underlying HZ */ +#define CLOCK_TICK_FACTOR 20 /* Factor of both 1000000 and CLOCK_TICK_RATE */ +#define LATCH ((CLOCK_TICK_RATE + HZ/2) / HZ) /* For divider */ + +#define FINETUNE (((((LATCH * HZ - CLOCK_TICK_RATE) << SHIFT_HZ) * \ + (1000000/CLOCK_TICK_FACTOR) / (CLOCK_TICK_RATE/CLOCK_TICK_FACTOR)) \ + << (SHIFT_SCALE-SHIFT_HZ)) / HZ) + +/* + * syscall interface - used (mainly by NTP daemon) + * to discipline kernel clock oscillator + */ +struct timex { + int mode; /* mode selector */ + long offset; /* time offset (usec) */ + long frequency; /* frequency offset (scaled ppm) */ + long maxerror; /* maximum error (usec) */ + long esterror; /* estimated error (usec) */ + int status; /* clock command/status */ + long time_constant; /* pll time constant */ + long precision; /* clock precision (usec) (read only) */ + long tolerance; /* clock frequency tolerance (ppm) + * (read only) + */ + struct timeval time; /* (read only) */ + long tick; /* (modified) usecs between clock ticks */ +}; + +/* + * Mode codes (timex.mode) + */ +#define ADJ_OFFSET 0x0001 /* time offset */ +#define ADJ_FREQUENCY 0x0002 /* frequency offset */ +#define ADJ_MAXERROR 0x0004 /* maximum time error */ +#define ADJ_ESTERROR 0x0008 /* estimated time error */ +#define ADJ_STATUS 0x0010 /* clock status */ +#define ADJ_TIMECONST 0x0020 /* pll time constant */ +#define ADJ_TICK 0x4000 /* tick value */ +#define ADJ_OFFSET_SINGLESHOT 0x8001 /* old-fashioned adjtime */ + +/* + * Clock command/status codes (timex.status) + */ +#define TIME_OK 0 /* clock synchronized */ +#define TIME_INS 1 /* insert leap second */ +#define TIME_DEL 2 /* delete leap second */ +#define TIME_OOP 3 /* leap second in progress */ +#define TIME_BAD 4 /* clock not synchronized */ + +#ifdef __KERNEL__ +/* + * kernel variables + */ +extern long tick; /* timer interrupt period */ +extern int tickadj; /* amount of adjustment per tick */ + +/* + * phase-lock loop variables + */ +extern int time_status; /* clock synchronization status */ +extern long time_offset; /* time adjustment (us) */ +extern long time_constant; /* pll time constant */ +extern long time_tolerance; /* frequency tolerance (ppm) */ +extern long time_precision; /* clock precision (us) */ +extern long time_maxerror; /* maximum error */ +extern long time_esterror; /* estimated error */ +extern long time_phase; /* phase offset (scaled us) */ +extern long time_freq; /* frequency offset (scaled ppm) */ +extern long time_adj; /* tick adjust (scaled 1 / HZ) */ +extern long time_reftime; /* time at last adjustment (s) */ + +extern long time_adjust; /* The amount of adjtime left */ +#endif /* KERNEL */ + +#endif /* LINUX_TIMEX_H */ diff --git a/include/linux/tpqic02.h b/include/linux/tpqic02.h new file mode 100644 index 000000000..ff67a7ed6 --- /dev/null +++ b/include/linux/tpqic02.h @@ -0,0 +1,693 @@ +/* $Id: tpqic02.h,v 0.25 1994/07/21 02:16:30 root Exp root $ + * + * Include file for QIC-02 driver for Linux. + * + * Copyright (c) 1992, 1993, 1994 by H. H. Bergman. All rights reserved. + * + * ******* USER CONFIG SECTION BELOW (Near line 70) ******* + */ + +#ifndef _LINUX_TPQIC02_H +#define _LINUX_TPQIC02_H + +#include <linux/config.h> + +#if CONFIG_QIC02_TAPE + +/* need to have QIC02_TAPE_DRIVE and QIC02_TAPE_IFC expand to something */ +#include <linux/mtio.h> + + +/* Make QIC02_TAPE_IFC expand to something. + * + * The only difference between WANGTEK and EVEREX is in the + * handling of the DMA channel 3. + * Note that the driver maps EVEREX to WANGTEK internally for speed + * reasons. Externally WANGTEK==1, EVEREX==2, ARCHIVE==3. + * These must correspond to the values used in qic02config(1). + * + * Support for Mountain controllers was added by Erik Jacobson + * and severely hacked by me. -- hhb + */ +#define WANGTEK 1 /* don't know about Wangtek QIC-36 */ +#define EVEREX (WANGTEK+1) /* I heard *some* of these are identical */ +#define EVEREX_811V EVEREX /* With TEAC MT 2ST 45D */ +#define EVEREX_831V EVEREX +#define ARCHIVE 3 +#define ARCHIVE_SC400 ARCHIVE /* rumoured to be from the pre-SMD-age */ +#define ARCHIVE_SC402 ARCHIVE /* don't know much about SC400 */ +#define ARCHIVE_SC499 ARCHIVE /* SC402 and SC499R should be identical */ + +#define MOUNTAIN 5 /* Mountain Computer Interface */ + + +/*********** START OF USER CONFIGURABLE SECTION ************/ + +/* Tape configuration: Select DRIVE, IFC, PORT, IRQ and DMA below. + * Runtime (re)configuration is not supported yet. + * + * Tape drive configuration: (MT_IS* constants are defined in mtio.h) + * + * QIC02_TAPE_DRIVE = MT_ISWT5150 + * - Wangtek 5150, format: up to QIC-150. + * QIC02_TAPE_DRIVE = MT_ISQIC02_ALL_FEATURES + * - Enables some optional QIC02 commands that some drives may lack. + * It is provided so you can check which are supported by your drive. + * Refer to tpqic02.h for others. + * + * Supported interface cards: QIC02_TAPE_IFC = + * WANGTEK, + * ARCHIVE_SC402, ARCHIVE_SC499. (both same programming interface) + * + * Make sure you have the I/O ports/DMA channels + * and IRQ stuff configured properly! + * NOTE: There may be other device drivers using the same major + * number. This must be avoided. Check for timer.h conflicts too. + * + * If you have an EVEREX EV-831 card and you are using DMA channel 3, + * you will probably have to ``#define QIC02_TAPE_DMA3_FIX'' below. + */ + +/* CONFIG_QIC02_DYNCONF can be defined in autoconf.h, by `make config' */ + +/*** #undef CONFIG_QIC02_DYNCONF ***/ + +#ifndef CONFIG_QIC02_DYNCONF + +#define QIC02_TAPE_DRIVE MT_ISQIC02_ALL_FEATURES /* drive type */ +/* #define QIC02_TAPE_DRIVE MT_ISWT5150 */ +/* #define QIC02_TAPE_DRIVE MT_ISARCHIVE_5945L2 */ +/* #define QIC02_TAPE_DRIVE MT_ISTEAC_MT2ST */ +/* #define QIC02_TAPE_DRIVE MT_ISARCHIVE_2150L */ +/* #define QIC02_TAPE_DRIVE MT_ISARCHIVESC499 */ + +/* Either WANGTEK, ARCHIVE or MOUNTAIN. Not EVEREX. + * If you have an EVEREX, use WANGTEK and try the DMA3_FIX below. + */ +#define QIC02_TAPE_IFC WANGTEK /* interface card type */ +/* #define QIC02_TAPE_IFC ARCHIVE */ +/* #define QIC02_TAPE_IFC MOUNTAIN */ + +#define QIC02_TAPE_PORT 0x300 /* controller port address */ +#define QIC02_TAPE_IRQ 5 /* For IRQ2, use 9 here, others normal. */ +#define QIC02_TAPE_DMA 1 /* either 1 or 3, because 2 is used by the floppy */ + +/* If DMA3 doesn't work, but DMA1 does, and you have a + * Wangtek/Everex card, you can try #define-ing the flag + * below. Note that you should also change the DACK jumper + * for Wangtek/Everex cards when changing the DMA channel. + */ +#undef QIC02_TAPE_DMA3_FIX + +/************ END OF USER CONFIGURABLE SECTION *************/ + +/* I put the stuff above in config.in, but a few recompiles, to + * verify different configurations, and several days later I decided + * to change it back again. + */ + + + +/* NOTE: TP_HAVE_DENS should distinguish between available densities (?) + * NOTE: Drive select is not implemented -- I have only one tape streamer, + * so I'm unable and unmotivated to test and implement that. ;-) ;-) + */ +#if QIC02_TAPE_DRIVE == MT_ISWT5150 +#define TP_HAVE_DENS 1 +#define TP_HAVE_BSF 0 /* nope */ +#define TP_HAVE_FSR 0 /* nope */ +#define TP_HAVE_BSR 0 /* nope */ +#define TP_HAVE_EOD 0 /* most of the time */ +#define TP_HAVE_SEEK 0 +#define TP_HAVE_TELL 0 +#define TP_HAVE_RAS1 1 +#define TP_HAVE_RAS2 1 + +#elif QIC02_TAPE_DRIVE == MT_ISARCHIVESC499 /* Archive SC-499 QIC-36 controller */ +#define TP_HAVE_DENS 1 /* can do set density (QIC-11 / QIC-24) */ +#define TP_HAVE_BSF 0 +#define TP_HAVE_FSR 1 /* can skip one block forwards */ +#define TP_HAVE_BSR 1 /* can skip one block backwards */ +#define TP_HAVE_EOD 1 /* can seek to end of recorded data */ +#define TP_HAVE_SEEK 0 +#define TP_HAVE_TELL 0 +#define TP_HAVE_RAS1 1 /* can run selftest 1 */ +#define TP_HAVE_RAS2 1 /* can run selftest 2 */ +/* These last two selftests shouldn't be used yet! */ + +#elif (QIC02_TAPE_DRIVE == MT_ISARCHIVE_2060L) || (QIC02_TAPE_DRIVE == MT_ISARCHIVE_2150L) +#define TP_HAVE_DENS 1 /* can do set density (QIC-24 / QIC-120 / QIC-150) */ +#define TP_HAVE_BSF 0 +#define TP_HAVE_FSR 1 /* can skip one block forwards */ +#define TP_HAVE_BSR 1 /* can skip one block backwards */ +#define TP_HAVE_EOD 1 /* can seek to end of recorded data */ +#define TP_HAVE_TELL 1 /* can read current block address */ +#define TP_HAVE_SEEK 1 /* can seek to block */ +#define TP_HAVE_RAS1 1 /* can run selftest 1 */ +#define TP_HAVE_RAS2 1 /* can run selftest 2 */ +/* These last two selftests shouldn't be used yet! */ + +#elif QIC02_TAPE_DRIVE == MT_ISARCHIVE_5945L2 +/* can anyone verify this entry?? */ +#define TP_HAVE_DENS 1 /* can do set density?? (QIC-24??) */ +#define TP_HAVE_BSF 0 +#define TP_HAVE_FSR 1 /* can skip one block forwards */ +#define TP_HAVE_BSR 1 /* can skip one block backwards */ +#define TP_HAVE_EOD 1 /* can seek to end of recorded data */ +#define TP_HAVE_TELL 1 /* can read current block address */ +#define TP_HAVE_SEEK 1 /* can seek to block */ +#define TP_HAVE_RAS1 1 /* can run selftest 1 */ +#define TP_HAVE_RAS2 1 /* can run selftest 2 */ +/* These last two selftests shouldn't be used yet! */ + +#elif QIC02_TAPE_DRIVE == MT_ISTEAC_MT2ST +/* can anyone verify this entry?? */ +#define TP_HAVE_DENS 0 /* cannot do set density?? (QIC-150?) */ +#define TP_HAVE_BSF 0 +#define TP_HAVE_FSR 1 /* can skip one block forwards */ +#define TP_HAVE_BSR 1 /* can skip one block backwards */ +#define TP_HAVE_EOD 1 /* can seek to end of recorded data */ +#define TP_HAVE_SEEK 1 /* can seek to block */ +#define TP_HAVE_TELL 1 /* can read current block address */ +#define TP_HAVE_RAS1 1 /* can run selftest 1 */ +#define TP_HAVE_RAS2 1 /* can run selftest 2 */ +/* These last two selftests shouldn't be used yet! */ + +#elif QIC02_TAPE_DRIVE == MT_ISQIC02_ALL_FEATURES +#define TP_HAVE_DENS 1 /* can do set density */ +#define TP_HAVE_BSF 1 /* can search filemark backwards */ +#define TP_HAVE_FSR 1 /* can skip one block forwards */ +#define TP_HAVE_BSR 1 /* can skip one block backwards */ +#define TP_HAVE_EOD 1 /* can seek to end of recorded data */ +#define TP_HAVE_SEEK 1 /* seek to block address */ +#define TP_HAVE_TELL 1 /* tell current block address */ +#define TP_HAVE_RAS1 1 /* can run selftest 1 */ +#define TP_HAVE_RAS2 1 /* can run selftest 2 */ +/* These last two selftests shouldn't be used yet! */ + + +#else +#error No QIC-02 tape drive type defined! +/* If your drive is not listed above, first try the 'ALL_FEATURES', + * to see what commands are supported, then create your own entry in + * the list above. You may want to mail it to me, so that I can include + * it in the next release. + */ +#endif + +#endif /* !CONFIG_QIC02_DYNCONF */ + + +/* WANGTEK interface card specifics */ +#define WT_QIC02_STAT_PORT (QIC02_TAPE_PORT) +#define WT_QIC02_CTL_PORT (QIC02_TAPE_PORT) +#define WT_QIC02_CMD_PORT (QIC02_TAPE_PORT+1) +#define WT_QIC02_DATA_PORT (QIC02_TAPE_PORT+1) + +/* status register bits (Active LOW!) */ +#define WT_QIC02_STAT_READY 0x01 +#define WT_QIC02_STAT_EXCEPTION 0x02 +#define WT_QIC02_STAT_MASK (WT_QIC02_STAT_READY|WT_QIC02_STAT_EXCEPTION) + +#define WT_QIC02_STAT_RESETMASK 0x07 +#define WT_QIC02_STAT_RESETVAL (WT_QIC02_STAT_RESETMASK & ~WT_QIC02_STAT_EXCEPTION) + +/* controller register (QIC02_CTL_PORT) bits */ +#define WT_QIC02_CTL_RESET 0x02 +#define WT_QIC02_CTL_REQUEST 0x04 +#define WT_CTL_ONLINE 0x01 +#define WT_CTL_CMDOFF 0xC0 + +#define WT_CTL_DMA3 0x10 /* enable dma chan3 */ +#define WT_CTL_DMA1 0x08 /* enable dma chan1 or chan2 */ + + + + +/* ARCHIVE interface card specifics */ +#define AR_QIC02_STAT_PORT (QIC02_TAPE_PORT+1) +#define AR_QIC02_CTL_PORT (QIC02_TAPE_PORT+1) +#define AR_QIC02_CMD_PORT (QIC02_TAPE_PORT) +#define AR_QIC02_DATA_PORT (QIC02_TAPE_PORT) + +#define AR_START_DMA_PORT (QIC02_TAPE_PORT+2) +#define AR_RESET_DMA_PORT (QIC02_TAPE_PORT+3) + +/* STAT port bits */ +#define AR_STAT_IRQF 0x80 /* active high, interrupt request flag */ +#define AR_QIC02_STAT_READY 0x40 /* active low */ +#define AR_QIC02_STAT_EXCEPTION 0x20 /* active low */ +#define AR_QIC02_STAT_MASK (AR_QIC02_STAT_READY|AR_QIC02_STAT_EXCEPTION) +#define AR_STAT_DMADONE 0x10 /* active high, DMA done */ +#define AR_STAT_DIRC 0x08 /* active high, direction */ + +#define AR_QIC02_STAT_RESETMASK 0x70 /* check RDY,EXC,DMADONE */ +#define AR_QIC02_STAT_RESETVAL ((AR_QIC02_STAT_RESETMASK & ~AR_STAT_IRQF & ~AR_QIC02_STAT_EXCEPTION) | AR_STAT_DMADONE) + +/* CTL port bits */ +#define AR_QIC02_CTL_RESET 0x80 /* drive reset */ +#define AR_QIC02_CTL_REQUEST 0x40 /* notify of new command */ +#define AR_CTL_IEN 0x20 /* interrupt enable */ +#define AR_CTL_DNIEN 0x10 /* done-interrupt enable */ + /* Note: All of these bits are cleared automatically when writing to + * AR_RESET_DMA_PORT. So AR_CTL_IEN and AR_CTL_DNIEN must be + * reprogrammed before the write to AR_START_DMA_PORT. + */ + + +/* MOUNTAIN interface specifics */ +#define MTN_QIC02_STAT_PORT (QIC02_TAPE_PORT+1) +#define MTN_QIC02_CTL_PORT (QIC02_TAPE_PORT+1) +#define MTN_QIC02_CMD_PORT (QIC02_TAPE_PORT) +#define MTN_QIC02_DATA_PORT (QIC02_TAPE_PORT) + +#define MTN_W_SELECT_DMA_PORT (QIC02_TAPE_PORT+2) +#define MTN_R_DESELECT_DMA_PORT (QIC02_TAPE_PORT+2) +#define MTN_W_DMA_WRITE_PORT (QIC02_TAPE_PORT+3) + +/* STAT port bits */ +#define MTN_QIC02_STAT_READY 0x02 /* active low */ +#define MTN_QIC02_STAT_EXCEPTION 0x04 /* active low */ +#define MTN_QIC02_STAT_MASK (MTN_QIC02_STAT_READY|MTN_QIC02_STAT_EXCEPTION) +#define MTN_STAT_DMADONE 0x01 /* active high, DMA done */ + +#define MTN_QIC02_STAT_RESETMASK 0x07 /* check RDY,EXC,DMADONE */ +#define MTN_QIC02_STAT_RESETVAL ((MTN_QIC02_STAT_RESETMASK & ~MTN_QIC02_STAT_EXCEPTION) | MTN_STAT_DMADONE) + + /* CTL port bits */ +#define MTN_QIC02_CTL_RESET_NOT 0x80 /* drive reset, active low */ +#define MTN_QIC02_CTL_RESET 0x80 /* Fodder #definition to keep gcc happy */ + +#define MTN_QIC02_CTL_ONLINE 0x40 /* Put drive on line */ +#define MTN_QIC02_CTL_REQUEST 0x20 /* notify of new command */ +#define MTN_QIC02_CTL_IRQ_DRIVER 0x10 /* Enable IRQ tristate driver */ +#define MTN_QIC02_CTL_DMA_DRIVER 0x08 /* Enable DMA tristate driver */ +#define MTN_CTL_EXC_IEN 0x04 /* Exception interrupt enable */ +#define MTN_CTL_RDY_IEN 0x02 /* Ready interrupt enable */ +#define MTN_CTL_DNIEN 0x01 /* done-interrupt enable */ + +#define MTN_CTL_ONLINE (MTN_QIC02_CTL_RESET_NOT | MTN_QIC02_CTL_IRQ_DRIVER | MTN_QIC02_CTL_DMA_DRIVER) + + +#ifndef CONFIG_QIC02_DYNCONF + +# define QIC02_TAPE_DEBUG (qic02_tape_debug) + +# if QIC02_TAPE_IFC == WANGTEK +# define QIC02_STAT_PORT WT_QIC02_STAT_PORT +# define QIC02_CTL_PORT WT_QIC02_CTL_PORT +# define QIC02_CMD_PORT WT_QIC02_CMD_PORT +# define QIC02_DATA_PORT WT_QIC02_DATA_PORT + +# define QIC02_STAT_READY WT_QIC02_STAT_READY +# define QIC02_STAT_EXCEPTION WT_QIC02_STAT_EXCEPTION +# define QIC02_STAT_MASK WT_QIC02_STAT_MASK +# define QIC02_STAT_RESETMASK WT_QIC02_STAT_RESETMASK +# define QIC02_STAT_RESETVAL WT_QIC02_STAT_RESETVAL + +# define QIC02_CTL_RESET WT_QIC02_CTL_RESET +# define QIC02_CTL_REQUEST WT_QIC02_CTL_REQUEST + +# if QIC02_TAPE_DMA == 3 +# ifdef QIC02_TAPE_DMA3_FIX +# define WT_CTL_DMA WT_CTL_DMA1 +# else +# define WT_CTL_DMA WT_CTL_DMA3 +# endif +# elif QIC02_TAPE_DMA == 1 +# define WT_CTL_DMA WT_CTL_DMA1 +# else +# error Unsupported or incorrect DMA configuration. +# endif + +# elif QIC02_TAPE_IFC == ARCHIVE +# define QIC02_STAT_PORT AR_QIC02_STAT_PORT +# define QIC02_CTL_PORT AR_QIC02_CTL_PORT +# define QIC02_CMD_PORT AR_QIC02_CMD_PORT +# define QIC02_DATA_PORT AR_QIC02_DATA_PORT + +# define QIC02_STAT_READY AR_QIC02_STAT_READY +# define QIC02_STAT_EXCEPTION AR_QIC02_STAT_EXCEPTION +# define QIC02_STAT_MASK AR_QIC02_STAT_MASK +# define QIC02_STAT_RESETMASK AR_QIC02_STAT_RESETMASK +# define QIC02_STAT_RESETVAL AR_QIC02_STAT_RESETVAL + +# define QIC02_CTL_RESET AR_QIC02_CTL_RESET +# define QIC02_CTL_REQUEST AR_QIC02_CTL_REQUEST + +# if QIC02_TAPE_DMA > 3 /* channel 2 is used by the floppy driver */ +# error DMA channels other than 1 and 3 are not supported. +# endif + +# elif QIC02_TAPE_IFC == MOUNTAIN +# define QIC02_STAT_PORT MTN_QIC02_STAT_PORT +# define QIC02_CTL_PORT MTN_QIC02_CTL_PORT +# define QIC02_CMD_PORT MTN_QIC02_CMD_PORT +# define QIC02_DATA_PORT MTN_QIC02_DATA_PORT + +# define QIC02_STAT_READY MTN_QIC02_STAT_READY +# define QIC02_STAT_EXCEPTION MTN_QIC02_STAT_EXCEPTION +# define QIC02_STAT_MASK MTN_QIC02_STAT_MASK +# define QIC02_STAT_RESETMASK MTN_QIC02_STAT_RESETMASK +# define QIC02_STAT_RESETVAL MTN_QIC02_STAT_RESETVAL + +# define QIC02_CTL_RESET MTN_QIC02_CTL_RESET +# define QIC02_CTL_REQUEST MTN_QIC02_CTL_REQUEST + +# if QIC02_TAPE_DMA > 3 /* channel 2 is used by the floppy driver */ +# error DMA channels other than 1 and 3 are not supported. +# endif + +# else +# error No valid interface card specified! +# endif /* QIC02_TAPE_IFC */ + + + /* An ugly hack to make sure WT_CTL_DMA is defined even for the + * static, non-Wangtek case. The alternative was even worse. + */ +# ifndef WT_CTL_DMA +# define WT_CTL_DMA WT_CTL_DMA1 +# endif + +/*******************/ + +#else /* !CONFIG_QIC02_DYNCONF */ + +/* Now the runtime config version, using variables instead of constants. + * + * qic02_tape_dynconf is R/O for the kernel, set from userspace. + * qic02_tape_ccb is private to the driver, R/W. + */ + +# define QIC02_TAPE_DRIVE (qic02_tape_dynconf.mt_type) +# define QIC02_TAPE_IFC (qic02_tape_ccb.ifc_type) +# define QIC02_TAPE_IRQ (qic02_tape_dynconf.irqnr) +# define QIC02_TAPE_DMA (qic02_tape_dynconf.dmanr) +# define QIC02_TAPE_PORT (qic02_tape_dynconf.port) +# define WT_CTL_DMA (qic02_tape_ccb.dma_enable_value) +# define QIC02_TAPE_DEBUG (qic02_tape_dynconf.debug) + +# define QIC02_STAT_PORT (qic02_tape_ccb.port_stat) +# define QIC02_CTL_PORT (qic02_tape_ccb.port_ctl) +# define QIC02_CMD_PORT (qic02_tape_ccb.port_cmd) +# define QIC02_DATA_PORT (qic02_tape_ccb.port_data) + +# define QIC02_STAT_READY (qic02_tape_ccb.stat_ready) +# define QIC02_STAT_EXCEPTION (qic02_tape_ccb.stat_exception) +# define QIC02_STAT_MASK (qic02_tape_ccb.stat_mask) + +# define QIC02_STAT_RESETMASK (qic02_tape_ccb.stat_resetmask) +# define QIC02_STAT_RESETVAL (qic02_tape_ccb.stat_resetval) + +# define QIC02_CTL_RESET (qic02_tape_ccb.ctl_reset) +# define QIC02_CTL_REQUEST (qic02_tape_ccb.ctl_request) + +# define TP_HAVE_DENS (qic02_tape_dynconf.have_dens) +# define TP_HAVE_BSF (qic02_tape_dynconf.have_bsf) +# define TP_HAVE_FSR (qic02_tape_dynconf.have_fsr) +# define TP_HAVE_BSR (qic02_tape_dynconf.have_bsr) +# define TP_HAVE_EOD (qic02_tape_dynconf.have_eod) +# define TP_HAVE_SEEK (qic02_tape_dynconf.have_seek) +# define TP_HAVE_TELL (qic02_tape_dynconf.have_tell) +# define TP_HAVE_RAS1 (qic02_tape_dynconf.have_ras1) +# define TP_HAVE_RAS2 (qic02_tape_dynconf.have_ras2) + +#endif /* CONFIG_QIC02_DYNCONF */ + + +/* "Vendor Unique" codes */ +/* Archive seek & tell stuff */ +#define AR_QCMDV_TELL_BLK 0xAE /* read current block address */ +#define AR_QCMDV_SEEK_BLK 0xAD /* seek to specific block */ +#define AR_SEEK_BUF_SIZE 3 /* address is 3 bytes */ + + + +/* + * Misc common stuff + */ + +/* Standard QIC-02 commands -- rev F. All QIC-02 drives must support these */ +#define QCMD_SEL_1 0x01 /* select drive 1 */ +#define QCMD_SEL_2 0x02 /* select drive 2 */ +#define QCMD_SEL_3 0x04 /* select drive 3 */ +#define QCMD_SEL_4 0x08 /* select drive 4 */ +#define QCMD_REWIND 0x21 /* rewind tape */ +#define QCMD_ERASE 0x22 /* erase tape */ +#define QCMD_RETEN 0x24 /* retension tape */ +#define QCMD_WRT_DATA 0x40 /* write data */ +#define QCMD_WRT_FM 0x60 /* write file mark */ +#define QCMD_RD_DATA 0x80 /* read data */ +#define QCMD_RD_FM 0xA0 /* read file mark (forward direction) */ +#define QCMD_RD_STAT 0xC0 /* read status */ + +/* Other (optional/vendor unique) commands */ + /* Density commands are only valid when TP_BOM is set! */ +#define QCMD_DENS_11 0x26 /* QIC-11 */ +#define QCMD_DENS_24 0x27 /* QIC-24: 9 track 60MB */ +#define QCMD_DENS_120 0x28 /* QIC-120: 15 track 120MB */ +#define QCMD_DENS_150 0x29 /* QIC-150: 18 track 150MB */ +#define QCMD_DENS_300 0x2A /* QIC-300/QIC-2100 */ +#define QCMD_DENS_600 0x2B /* QIC-600/QIC-2200 */ +/* don't know about QIC-1000 and QIC-1350 */ + +#define QCMD_WRTNU_DATA 0x40 /* write data, no underruns, insert filler. */ +#define QCMD_SPACE_FWD 0x81 /* skip next block */ +#define QCMD_SPACE_BCK 0x89 /* move tape head one block back -- very useful! */ +#define QCMD_RD_FM_BCK 0xA8 /* read filemark (backwards) */ +#define QCMD_SEEK_EOD 0xA3 /* skip to EOD */ +#define QCMD_RD_STAT_X1 0xC1 /* read extended status 1 */ +#define QCMD_RD_STAT_X2 0xC4 /* read extended status 2 */ +#define QCMD_RD_STAT_X3 0xE0 /* read extended status 3 */ +#define QCMD_SELF_TST1 0xC2 /* run self test 1 (nondestructive) */ +#define QCMD_SELF_TST2 0xCA /* run self test 2 (destructive) */ + + + +/* Optional, QFA (Quick File Access) commands. + * Not all drives support this, but those that do could use these commands + * to implement semi-non-sequential access. `mt fsf` would benefit from this. + * QFA divides the tape into 2 partitions, a data and a directory partition, + * causing some incompatibility problems wrt std QIC-02 data exchange. + * It would be useful to cache the directory info, but that might be tricky + * to do in kernel-space. [Size constraints.] + * Refer to the QIC-02 specs, appendix A for more information. + * I have no idea how other *nix variants implement QFA. + * I have no idea which drives support QFA and which don't. + */ +#define QFA_ENABLE 0x2D /* enter QFA mode, give @ BOT only */ +#define QFA_DATA 0x20 /* select data partition */ +#define QFA_DIR 0x23 /* select directory partition */ +#define QFA_RD_POS 0xCF /* read position+status bytes */ +#define QFA_SEEK_EOD 0xA1 /* seek EOD within current partition */ +#define QFA_SEEK_BLK 0xAF /* seek to a block within current partition */ + + + + +/* + * Debugging flags + */ +#define TPQD_SENSE_TEXT 0x0001 +#define TPQD_SENSE_CNTS 0x0002 +#define TPQD_REWIND 0x0004 +#define TPQD_TERM_CYCLE 0x0008 +#define TPQD_IOCTLS 0x0010 +#define TPQD_DMAX 0x0020 +#define TPQD_BLKSZ 0x0040 +#define TPQD_MISC 0x0080 + +#define TPQD_DEBUG 0x0100 + +#define TPQD_DIAGS 0x1000 + +#define TPQD_ALWAYS 0x8000 + +#define TPQD_DEFAULT_FLAGS 0x01fc + +#define TPQDBG(f) ((QIC02_TAPE_DEBUG) & (TPQD_##f)) + + +/* Minor device codes for tapes: + * |7|6|5|4|3|2|1|0| + * | \ | / \ | / |_____ 1=rewind on close, 0=no rewind on close + * | \|/ |_________ Density: 000=none, 001=QIC-11, 010=24, 011=120, + * | | 100=QIC-150, 101..111 reserved. + * | |_______________ Reserved for unit numbers. + * |___________________ Reserved for diagnostics during debugging. + */ + +#define TP_REWCLOSE(d) ((MINOR(d)&0x01) == 1) /* rewind bit */ + /* rewind is only done if data has been transfered */ +#define TP_DENS(dev) ((MINOR(dev) >> 1) & 0x07) /* tape density */ +#define TP_UNIT(dev) ((MINOR(dev) >> 4) & 0x07) /* unit number */ + +/* print excessive diagnostics */ +#define TP_DIAGS(dev) (QIC02_TAPE_DEBUG & TPQD_DIAGS) + +/* status codes returned by a WTS_RDSTAT call */ +struct tpstatus { /* sizeof(short)==2), LSB first */ + unsigned short exs; /* Drive exception flags */ + unsigned short dec; /* data error count: nr of blocks rewritten/soft read errors */ + unsigned short urc; /* underrun count: nr of times streaming was interrupted */ +}; +#define TPSTATSIZE sizeof(struct tpstatus) + + +/* defines for tpstatus.exs -- taken from 386BSD wt driver */ +#define TP_POR 0x100 /* Power on or reset occurred */ +#define TP_EOR 0x200 /* REServed for end of RECORDED media */ +#define TP_PAR 0x400 /* REServed for bus parity */ +#define TP_BOM 0x800 /* Beginning of media */ +#define TP_MBD 0x1000 /* Marginal block detected */ +#define TP_NDT 0x2000 /* No data detected */ +#define TP_ILL 0x4000 /* Illegal command */ +#define TP_ST1 0x8000 /* Status byte 1 flag */ +#define TP_FIL 0x01 /* File mark detected */ +#define TP_BNL 0x02 /* Bad block not located */ +#define TP_UDA 0x04 /* Unrecoverable data error */ +#define TP_EOM 0x08 /* End of media */ +#define TP_WRP 0x10 /* Write protected cartridge */ +#define TP_USL 0x20 /* Unselected drive */ +#define TP_CNI 0x40 /* Cartridge not in place */ +#define TP_ST0 0x80 /* Status byte 0 flag */ + +#define REPORT_ERR0 (TP_CNI|TP_USL|TP_WRP|TP_EOM|TP_UDA|TP_BNL|TP_FIL) +#define REPORT_ERR1 (TP_ILL|TP_NDT|TP_MBD|TP_PAR) + + +/* exception numbers */ +#define EXC_UNKNOWN 0 /* (extra) Unknown exception code */ +#define EXC_NDRV 1 /* No drive */ +#define EXC_NCART 2 /* No cartridge */ +#define EXC_WP 3 /* Write protected */ +#define EXC_EOM 4 /* EOM */ +#define EXC_RWA 5 /* read/write abort */ +#define EXC_XBAD 6 /* read error, bad block transfered */ +#define EXC_XFILLER 7 /* read error, filler block transfered */ +#define EXC_NDT 8 /* read error, no data */ +#define EXC_NDTEOM 9 /* read error, no data & EOM */ +#define EXC_NDTBOM 10 /* read error, no data & BOM */ +#define EXC_FM 11 /* Read a filemark */ +#define EXC_ILL 12 /* Illegal command */ +#define EXC_POR 13 /* Power on/reset */ +#define EXC_MARGINAL 14 /* Marginal block detected */ +#define EXC_EOR 15 /* (extra, for SEEKEOD) End Of Recorded data reached */ +#define EXC_BOM 16 /* (extra) BOM reached */ + + +#define TAPE_NOTIFY_TIMEOUT 1000000 + +/* internal function return codes */ +#define TE_OK 0 /* everything is fine */ +#define TE_EX 1 /* exception detected */ +#define TE_ERR 2 /* some error */ +#define TE_NS 3 /* can't read status */ +#define TE_TIM 4 /* timed out */ +#define TE_DEAD 5 /* tape drive doesn't respond */ +#define TE_END 6 /******** Archive hack *****/ + +/* timeout timer values -- check these! */ +#define TIM_S (4*HZ) /* 4 seconds (normal cmds) */ +#define TIM_M (30*HZ) /* 30 seconds (write FM) */ +#define TIM_R (8*60*HZ) /* 8 minutes (retensioning) */ +#define TIM_F (2*3600*HZ) /* est. 1.2hr for full tape read/write+2 retens */ + +#define TIMERON(t) timer_table[QIC02_TAPE_TIMER].expires = jiffies + (t); \ + timer_active |= (1<<QIC02_TAPE_TIMER) +#define TIMEROFF timer_active &= ~(1<<QIC02_TAPE_TIMER) +#define TIMERCONT timer_active |= (1<<QIC02_TAPE_TIMER) + + +typedef char flag; +#define NO 0 /* NO must be 0 */ +#define YES 1 /* YES must be != 0 */ + + +#ifdef TDEBUG +# define TPQDEB(s) s +# define TPQPUTS(s) tpqputs(s) +#else +# define TPQDEB(s) +# define TPQPUTS(s) +#endif + + +/* NR_BLK_BUF is a `tuneable parameter'. If you're really low on + * kernel space, you could decrease it to 1, or if you got a very + * slow machine, you could increase it up to 128 blocks. Less kernel + * buffer blocks result in more context-switching. + */ +#define NR_BLK_BUF 20 /* max 128 blocks */ +#define TAPE_BLKSIZE 512 /* streamer tape block size (fixed) */ +#define TPQBUF_SIZE (TAPE_BLKSIZE*NR_BLK_BUF) /* buffer size */ + + +#define BLOCKS_BEYOND_EW 2 /* nr of blocks after Early Warning hole */ +#define BOGUS_IRQ 32009 + +/* structure for MTIOCGETCONFIG/MTIOCSETCONFIG primarily intended + * as an interim solution for QIC-02 until DDI is fully implemented. + */ +struct mtconfiginfo { + long mt_type; /* drive type */ + long ifc_type; /* interface card type */ + unsigned short irqnr; /* IRQ number to use */ + unsigned short dmanr; /* DMA channel to use */ + unsigned short port; /* IO port base address */ + + unsigned long debug; /* debugging flags */ + + unsigned have_dens:1; + unsigned have_bsf:1; + unsigned have_fsr:1; + unsigned have_bsr:1; + unsigned have_eod:1; + unsigned have_seek:1; + unsigned have_tell:1; + unsigned have_ras1:1; + unsigned have_ras2:1; + unsigned have_ras3:1; + unsigned have_qfa:1; + + unsigned pad1:5; + char reserved[10]; +}; + + +/* This is internal data, filled in based on the ifc_type field given + * by the user. Everex is mapped to Wangtek with a different + * `dma_enable_value', if dmanr==3. + */ +struct qic02_ccb { + long ifc_type; + + unsigned short port_stat; /* Status port address */ + unsigned short port_ctl; /* Control port address */ + unsigned short port_cmd; /* Command port address */ + unsigned short port_data; /* Data port address */ + + /* status register bits */ + unsigned short stat_ready; /* drive ready */ + unsigned short stat_exception; /* drive signals exception */ + unsigned short stat_mask; + unsigned short stat_resetmask; + unsigned short stat_resetval; + + /* control register bits */ + unsigned short ctl_reset; /* reset drive */ + unsigned short ctl_request; /* latch command */ + + /* This is used to change the DMA3 behaviour */ + unsigned short dma_enable_value; +}; + + +extern long qic02_tape_init(long); /* for mem.c */ + + +#endif /* CONFIG_QIC02_TAPE */ + +#endif /* _LINUX_TPQIC02_H */ + diff --git a/include/linux/tqueue.h b/include/linux/tqueue.h new file mode 100644 index 000000000..d264495e3 --- /dev/null +++ b/include/linux/tqueue.h @@ -0,0 +1,165 @@ +/* + * tqueue.h --- task queue handling for Linux. + * + * Mostly based on a proposed bottom-half replacement code written by + * Kai Petzke, wpp@marie.physik.tu-berlin.de. + * + * Modified for use in the Linux kernel by Theodore Ts'o, + * tytso@mit.edu. Any bugs are my fault, not Kai's. + * + * The original comment follows below. + */ + +#ifndef _LINUX_TQUEUE_H +#define _LINUX_TQUEUE_H + +#include <asm/bitops.h> +#include <asm/system.h> + +#ifdef INCLUDE_INLINE_FUNCS +#define _INLINE_ extern +#else +#define _INLINE_ extern __inline__ +#endif + +/* + * New proposed "bottom half" handlers: + * (C) 1994 Kai Petzke, wpp@marie.physik.tu-berlin.de + * + * Advantages: + * - Bottom halfs are implemented as a linked list. You can have as many + * of them, as you want. + * - No more scanning of a bit field is required upon call of a bottom half. + * - Support for chained bottom half lists. The run_task_queue() function can be + * used as a bottom half handler. This is for example useful for bottom + * halfs, which want to be delayed until the next clock tick. + * + * Problems: + * - The queue_task_irq() inline function is only atomic with respect to itself. + * Problems can occur, when queue_task_irq() is called from a normal system + * call, and an interrupt comes in. No problems occur, when queue_task_irq() + * is called from an interrupt or bottom half, and interrupted, as run_task_queue() + * will not be executed/continued before the last interrupt returns. If in + * doubt, use queue_task(), not queue_task_irq(). + * - Bottom halfs are called in the reverse order that they were linked into + * the list. + */ + +struct tq_struct { + struct tq_struct *next; /* linked list of active bh's */ + int sync; /* must be initialized to zero */ + void (*routine)(void *); /* function to call */ + void *data; /* argument to function */ +}; + +typedef struct tq_struct * task_queue; + +#define DECLARE_TASK_QUEUE(q) task_queue q = &tq_last + +extern struct tq_struct tq_last; +extern task_queue tq_timer, tq_immediate; + +#ifdef INCLUDE_INLINE_FUNCS +struct tq_struct tq_last = { + &tq_last, 0, 0, 0 +}; +#endif + +/* + * To implement your own list of active bottom halfs, use the following + * two definitions: + * + * struct tq_struct *my_bh = &tq_last; + * struct tq_struct run_my_bh = { + * 0, 0, (void *)(void *) run_task_queue, &my_bh + * }; + * + * To activate a bottom half on your list, use: + * + * queue_task(tq_pointer, &my_bh); + * + * To run the bottom halfs on your list put them on the immediate list by: + * + * queue_task(&run_my_bh, &tq_immediate); + * + * This allows you to do deferred procession. For example, you could + * have a bottom half list tq_timer, which is marked active by the timer + * interrupt. + */ + +/* + * queue_task_irq: put the bottom half handler "bh_pointer" on the list + * "bh_list". You may call this function only from an interrupt + * handler or a bottom half handler. + */ +_INLINE_ void queue_task_irq(struct tq_struct *bh_pointer, + task_queue *bh_list) +{ + if (!set_bit(0,&bh_pointer->sync)) { + bh_pointer->next = *bh_list; + *bh_list = bh_pointer; + } +} + +/* + * queue_task_irq_off: put the bottom half handler "bh_pointer" on the list + * "bh_list". You may call this function only when interrupts are off. + */ +_INLINE_ void queue_task_irq_off(struct tq_struct *bh_pointer, + task_queue *bh_list) +{ + if (!(bh_pointer->sync & 1)) { + bh_pointer->sync = 1; + bh_pointer->next = *bh_list; + *bh_list = bh_pointer; + } +} + + +/* + * queue_task: as queue_task_irq, but can be called from anywhere. + */ +_INLINE_ void queue_task(struct tq_struct *bh_pointer, + task_queue *bh_list) +{ + if (!set_bit(0,&bh_pointer->sync)) { + unsigned long flags; + save_flags(flags); + cli(); + bh_pointer->next = *bh_list; + *bh_list = bh_pointer; + restore_flags(flags); + } +} + +/* + * Call all "bottom halfs" on a given list. + */ +_INLINE_ void run_task_queue(task_queue *list) +{ + register struct tq_struct *save_p; + register struct tq_struct *p; + void *arg; + void (*f) (void *); + + while(1) { + p = &tq_last; + __asm__ __volatile__("xchgl %0,%2" : "=r" (p) : + "0" (p), "m" (*list) : "memory"); + if(p == &tq_last) + break; + + do { + arg = p -> data; + f = p -> routine; + save_p = p -> next; + p -> sync = 0; + (*f)(arg); + p = save_p; + } while(p != &tq_last); + } +} + +#undef _INLINE_ + +#endif /* _LINUX_TQUEUE_H */ diff --git a/include/linux/tty.h b/include/linux/tty.h new file mode 100644 index 000000000..c177902b5 --- /dev/null +++ b/include/linux/tty.h @@ -0,0 +1,334 @@ +#ifndef _LINUX_TTY_H +#define _LINUX_TTY_H + +/* + * 'tty.h' defines some structures used by tty_io.c and some defines. + */ + +#ifdef __KERNEL__ +#include <linux/fs.h> +#include <linux/termios.h> +#include <linux/tqueue.h> +#include <linux/tty_driver.h> +#include <linux/tty_ldisc.h> + +#include <asm/system.h> + + +/* + * Note: don't mess with NR_PTYS until you understand the tty minor + * number allocation game... + * (Note: the *_driver.minor_start values 1, 64, 128, 192 are + * hardcoded at present.) + */ +#define MIN_NR_CONSOLES 1 /* must be at least 1 */ +#define MAX_NR_CONSOLES 63 /* serial lines start at 64 */ +#define MAX_NR_USER_CONSOLES 63 /* must be root to allocate above this */ + /* Note: the ioctl VT_GETSTATE does not work for + consoles 16 and higher (since it returns a short) */ +#define NR_PTYS 64 +#define NR_LDISCS 16 + +/* + * These are set up by the setup-routine at boot-time: + */ + +struct screen_info { + unsigned char orig_x; + unsigned char orig_y; + unsigned char unused1[2]; + unsigned short orig_video_page; + unsigned char orig_video_mode; + unsigned char orig_video_cols; + unsigned short orig_video_ega_ax; + unsigned short orig_video_ega_bx; + unsigned short orig_video_ega_cx; + unsigned char orig_video_lines; +}; + +extern struct screen_info screen_info; + +#define ORIG_X (screen_info.orig_x) +#define ORIG_Y (screen_info.orig_y) +#define ORIG_VIDEO_PAGE (screen_info.orig_video_page) +#define ORIG_VIDEO_MODE (screen_info.orig_video_mode) +#define ORIG_VIDEO_COLS (screen_info.orig_video_cols) +#define ORIG_VIDEO_EGA_AX (screen_info.orig_video_ega_ax) +#define ORIG_VIDEO_EGA_BX (screen_info.orig_video_ega_bx) +#define ORIG_VIDEO_EGA_CX (screen_info.orig_video_ega_cx) +#define ORIG_VIDEO_LINES (screen_info.orig_video_lines) + +#define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */ +#define VIDEO_TYPE_CGA 0x11 /* CGA Display */ +#define VIDEO_TYPE_EGAM 0x20 /* EGA/VGA in Monochrome Mode */ +#define VIDEO_TYPE_EGAC 0x21 /* EGA/VGA in Color Mode */ + +/* + * This character is the same as _POSIX_VDISABLE: it cannot be used as + * a c_cc[] character, but indicates that a particular special character + * isn't in use (eg VINTR has no character etc) + */ +#define __DISABLED_CHAR '\0' + +/* + * This is the flip buffer used for the tty driver. The buffer is + * located in the tty structure, and is used as a high speed interface + * between the tty driver and the tty line discipline. + */ +#define TTY_FLIPBUF_SIZE 512 + +struct tty_flip_buffer { + struct tq_struct tqueue; + unsigned char char_buf[2*TTY_FLIPBUF_SIZE]; + char flag_buf[2*TTY_FLIPBUF_SIZE]; + char *char_buf_ptr; + unsigned char *flag_buf_ptr; + int count; + int buf_num; +}; + +/* + * When a break, frame error, or parity error happens, these codes are + * stuffed into the flags buffer. + */ +#define TTY_NORMAL 0 +#define TTY_BREAK 1 +#define TTY_FRAME 2 +#define TTY_PARITY 3 +#define TTY_OVERRUN 4 + +#define INTR_CHAR(tty) ((tty)->termios->c_cc[VINTR]) +#define QUIT_CHAR(tty) ((tty)->termios->c_cc[VQUIT]) +#define ERASE_CHAR(tty) ((tty)->termios->c_cc[VERASE]) +#define KILL_CHAR(tty) ((tty)->termios->c_cc[VKILL]) +#define EOF_CHAR(tty) ((tty)->termios->c_cc[VEOF]) +#define TIME_CHAR(tty) ((tty)->termios->c_cc[VTIME]) +#define MIN_CHAR(tty) ((tty)->termios->c_cc[VMIN]) +#define SWTC_CHAR(tty) ((tty)->termios->c_cc[VSWTC]) +#define START_CHAR(tty) ((tty)->termios->c_cc[VSTART]) +#define STOP_CHAR(tty) ((tty)->termios->c_cc[VSTOP]) +#define SUSP_CHAR(tty) ((tty)->termios->c_cc[VSUSP]) +#define EOL_CHAR(tty) ((tty)->termios->c_cc[VEOL]) +#define REPRINT_CHAR(tty) ((tty)->termios->c_cc[VREPRINT]) +#define DISCARD_CHAR(tty) ((tty)->termios->c_cc[VDISCARD]) +#define WERASE_CHAR(tty) ((tty)->termios->c_cc[VWERASE]) +#define LNEXT_CHAR(tty) ((tty)->termios->c_cc[VLNEXT]) +#define EOL2_CHAR(tty) ((tty)->termios->c_cc[VEOL2]) + +#define _I_FLAG(tty,f) ((tty)->termios->c_iflag & (f)) +#define _O_FLAG(tty,f) ((tty)->termios->c_oflag & (f)) +#define _C_FLAG(tty,f) ((tty)->termios->c_cflag & (f)) +#define _L_FLAG(tty,f) ((tty)->termios->c_lflag & (f)) + +#define I_IGNBRK(tty) _I_FLAG((tty),IGNBRK) +#define I_BRKINT(tty) _I_FLAG((tty),BRKINT) +#define I_IGNPAR(tty) _I_FLAG((tty),IGNPAR) +#define I_PARMRK(tty) _I_FLAG((tty),PARMRK) +#define I_INPCK(tty) _I_FLAG((tty),INPCK) +#define I_ISTRIP(tty) _I_FLAG((tty),ISTRIP) +#define I_INLCR(tty) _I_FLAG((tty),INLCR) +#define I_IGNCR(tty) _I_FLAG((tty),IGNCR) +#define I_ICRNL(tty) _I_FLAG((tty),ICRNL) +#define I_IUCLC(tty) _I_FLAG((tty),IUCLC) +#define I_IXON(tty) _I_FLAG((tty),IXON) +#define I_IXANY(tty) _I_FLAG((tty),IXANY) +#define I_IXOFF(tty) _I_FLAG((tty),IXOFF) +#define I_IMAXBEL(tty) _I_FLAG((tty),IMAXBEL) + +#define O_OPOST(tty) _O_FLAG((tty),OPOST) +#define O_OLCUC(tty) _O_FLAG((tty),OLCUC) +#define O_ONLCR(tty) _O_FLAG((tty),ONLCR) +#define O_OCRNL(tty) _O_FLAG((tty),OCRNL) +#define O_ONOCR(tty) _O_FLAG((tty),ONOCR) +#define O_ONLRET(tty) _O_FLAG((tty),ONLRET) +#define O_OFILL(tty) _O_FLAG((tty),OFILL) +#define O_OFDEL(tty) _O_FLAG((tty),OFDEL) +#define O_NLDLY(tty) _O_FLAG((tty),NLDLY) +#define O_CRDLY(tty) _O_FLAG((tty),CRDLY) +#define O_TABDLY(tty) _O_FLAG((tty),TABDLY) +#define O_BSDLY(tty) _O_FLAG((tty),BSDLY) +#define O_VTDLY(tty) _O_FLAG((tty),VTDLY) +#define O_FFDLY(tty) _O_FLAG((tty),FFDLY) + +#define C_BAUD(tty) _C_FLAG((tty),CBAUD) +#define C_CSIZE(tty) _C_FLAG((tty),CSIZE) +#define C_CSTOPB(tty) _C_FLAG((tty),CSTOPB) +#define C_CREAD(tty) _C_FLAG((tty),CREAD) +#define C_PARENB(tty) _C_FLAG((tty),PARENB) +#define C_PARODD(tty) _C_FLAG((tty),PARODD) +#define C_HUPCL(tty) _C_FLAG((tty),HUPCL) +#define C_CLOCAL(tty) _C_FLAG((tty),CLOCAL) +#define C_CIBAUD(tty) _C_FLAG((tty),CIBAUD) +#define C_CRTSCTS(tty) _C_FLAG((tty),CRTSCTS) + +#define L_ISIG(tty) _L_FLAG((tty),ISIG) +#define L_ICANON(tty) _L_FLAG((tty),ICANON) +#define L_XCASE(tty) _L_FLAG((tty),XCASE) +#define L_ECHO(tty) _L_FLAG((tty),ECHO) +#define L_ECHOE(tty) _L_FLAG((tty),ECHOE) +#define L_ECHOK(tty) _L_FLAG((tty),ECHOK) +#define L_ECHONL(tty) _L_FLAG((tty),ECHONL) +#define L_NOFLSH(tty) _L_FLAG((tty),NOFLSH) +#define L_TOSTOP(tty) _L_FLAG((tty),TOSTOP) +#define L_ECHOCTL(tty) _L_FLAG((tty),ECHOCTL) +#define L_ECHOPRT(tty) _L_FLAG((tty),ECHOPRT) +#define L_ECHOKE(tty) _L_FLAG((tty),ECHOKE) +#define L_FLUSHO(tty) _L_FLAG((tty),FLUSHO) +#define L_PENDIN(tty) _L_FLAG((tty),PENDIN) +#define L_IEXTEN(tty) _L_FLAG((tty),IEXTEN) + +/* + * Where all of the state associated with a tty is kept while the tty + * is open. Since the termios state should be kept even if the tty + * has been closed --- for things like the baud rate, etc --- it is + * not stored here, but rather a pointer to the real state is stored + * here. Possible the winsize structure should have the same + * treatment, but (1) the default 80x24 is usually right and (2) it's + * most often used by a windowing system, which will set the correct + * size each time the window is created or resized anyway. + * IMPORTANT: since this structure is dynamically allocated, it must + * be no larger than 4096 bytes. Changing TTY_BUF_SIZE will change + * the size of this structure, and it needs to be done with care. + * - TYT, 9/14/92 + */ +struct tty_struct { + int magic; + struct tty_driver driver; + struct tty_ldisc ldisc; + struct termios *termios, *termios_locked; + int pgrp; + int session; + dev_t device; + int flags; + int count; + struct winsize winsize; + unsigned char stopped:1, hw_stopped:1, packet:1; + unsigned char ctrl_status; + + struct tty_struct *link; + struct fasync_struct *fasync; + struct tty_flip_buffer flip; + int max_flip_cnt; + struct wait_queue *write_wait; + struct wait_queue *read_wait; + void *disc_data; + void *driver_data; + +#define N_TTY_BUF_SIZE 4096 + + /* + * The following is data for the N_TTY line discipline. For + * historical reasons, this is included in the tty structure. + */ + unsigned int column; + unsigned char lnext:1, erasing:1, raw:1, real_raw:1, icanon:1; + unsigned short minimum_to_wake; + unsigned overrun_time; + int num_overrun; + int process_char_map[256/32]; + char *read_buf; + int read_head; + int read_tail; + int read_cnt; + int read_flags[N_TTY_BUF_SIZE/32]; + int canon_data; + unsigned long canon_head; + unsigned int canon_column; +}; + +/* tty magic number */ +#define TTY_MAGIC 0x5401 + +/* + * These bits are used in the flags field of the tty structure. + * + * So that interrupts won't be able to mess up the queues, + * copy_to_cooked must be atomic with respect to itself, as must + * tty->write. Thus, you must use the inline functions set_bit() and + * clear_bit() to make things atomic. + */ +#define TTY_THROTTLED 0 +#define TTY_IO_ERROR 1 +#define TTY_SLAVE_CLOSED 2 +#define TTY_EXCLUSIVE 3 +#define TTY_DEBUG 4 +#define TTY_DO_WRITE_WAKEUP 5 +#define TTY_PUSH 6 + +#define TTY_WRITE_FLUSH(tty) tty_write_flush((tty)) + +extern void tty_write_flush(struct tty_struct *); + +extern struct termios tty_std_termios; +extern struct tty_struct * redirect; +extern struct tty_ldisc ldiscs[]; +extern int fg_console; +extern struct wait_queue * keypress_wait; + +/* intr=^C quit=^| erase=del kill=^U + eof=^D vtime=\0 vmin=\1 sxtc=\0 + start=^Q stop=^S susp=^Z eol=\0 + reprint=^R discard=^U werase=^W lnext=^V + eol2=\0 +*/ +#define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0" + +extern long rs_init(long); +extern long lp_init(long); +extern long con_init(long); +extern long pty_init(long); +extern long tty_init(long); + +extern int tty_paranoia_check(struct tty_struct *tty, dev_t device, + const char *routine); +extern char *_tty_name(struct tty_struct *tty, char *buf); +extern char *tty_name(struct tty_struct *tty); +extern void wait_until_sent(struct tty_struct * tty, int timeout); +extern int tty_check_change(struct tty_struct * tty); +extern void stop_tty(struct tty_struct * tty); +extern void start_tty(struct tty_struct * tty); +extern int tty_register_ldisc(int disc, struct tty_ldisc *new_ldisc); +extern int tty_register_driver(struct tty_driver *driver); +extern int tty_unregister_driver(struct tty_driver *driver); +extern int tty_read_raw_data(struct tty_struct *tty, unsigned char *bufp, + int buflen); + +extern int is_orphaned_pgrp(int pgrp); +extern int is_ignored(int sig); +extern int tty_signal(int sig, struct tty_struct *tty); +extern void tty_hangup(struct tty_struct * tty); +extern void tty_vhangup(struct tty_struct * tty); +extern void tty_unhangup(struct file *filp); +extern int tty_hung_up_p(struct file * filp); +extern void do_SAK(struct tty_struct *tty); +extern void disassociate_ctty(int priv); + +/* n_tty.c */ +extern struct tty_ldisc tty_ldisc_N_TTY; + +/* tty_ioctl.c */ +extern int n_tty_ioctl(struct tty_struct * tty, struct file * file, + unsigned int cmd, unsigned long arg); + +/* serial.c */ + +extern int rs_open(struct tty_struct * tty, struct file * filp); + +/* pty.c */ + +extern int pty_open(struct tty_struct * tty, struct file * filp); + +/* console.c */ + +extern int con_open(struct tty_struct * tty, struct file * filp); +extern void update_screen(int new_console); +extern void blank_screen(void); +extern void unblank_screen(void); + +/* vt.c */ + +extern int vt_ioctl(struct tty_struct *tty, struct file * file, + unsigned int cmd, unsigned long arg); + +#endif /* __KERNEL__ */ +#endif diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h new file mode 100644 index 000000000..5244dc870 --- /dev/null +++ b/include/linux/tty_driver.h @@ -0,0 +1,188 @@ +#ifndef _LINUX_TTY_DRIVER_H +#define _LINUX_TTY_DRIVER_H + +/* + * This structure defines the interface between the low-level tty + * driver and the tty routines. The following routines can be + * defined; unless noted otherwise, they are optional, and can be + * filled in with a null pointer. + * + * int (*open)(struct tty_struct * tty, struct file * filp); + * + * This routine is called when a particular tty device is opened. + * This routine is mandatory; if this routine is not filled in, + * the attempted open will fail with ENODEV. + * + * void (*close)(struct tty_struct * tty, struct file * filp); + * + * This routine is called when a particular tty device is closed. + * + * int (*write)(struct tty_struct * tty, int from_user, + * unsigned char *buf, int count); + * + * This routine is called by the kernel to write a series of + * characters to the tty device. The characters may come from + * user space or kernel space. This routine will return the + * number of characters actually accepted for writing. This + * routine is mandatory. + * + * void (*put_char)(struct tty_struct *tty, unsigned char ch); + * + * This routine is called by the kernel to write a single + * character to the tty device. If the kernel uses this routine, + * it must call the flush_chars() routine (if defined) when it is + * done stuffing characters into the driver. If there is no room + * in the queue, the character is ignored. + * + * void (*flush_chars)(struct tty_struct *tty); + * + * This routine is called by the kernel after it has written a + * series of characters to the tty device using put_char(). + * + * int (*write_room)(struct tty_struct *tty); + * + * This routine returns the numbers of characters the tty driver + * will accept for queuing to be written. This number is subject + * to change as output buffers get emptied, or if the output flow + * control is acted. + * + * int (*ioctl)(struct tty_struct *tty, struct file * file, + * unsigned int cmd, unsigned long arg); + * + * This routine allows the tty driver to implement + * device-specific ioctl's. If the ioctl number passed in cmd + * is not recognized by the driver, it should return ENOIOCTLCMD. + * + * void (*set_termios)(struct tty_struct *tty, struct termios * old); + * + * This routine allows the tty driver to be notified when + * device's termios settings have changed. Note that a + * well-designed tty driver should be prepared to accept the case + * where old == NULL, and try to do something rational. + * + * void (*set_ldisc)(struct tty_struct *tty); + * + * This routine allows the tty driver to be notified when the + * device's termios settings have changed. + * + * void (*throttle)(struct tty_struct * tty); + * + * This routine notifies the tty driver that input buffers for + * the line discipline are close to full, and it should somehow + * signal that no more characters should be sent to the tty. + * + * void (*unthrottle)(struct tty_struct * tty); + * + * This routine notifies the tty drivers that it should signals + * that characters can now be sent to the tty without fear of + * overrunning the input buffers of the line disciplines. + * + * void (*stop)(struct tty_struct *tty); + * + * This routine notifies the tty driver that it should stop + * outputting characters to the tty device. + * + * void (*start)(struct tty_struct *tty); + * + * This routine notifies the tty driver that it resume sending + * characters to the tty device. + * + * void (*hangup)(struct tty_struct *tty); + * + * This routine notifies the tty driver that it should hangup the + * tty device. + * + */ + +#include <linux/fs.h> + +struct tty_driver { + int magic; /* magic number for this structure */ + char *name; + int name_base; /* offset of printed name */ + short major; /* major device number */ + short minor_start; /* start of minor device number*/ + short num; /* number of devices */ + short type; /* type of tty driver */ + short subtype; /* subtype of tty driver */ + struct termios init_termios; /* Initial termios */ + int flags; /* tty driver flags */ + int *refcount; /* for loadable tty drivers */ + struct tty_driver *other; /* only used for the PTY driver */ + + /* + * Pointer to the tty data structures + */ + struct tty_struct **table; + struct termios **termios; + struct termios **termios_locked; + + /* + * Interface routines from the upper tty layer to the tty + * driver. + */ + int (*open)(struct tty_struct * tty, struct file * filp); + void (*close)(struct tty_struct * tty, struct file * filp); + int (*write)(struct tty_struct * tty, int from_user, + unsigned char *buf, int count); + void (*put_char)(struct tty_struct *tty, unsigned char ch); + void (*flush_chars)(struct tty_struct *tty); + int (*write_room)(struct tty_struct *tty); + int (*chars_in_buffer)(struct tty_struct *tty); + int (*ioctl)(struct tty_struct *tty, struct file * file, + unsigned int cmd, unsigned long arg); + void (*set_termios)(struct tty_struct *tty, struct termios * old); + void (*throttle)(struct tty_struct * tty); + void (*unthrottle)(struct tty_struct * tty); + void (*stop)(struct tty_struct *tty); + void (*start)(struct tty_struct *tty); + void (*hangup)(struct tty_struct *tty); + void (*flush_buffer)(struct tty_struct *tty); + void (*set_ldisc)(struct tty_struct *tty); + + /* + * linked list pointers + */ + struct tty_driver *next; + struct tty_driver *prev; +}; + +/* tty driver magic number */ +#define TTY_DRIVER_MAGIC 0x5402 + +/* + * tty driver flags + * + * TTY_DRIVER_RESET_TERMIOS --- requests the tty layer to reset the + * termios setting when the last process has closed the device. + * Used for PTY's, in particular. + * + * TTY_DRIVER_REAL_RAW --- if set, indicates that the driver will + * guarantee never not to set any special character handling + * flags if ((IGNBRK || (!BRKINT && !PARMRK)) && (IGNPAR || + * !INPCK)). That is, if there is no reason for the driver to + * send notifications of parity and break characters up to the + * line driver, it won't do so. This allows the line driver to + * optimize for this case if this flag is set. (Note that there + * is also a promise, if the above case is true, not to signal + * overruns, either.) + */ +#define TTY_DRIVER_INSTALLED 0x0001 +#define TTY_DRIVER_RESET_TERMIOS 0x0002 +#define TTY_DRIVER_REAL_RAW 0x0004 + +/* tty driver types */ +#define TTY_DRIVER_TYPE_SYSTEM 0x0001 +#define TTY_DRIVER_TYPE_CONSOLE 0x0002 +#define TTY_DRIVER_TYPE_SERIAL 0x0003 +#define TTY_DRIVER_TYPE_PTY 0x0004 + +/* system subtypes (magic, used by tty_io.c) */ +#define SYSTEM_TYPE_TTY 0x0001 +#define SYSTEM_TYPE_CONSOLE 0x0002 + +/* pty subtypes (magic, used by tty_io.c) */ +#define PTY_TYPE_MASTER 0x0001 +#define PTY_TYPE_SLAVE 0x0002 + +#endif /* #ifdef _LINUX_TTY_DRIVER_H */ diff --git a/include/linux/tty_flip.h b/include/linux/tty_flip.h new file mode 100644 index 000000000..97316607b --- /dev/null +++ b/include/linux/tty_flip.h @@ -0,0 +1,34 @@ +#ifndef _LINUX_TTY_FLIP_H +#define _LINUX_TTY_FLIP_H + +#ifdef INCLUDE_INLINE_FUNCS +#define _INLINE_ extern +#else +#define _INLINE_ extern __inline__ +#endif + +_INLINE_ void tty_insert_flip_char(struct tty_struct *tty, + unsigned char ch, char flag) +{ + if (tty->flip.count++ >= TTY_FLIPBUF_SIZE) + return; + *tty->flip.flag_buf_ptr++ = flag; + *tty->flip.char_buf_ptr++ = ch; +} + +_INLINE_ void tty_schedule_flip(struct tty_struct *tty) +{ + queue_task(&tty->flip.tqueue, &tq_timer); +} + +#undef _INLINE_ + + +#endif /* _LINUX_TTY_FLIP_H */ + + + + + + + diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h new file mode 100644 index 000000000..732f5a115 --- /dev/null +++ b/include/linux/tty_ldisc.h @@ -0,0 +1,46 @@ +#ifndef _LINUX_TTY_LDISC_H +#define _LINUX_TTY_LDISC_H + +/* + * Definitions for the tty line discipline + */ + +#include <linux/fs.h> +#include <linux/wait.h> + +struct tty_ldisc { + int magic; + int num; + int flags; + /* + * The following routines are called from above. + */ + int (*open)(struct tty_struct *); + void (*close)(struct tty_struct *); + void (*flush_buffer)(struct tty_struct *tty); + int (*chars_in_buffer)(struct tty_struct *tty); + int (*read)(struct tty_struct * tty, struct file * file, + unsigned char * buf, unsigned int nr); + int (*write)(struct tty_struct * tty, struct file * file, + unsigned char * buf, unsigned int nr); + int (*ioctl)(struct tty_struct * tty, struct file * file, + unsigned int cmd, unsigned long arg); + void (*set_termios)(struct tty_struct *tty, struct termios * old); + int (*select)(struct tty_struct * tty, struct inode * inode, + struct file * file, int sel_type, + struct select_table_struct *wait); + + /* + * The following routines are called from below. + */ + void (*receive_buf)(struct tty_struct *, unsigned char *cp, + char *fp, int count); + int (*receive_room)(struct tty_struct *); + void (*write_wakeup)(struct tty_struct *); +}; + +#define TTY_LDISC_MAGIC 0x5403 + +#define LDISC_FLAG_DEFINED 0x00000001 + +#endif /* _LINUX_TTY_LDISC_H */ diff --git a/include/linux/types.h b/include/linux/types.h new file mode 100644 index 000000000..bc068f3b3 --- /dev/null +++ b/include/linux/types.h @@ -0,0 +1,129 @@ +#ifndef _LINUX_TYPES_H +#define _LINUX_TYPES_H + +#include <asm/types.h> + +#ifndef _SIZE_T +#define _SIZE_T +typedef unsigned int size_t; +#endif + +#ifndef _SSIZE_T +#define _SSIZE_T +typedef int ssize_t; +#endif + +#ifndef _TIME_T +#define _TIME_T +typedef long time_t; +#endif + +#ifndef _CLOCK_T +#define _CLOCK_T +typedef long clock_t; +#endif + +#ifndef _PTRDIFF_T +#define _PTRDIFF_T +typedef int ptrdiff_t; +#endif + +#ifndef NULL +#define NULL ((void *) 0) +#endif + +typedef int pid_t; +typedef unsigned short uid_t; +typedef unsigned short gid_t; +typedef unsigned short dev_t; +typedef unsigned long ino_t; +typedef unsigned short mode_t; +typedef unsigned short umode_t; +typedef unsigned short nlink_t; +typedef int daddr_t; +typedef long off_t; + +#ifndef __STRICT_ANSI__ +#define _LOFF_T +typedef long long loff_t; +#endif + +/* bsd */ +typedef unsigned char u_char; +typedef unsigned short u_short; +typedef unsigned int u_int; +typedef unsigned long u_long; + +/* sysv */ +typedef unsigned char unchar; +typedef unsigned short ushort; +typedef unsigned int uint; +typedef unsigned long ulong; + +typedef char *caddr_t; + +typedef unsigned char cc_t; +typedef unsigned int speed_t; +typedef unsigned long tcflag_t; + +/* + * This allows for 256 file descriptors: if NR_OPEN is ever grown beyond that + * you'll have to change this too. But 256 fd's seem to be enough even for such + * "real" unices like SunOS, so hopefully this is one limit that doesn't have + * to be changed. + * + * Note that POSIX wants the FD_CLEAR(fd,fdsetp) defines to be in <sys/time.h> + * (and thus <linux/time.h>) - but this is a more logical place for them. Solved + * by having dummy defines in <sys/time.h>. + */ + +/* + * Those macros may have been defined in <gnu/types.h>. But we always + * use the ones here. + */ +#undef __FDSET_LONGS +#define __FDSET_LONGS 8 + +typedef struct fd_set { + unsigned long fds_bits [__FDSET_LONGS]; +} fd_set; + +#undef __NFDBITS +#define __NFDBITS (8 * sizeof(unsigned long)) + +#undef __FD_SETSIZE +#define __FD_SETSIZE (__FDSET_LONGS*__NFDBITS) + +#undef __FD_SET +#define __FD_SET(fd,fdsetp) \ + __asm__ __volatile__("btsl %1,%0": \ + "=m" (*(fd_set *) (fdsetp)):"r" ((int) (fd))) + +#undef __FD_CLR +#define __FD_CLR(fd,fdsetp) \ + __asm__ __volatile__("btrl %1,%0": \ + "=m" (*(fd_set *) (fdsetp)):"r" ((int) (fd))) + +#undef __FD_ISSET +#define __FD_ISSET(fd,fdsetp) (__extension__ ({ \ + unsigned char __result; \ + __asm__ __volatile__("btl %1,%2 ; setb %0" \ + :"=q" (__result) :"r" ((int) (fd)), \ + "m" (*(fd_set *) (fdsetp))); \ + __result; })) + +#undef __FD_ZERO +#define __FD_ZERO(fdsetp) \ + __asm__ __volatile__("cld ; rep ; stosl" \ + :"=m" (*(fd_set *) (fdsetp)) \ + :"a" (0), "c" (__FDSET_LONGS), \ + "D" ((fd_set *) (fdsetp)) :"cx","di") + +struct ustat { + daddr_t f_tfree; + ino_t f_tinode; + char f_fname[6]; + char f_fpack[6]; +}; + +#endif diff --git a/include/linux/udp.h b/include/linux/udp.h new file mode 100644 index 000000000..471301a2f --- /dev/null +++ b/include/linux/udp.h @@ -0,0 +1,29 @@ +/* + * INET An implementation of the TCP/IP protocol suite for the LINUX + * operating system. INET is implemented using the BSD Socket + * interface as the means of communication with the user level. + * + * Definitions for the UDP protocol. + * + * Version: @(#)udp.h 1.0.2 04/28/93 + * + * Author: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> + * + * 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. + */ +#ifndef _LINUX_UDP_H +#define _LINUX_UDP_H + + +struct udphdr { + unsigned short source; + unsigned short dest; + unsigned short len; + unsigned short check; +}; + + +#endif /* _LINUX_UDP_H */ diff --git a/include/linux/ultrasound.h b/include/linux/ultrasound.h new file mode 100644 index 000000000..5571ca08d --- /dev/null +++ b/include/linux/ultrasound.h @@ -0,0 +1,121 @@ +#ifndef _ULTRASOUND_H_ +#define _ULTRASOUND_H_ +/* + * Copyright by Hannu Savolainen 1993 + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +/* + * ultrasound.h - Macros for programming the Gravis Ultrasound + * These macros are extremely device dependent + * and not portable. + */ + +/* + * Private events for Gravis Ultrasound (GUS) + * + * Format: + * byte 0 - SEQ_PRIVATE (0xfe) + * byte 1 - Synthesizer device number (0-N) + * byte 2 - Command (see below) + * byte 3 - Voice number (0-31) + * bytes 4 and 5 - parameter P1 (unsigned short) + * bytes 6 and 7 - parameter P2 (unsigned short) + * + * Commands: + * Each command affects one voice defined in byte 3. + * Unused parameters (P1 and/or P2 *MUST* be initialized to zero). + * _GUS_NUMVOICES - Sets max. number of concurrent voices (P1=14-31, default 16) + * _GUS_VOICESAMPLE- ************ OBSOLETE ************* + * _GUS_VOICEON - Starts voice (P1=voice mode) + * _GUS_VOICEOFF - Stops voice (no parameters) + * _GUS_VOICEFADE - Stops the voice smoothly. + * _GUS_VOICEMODE - Alters the voice mode, don't start or stop voice (P1=voice mode) + * _GUS_VOICEBALA - Sets voice balance (P1, 0=left, 7=middle and 15=right, default 7) + * _GUS_VOICEFREQ - Sets voice (sample) playback frequency (P1=Hz) + * _GUS_VOICEVOL - Sets voice volume (P1=volume, 0xfff=max, 0xeff=half, 0x000=off) + * _GUS_VOICEVOL2 - Sets voice volume (P1=volume, 0xfff=max, 0xeff=half, 0x000=off) + * (Like GUS_VOICEVOL but doesn't change the hw + * volume. It just updates volume in the voice table). + * + * _GUS_RAMPRANGE - Sets limits for volume ramping (P1=low volume, P2=high volume) + * _GUS_RAMPRATE - Sets the speed for volume ramping (P1=scale, P2=rate) + * _GUS_RAMPMODE - Sets the volume ramping mode (P1=ramping mode) + * _GUS_RAMPON - Starts volume ramping (no parameters) + * _GUS_RAMPOFF - Stops volume ramping (no parameters) + * _GUS_VOLUME_SCALE - Changes the volume calculation constants + * for all voices. + */ + +#define _GUS_NUMVOICES 0x00 +#define _GUS_VOICESAMPLE 0x01 /* OBSOLETE */ +#define _GUS_VOICEON 0x02 +#define _GUS_VOICEOFF 0x03 +#define _GUS_VOICEMODE 0x04 +#define _GUS_VOICEBALA 0x05 +#define _GUS_VOICEFREQ 0x06 +#define _GUS_VOICEVOL 0x07 +#define _GUS_RAMPRANGE 0x08 +#define _GUS_RAMPRATE 0x09 +#define _GUS_RAMPMODE 0x0a +#define _GUS_RAMPON 0x0b +#define _GUS_RAMPOFF 0x0c +#define _GUS_VOICEFADE 0x0d +#define _GUS_VOLUME_SCALE 0x0e +#define _GUS_VOICEVOL2 0x0f +#define _GUS_VOICE_POS 0x10 + +/* + * GUS API macros + */ + +#define _GUS_CMD(chn, voice, cmd, p1, p2) \ + {_SEQ_NEEDBUF(8); _seqbuf[_seqbufptr] = SEQ_PRIVATE;\ + _seqbuf[_seqbufptr+1] = (chn); _seqbuf[_seqbufptr+2] = cmd;\ + _seqbuf[_seqbufptr+3] = voice;\ + *(unsigned short*)&_seqbuf[_seqbufptr+4] = p1;\ + *(unsigned short*)&_seqbuf[_seqbufptr+6] = p2;\ + _SEQ_ADVBUF(8);} + +#define GUS_NUMVOICES(chn, p1) _GUS_CMD(chn, 0, _GUS_NUMVOICES, (p1), 0) +#define GUS_VOICESAMPLE(chn, voice, p1) _GUS_CMD(chn, voice, _GUS_VOICESAMPLE, (p1), 0) /* OBSOLETE */ +#define GUS_VOICEON(chn, voice, p1) _GUS_CMD(chn, voice, _GUS_VOICEON, (p1), 0) +#define GUS_VOICEOFF(chn, voice) _GUS_CMD(chn, voice, _GUS_VOICEOFF, 0, 0) +#define GUS_VOICEFADE(chn, voice) _GUS_CMD(chn, voice, _GUS_VOICEFADE, 0, 0) +#define GUS_VOICEMODE(chn, voice, p1) _GUS_CMD(chn, voice, _GUS_VOICEMODE, (p1), 0) +#define GUS_VOICEBALA(chn, voice, p1) _GUS_CMD(chn, voice, _GUS_VOICEBALA, (p1), 0) +#define GUS_VOICEFREQ(chn, voice, p) _GUS_CMD(chn, voice, _GUS_VOICEFREQ, \ + (p) & 0xffff, ((p) >> 16) & 0xffff) +#define GUS_VOICEVOL(chn, voice, p1) _GUS_CMD(chn, voice, _GUS_VOICEVOL, (p1), 0) +#define GUS_VOICEVOL2(chn, voice, p1) _GUS_CMD(chn, voice, _GUS_VOICEVOL2, (p1), 0) +#define GUS_RAMPRANGE(chn, voice, low, high) _GUS_CMD(chn, voice, _GUS_RAMPRANGE, (low), (high)) +#define GUS_RAMPRATE(chn, voice, p1, p2) _GUS_CMD(chn, voice, _GUS_RAMPRATE, (p1), (p2)) +#define GUS_RAMPMODE(chn, voice, p1) _GUS_CMD(chn, voice, _GUS_RAMPMODE, (p1), 0) +#define GUS_RAMPON(chn, voice, p1) _GUS_CMD(chn, voice, _GUS_RAMPON, (p1), 0) +#define GUS_RAMPOFF(chn, voice) _GUS_CMD(chn, voice, _GUS_RAMPOFF, 0, 0) +#define GUS_VOLUME_SCALE(chn, voice, p1, p2) _GUS_CMD(chn, voice, _GUS_VOLUME_SCALE, (p1), (p2)) +#define GUS_VOICE_POS(chn, voice, p) _GUS_CMD(chn, voice, _GUS_VOICE_POS, \ + (p) & 0xffff, ((p) >> 16) & 0xffff) + +#endif diff --git a/include/linux/umsdos_fs.h b/include/linux/umsdos_fs.h new file mode 100644 index 000000000..9f943237e --- /dev/null +++ b/include/linux/umsdos_fs.h @@ -0,0 +1,106 @@ +#ifndef LINUX_UMSDOS_FS_H +#define LINUX_UMSDOS_FS_H + +#define UMSDOS_VERSION 0 +#define UMSDOS_RELEASE 3 + +#ifndef LINUX_FS_H +#include <linux/fs.h> +#endif + +/* This is the file acting as a directory extension */ +#define UMSDOS_EMD_FILE "--linux-.---" +#define UMSDOS_EMD_NAMELEN 12 +#define UMSDOS_PSDROOT_NAME "linux" +#define UMSDOS_PSDROOT_LEN 5 + +struct umsdos_fake_info { + char fname[13]; + int len; +}; + +#define UMSDOS_MAXNAME 220 +/* This structure is 256 bytes large, depending on the name, only part */ +/* of it is written to disk */ +struct umsdos_dirent { + unsigned char name_len; /* if == 0, then this entry is not used */ + unsigned char flags; /* UMSDOS_xxxx */ + unsigned short nlink; /* How many hard links point to this entry */ + uid_t uid; /* Owner user id */ + gid_t gid; /* Group id */ + time_t atime; /* Access time */ + time_t mtime; /* Last modification time */ + time_t ctime; /* Creation time */ + dev_t rdev; /* major and minor number of a device */ + /* special file */ + umode_t mode; /* Standard UNIX permissions bits + type of */ + char spare[12]; /* unused bytes for future extensions */ + /* file, see linux/stat.h */ + char name[UMSDOS_MAXNAME]; /* Not '\0' terminated */ + /* but '\0' padded, so it will allow */ + /* for adding news fields in this record */ + /* by reducing the size of name[] */ +}; +#define UMSDOS_HIDDEN 1 /* Never show this entry in directory search */ +#define UMSDOS_HLINK 2 /* It is a (pseudo) hard link */ + +/* #Specification: EMD file / record size + Entry are 64 bytes wide in the EMD file. It allows for a 30 characters + name. If a name is longer, contiguous entries are allocated. So a + umsdos_dirent may span multiple records. +*/ +#define UMSDOS_REC_SIZE 64 + +/* Translation between MSDOS name and UMSDOS name */ +struct umsdos_info{ + int msdos_reject; /* Tell if the file name is invalid for MSDOS */ + /* See umsdos_parse */ + struct umsdos_fake_info fake; + struct umsdos_dirent entry; + off_t f_pos; /* offset of the entry in the EMD file */ + /* or offset where the entry may be store */ + /* if it is a new entry */ + int recsize; /* Record size needed to store entry */ +}; + +/* Definitions for ioctl (number randomly chosen) */ +/* The next ioctl commands operate only on the DOS directory */ +/* The file umsdos_progs/umsdosio.c contain a string table */ +/* based on the order of those definition. Keep it in sync */ +#define UMSDOS_READDIR_DOS 1234 /* Do a readdir of the DOS directory */ +#define UMSDOS_UNLINK_DOS 1235 /* Erase in the DOS directory only */ +#define UMSDOS_RMDIR_DOS 1236 /* rmdir in the DOS directory only */ +#define UMSDOS_STAT_DOS 1237 /* Get info about a file */ +/* The next ioctl commands operate only on the EMD file */ +#define UMSDOS_CREAT_EMD 1238 /* Create a file */ +#define UMSDOS_UNLINK_EMD 1239 /* unlink (rmdir) a file */ +#define UMSDOS_READDIR_EMD 1240 /* read the EMD file only. */ +#define UMSDOS_GETVERSION 1241 /* Get the release number of UMSDOS */ +#define UMSDOS_INIT_EMD 1242 /* Create the EMD file if not there */ +#define UMSDOS_DOS_SETUP 1243 /* Set the defaults of the MsDOS driver */ + +#include <linux/stat.h> + +struct umsdos_ioctl{ + struct dirent dos_dirent; + struct umsdos_dirent umsdos_dirent; + struct new_stat stat; + char version,release; +}; + +/* Different macros to access struct umsdos_dirent */ +#define EDM_ENTRY_ISUSED(e) ((e)->name_len!=0) + +#ifdef __KERNEL__ + +extern struct inode_operations umsdos_dir_inode_operations; +extern struct file_operations umsdos_file_operations; +extern struct inode_operations umsdos_file_inode_operations; +extern struct inode_operations umsdos_file_inode_operations_no_bmap; +extern struct inode_operations umsdos_symlink_inode_operations; + +#include <linux/umsdos_fs.p> + +#endif /* __KERNEL__ */ + +#endif diff --git a/include/linux/umsdos_fs.p b/include/linux/umsdos_fs.p new file mode 100644 index 000000000..ef91d03ed --- /dev/null +++ b/include/linux/umsdos_fs.p @@ -0,0 +1,133 @@ +/* check.c 20/07/94 10.08.36 */ +void check_page_tables (void); +/* dir.c 22/07/94 01.06.58 */ +int UMSDOS_dir_read (struct inode *inode, + struct file *filp, + char *buf, + int count); +void umsdos_lookup_patch (struct inode *dir, + struct inode *inode, + struct umsdos_dirent *entry, + off_t emd_pos); +int umsdos_inode2entry (struct inode *dir, + struct inode *inode, + struct umsdos_dirent *entry); +int umsdos_locate_path (struct inode *inode, char *path); +int umsdos_is_pseudodos (struct inode *dir, const char *name, int len); +int UMSDOS_lookup (struct inode *dir, + const char *name, + int len, + struct inode **result); +int umsdos_hlink2inode (struct inode *hlink, struct inode **result); +/* emd.c 22/07/94 01.06.38 */ +int umsdos_readdir_kmem (struct inode *inode, + struct file *filp, + struct dirent *dirent, + int count); +int umsdos_file_read_kmem (struct inode *inode, + struct file *filp, + char *buf, + int count); +int umsdos_file_write_kmem (struct inode *inode, + struct file *filp, + char *buf, + int count); +int umsdos_emd_dir_write (struct inode *emd_dir, + struct file *filp, + char *buf, + int count); +int umsdos_emd_dir_read (struct inode *emd_dir, + struct file *filp, + char *buf, + int count); +struct inode *umsdos_emd_dir_lookup (struct inode *dir, int creat); +int umsdos_emd_dir_readentry (struct inode *emd_dir, + struct file *filp, + struct umsdos_dirent *entry); +int umsdos_writeentry (struct inode *dir, + struct inode *emd_dir, + struct umsdos_info *info, + int free_entry); +int umsdos_newentry (struct inode *dir, struct umsdos_info *info); +int umsdos_newhidden (struct inode *dir, struct umsdos_info *info); +int umsdos_delentry (struct inode *dir, + struct umsdos_info *info, + int isdir); +int umsdos_isempty (struct inode *dir); +int umsdos_findentry (struct inode *dir, + struct umsdos_info *info, + int expect); +/* file.c 20/07/94 10.08.36 */ +/* inode.c 20/07/94 10.08.36 */ +void UMSDOS_put_inode (struct inode *inode); +void UMSDOS_put_super (struct super_block *sb); +void UMSDOS_statfs (struct super_block *sb, struct statfs *buf); +int umsdos_real_lookup (struct inode *dir, + const char *name, + int len, + struct inode **result); +void umsdos_setup_dir_inode (struct inode *inode); +void umsdos_set_dirinfo (struct inode *inode, + struct inode *dir, + off_t f_pos); +int umsdos_isinit (struct inode *inode); +void umsdos_patch_inode (struct inode *inode, + struct inode *dir, + off_t f_pos); +int umsdos_get_dirowner (struct inode *inode, struct inode **result); +void UMSDOS_read_inode (struct inode *inode); +void UMSDOS_write_inode (struct inode *inode); +int UMSDOS_notify_change (struct inode *inode, struct iattr *attr); +struct super_block *UMSDOS_read_super (struct super_block *s, + void *data, + int silent); +/* ioctl.c 20/07/94 10.08.36 */ +int UMSDOS_ioctl_dir (struct inode *dir, + struct file *filp, + unsigned int cmd, + unsigned long data); +/* mangle.c 20/07/94 10.08.36 */ +void umsdos_manglename (struct umsdos_info *info); +int umsdos_evalrecsize (int len); +int umsdos_parse (const char *fname, int len, struct umsdos_info *info); +/* namei.c 22/07/94 00.59.28 */ +void umsdos_lockcreate (struct inode *dir); +void umsdos_startlookup (struct inode *dir); +void umsdos_unlockcreate (struct inode *dir); +void umsdos_endlookup (struct inode *dir); +int UMSDOS_symlink (struct inode *dir, + const char *name, + int len, + const char *symname); +int UMSDOS_link (struct inode *oldinode, + struct inode *dir, + const char *name, + int len); +int UMSDOS_create (struct inode *dir, + const char *name, + int len, + int mode, + struct inode **result); +int UMSDOS_mkdir (struct inode *dir, + const char *name, + int len, + int mode); +int UMSDOS_mknod (struct inode *dir, + const char *name, + int len, + int mode, + int rdev); +int UMSDOS_rmdir (struct inode *dir, const char *name, int len); +int UMSDOS_unlink (struct inode *dir, const char *name, int len); +int UMSDOS_rename (struct inode *old_dir, + const char *old_name, + int old_len, + struct inode *new_dir, + const char *new_name, + int new_len); +/* rdir.c 20/07/94 10.08.38 */ +int UMSDOS_rlookup (struct inode *dir, + const char *name, + int len, + struct inode **result); +/* symlink.c 22/07/94 00.59.10 */ diff --git a/include/linux/umsdos_fs_i.h b/include/linux/umsdos_fs_i.h new file mode 100644 index 000000000..36a5f47f4 --- /dev/null +++ b/include/linux/umsdos_fs_i.h @@ -0,0 +1,140 @@ +#ifndef UMSDOS_FS_I_H +#define UMSDOS_FS_I_H + +#ifndef _LINUX_TYPES_H +#include <linux/types.h> +#endif +#include <linux/msdos_fs_i.h> +#include <linux/pipe_fs_i.h> + +/* #Specification: strategy / in memory inode + Here is the information specific to the inode of the UMSDOS file + system. This information is added to the end of the standard struct + inode. Each file system has its own extension to struct inode, + so do the umsdos file system. + + The strategy is to have the umsdos_inode_info as a superset of + the msdos_inode_info, since most of the time the job is done + by the msdos fs code. + + So we duplicate the msdos_inode_info, and add our own info at the + end. + + For all file type (and directory) the inode has a reference to: + the directory which hold this entry: i_dir_owner + The EMD file of i_dir_owner: i_emd_owner + The offset in this EMD file of the entry: pos + + For directory, we also have a reference to the inode of its + own EMD file. Also, we have dir_locking_info to help synchronise + file creation and file lookup. This data is sharing space with + the pipe_inode_info not used by directory. See also msdos_fs_i.h + for more information about pipe_inode_info and msdos_inode_info. + + Special file and fifo do have an inode which correspond to an + empty MSDOS file. + + symlink are processed mostly like regular file. The content is the + link. + + fifos add there own extension to the inode. I have reserved some + space for fifos side by side with msdos_inode_info. This is just + to for the show, because msdos_inode_info already include the + pipe_inode_info. + + The UMSDOS specific extension is placed after the union. +*/ +struct dir_locking_info { + struct wait_queue *p; + short int looking; /* How many process doing a lookup */ + short int creating; /* Is there any creation going on here */ + /* Only one at a time, although one */ + /* may recursively lock, so it is a counter */ + long pid; /* pid of the process owning the creation */ + /* lock */ +}; +struct umsdos_inode_info { + union { + struct msdos_inode_info msdos_info; + struct pipe_inode_info pipe_info; + struct dir_locking_info dir_info; + }u; /* Simply a filler, never referenced by fs/umsdos/... */ + unsigned long i_dir_owner; /* Inode of the dir which hold this */ + /* entry */ + unsigned long i_emd_owner; /* Inode of the EMD file of i_dir_owner */ + off_t pos; /* Entry offset in the emd_owner file */ + /* The rest is used only if this inode describe a directory */ + unsigned long i_emd_dir; /* Inode of the EMD file of this inode */ +}; + +#endif +#ifndef UMSDOS_FS_I_H +#define UMSDOS_FS_I_H + +#ifndef _LINUX_TYPES_H +#include <linux/types.h> +#endif +#include <linux/msdos_fs_i.h> +#include <linux/pipe_fs_i.h> + +/* #Specification: strategy / in memory inode + Here is the information specific to the inode of the UMSDOS file + system. This information is added to the end of the standard struct + inode. Each file system has its own extension to struct inode, + so do the umsdos file system. + + The strategy is to have the umsdos_inode_info as a superset of + the msdos_inode_info, since most of the time the job is done + by the msdos fs code. + + So we duplicate the msdos_inode_info, and add our own info at the + end. + + For all file type (and directory) the inode has a reference to: + the directory which hold this entry: i_dir_owner + The EMD file of i_dir_owner: i_emd_owner + The offset in this EMD file of the entry: pos + + For directory, we also have a reference to the inode of its + own EMD file. Also, we have dir_locking_info to help synchronise + file creation and file lookup. This data is sharing space with + the pipe_inode_info not used by directory. See also msdos_fs_i.h + for more information about pipe_inode_info and msdos_inode_info. + + Special file and fifo do have an inode which correspond to an + empty MSDOS file. + + symlink are processed mostly like regular file. The content is the + link. + + fifos add there own extension to the inode. I have reserved some + space for fifos side by side with msdos_inode_info. This is just + to for the show, because msdos_inode_info already include the + pipe_inode_info. + + The UMSDOS specific extension is placed after the union. +*/ +struct dir_locking_info { + struct wait_queue *p; + short int looking; /* How many process doing a lookup */ + short int creating; /* Is there any creation going on here */ + /* Only one at a time, although one */ + /* may recursively lock, so it is a counter */ + long pid; /* pid of the process owning the creation */ + /* lock */ +}; +struct umsdos_inode_info { + union { + struct msdos_inode_info msdos_info; + struct pipe_inode_info pipe_info; + struct dir_locking_info dir_info; + }u; /* Simply a filler, never referenced by fs/umsdos/... */ + unsigned long i_dir_owner; /* Inode of the dir which hold this */ + /* entry */ + unsigned long i_emd_owner; /* Inode of the EMD file of i_dir_owner */ + off_t pos; /* Entry offset in the emd_owner file */ + /* The rest is used only if this inode describe a directory */ + unsigned long i_emd_dir; /* Inode of the EMD file of this inode */ +}; + +#endif diff --git a/include/linux/un.h b/include/linux/un.h new file mode 100644 index 000000000..e11ad75fe --- /dev/null +++ b/include/linux/un.h @@ -0,0 +1,11 @@ +#ifndef _LINUX_UN_H +#define _LINUX_UN_H + +#define UNIX_PATH_MAX 108 + +struct sockaddr_un { + unsigned short sun_family; /* AF_UNIX */ + char sun_path[UNIX_PATH_MAX]; /* pathname */ +}; + +#endif /* _LINUX_UN_H */ diff --git a/include/linux/unistd.h b/include/linux/unistd.h new file mode 100644 index 000000000..8ac5e0474 --- /dev/null +++ b/include/linux/unistd.h @@ -0,0 +1,157 @@ +#ifndef _LINUX_UNISTD_H_ +#define _LINUX_UNISTD_H_ + +/* + * This file contains the system call numbers. + */ + +#define __NR_setup 0 /* used only by init, to get system going */ +#define __NR_exit 1 +#define __NR_fork 2 +#define __NR_read 3 +#define __NR_write 4 +#define __NR_open 5 +#define __NR_close 6 +#define __NR_waitpid 7 +#define __NR_creat 8 +#define __NR_link 9 +#define __NR_unlink 10 +#define __NR_execve 11 +#define __NR_chdir 12 +#define __NR_time 13 +#define __NR_mknod 14 +#define __NR_chmod 15 +#define __NR_chown 16 +#define __NR_break 17 +#define __NR_oldstat 18 +#define __NR_lseek 19 +#define __NR_getpid 20 +#define __NR_mount 21 +#define __NR_umount 22 +#define __NR_setuid 23 +#define __NR_getuid 24 +#define __NR_stime 25 +#define __NR_ptrace 26 +#define __NR_alarm 27 +#define __NR_oldfstat 28 +#define __NR_pause 29 +#define __NR_utime 30 +#define __NR_stty 31 +#define __NR_gtty 32 +#define __NR_access 33 +#define __NR_nice 34 +#define __NR_ftime 35 +#define __NR_sync 36 +#define __NR_kill 37 +#define __NR_rename 38 +#define __NR_mkdir 39 +#define __NR_rmdir 40 +#define __NR_dup 41 +#define __NR_pipe 42 +#define __NR_times 43 +#define __NR_prof 44 +#define __NR_brk 45 +#define __NR_setgid 46 +#define __NR_getgid 47 +#define __NR_signal 48 +#define __NR_geteuid 49 +#define __NR_getegid 50 +#define __NR_acct 51 +#define __NR_phys 52 +#define __NR_lock 53 +#define __NR_ioctl 54 +#define __NR_fcntl 55 +#define __NR_mpx 56 +#define __NR_setpgid 57 +#define __NR_ulimit 58 +#define __NR_oldolduname 59 +#define __NR_umask 60 +#define __NR_chroot 61 +#define __NR_ustat 62 +#define __NR_dup2 63 +#define __NR_getppid 64 +#define __NR_getpgrp 65 +#define __NR_setsid 66 +#define __NR_sigaction 67 +#define __NR_sgetmask 68 +#define __NR_ssetmask 69 +#define __NR_setreuid 70 +#define __NR_setregid 71 +#define __NR_sigsuspend 72 +#define __NR_sigpending 73 +#define __NR_sethostname 74 +#define __NR_setrlimit 75 +#define __NR_getrlimit 76 +#define __NR_getrusage 77 +#define __NR_gettimeofday 78 +#define __NR_settimeofday 79 +#define __NR_getgroups 80 +#define __NR_setgroups 81 +#define __NR_select 82 +#define __NR_symlink 83 +#define __NR_oldlstat 84 +#define __NR_readlink 85 +#define __NR_uselib 86 +#define __NR_swapon 87 +#define __NR_reboot 88 +#define __NR_readdir 89 +#define __NR_mmap 90 +#define __NR_munmap 91 +#define __NR_truncate 92 +#define __NR_ftruncate 93 +#define __NR_fchmod 94 +#define __NR_fchown 95 +#define __NR_getpriority 96 +#define __NR_setpriority 97 +#define __NR_profil 98 +#define __NR_statfs 99 +#define __NR_fstatfs 100 +#define __NR_ioperm 101 +#define __NR_socketcall 102 +#define __NR_syslog 103 +#define __NR_setitimer 104 +#define __NR_getitimer 105 +#define __NR_stat 106 +#define __NR_lstat 107 +#define __NR_fstat 108 +#define __NR_olduname 109 +#define __NR_iopl 110 +#define __NR_vhangup 111 +#define __NR_idle 112 +#define __NR_vm86 113 +#define __NR_wait4 114 +#define __NR_swapoff 115 +#define __NR_sysinfo 116 +#define __NR_ipc 117 +#define __NR_fsync 118 +#define __NR_sigreturn 119 +#define __NR_clone 120 +#define __NR_setdomainname 121 +#define __NR_uname 122 +#define __NR_modify_ldt 123 +#define __NR_adjtimex 124 +#define __NR_mprotect 125 +#define __NR_sigprocmask 126 +#define __NR_create_module 127 +#define __NR_init_module 128 +#define __NR_delete_module 129 +#define __NR_get_kernel_syms 130 +#define __NR_quotactl 131 +#define __NR_getpgid 132 +#define __NR_fchdir 133 +#define __NR_bdflush 134 +#define __NR_sysfs 135 +#define __NR_personality 136 +#define __NR_afs_syscall 137 /* Syscall for Andrew File System */ +#define __NR_setfsuid 138 +#define __NR_setfsgid 139 +#define __NR__llseek 140 + +extern int errno; + +/* + * Include machine specific syscallX macros + */ +#include <asm/unistd.h> + +#endif /* _LINUX_UNISTD_H_ */ diff --git a/include/linux/user.h b/include/linux/user.h new file mode 100644 index 000000000..3fbee19e4 --- /dev/null +++ b/include/linux/user.h @@ -0,0 +1,77 @@ +#ifndef _LINUX_USER_H +#define _LINUX_USER_H + +#include <linux/ptrace.h> +/* Core file format: The core file is written in such a way that gdb + can understand it and provide useful information to the user (under + linux we use the 'trad-core' bfd). There are quite a number of + obstacles to being able to view the contents of the floating point + registers, and until these are solved you will not be able to view the + contents of them. Actually, you can read in the core file and look at + the contents of the user struct to find out what the floating point + registers contain. + The actual file contents are as follows: + UPAGE: 1 page consisting of a user struct that tells gdb what is present + in the file. Directly after this is a copy of the task_struct, which + is currently not used by gdb, but it may come in useful at some point. + All of the registers are stored as part of the upage. The upage should + always be only one page. + DATA: The data area is stored. We use current->end_text to + current->brk to pick up all of the user variables, plus any memory + that may have been malloced. No attempt is made to determine if a page + is demand-zero or if a page is totally unused, we just cover the entire + range. All of the addresses are rounded in such a way that an integral + number of pages is written. + STACK: We need the stack information in order to get a meaningful + backtrace. We need to write the data from (esp) to + current->start_stack, so we round each of these off in order to be able + to write an integer number of pages. + The minimum core file size is 3 pages, or 12288 bytes. +*/ + +struct user_i387_struct { + long cwd; + long swd; + long twd; + long fip; + long fcs; + long foo; + long fos; + long st_space[20]; /* 8*10 bytes for each FP-reg = 80 bytes */ +}; + +/* When the kernel dumps core, it starts by dumping the user struct - + this will be used by gdb to figure out where the data and stack segments + are within the file, and what virtual addresses to use. */ +struct user{ +/* We start with the registers, to mimic the way that "memory" is returned + from the ptrace(3,...) function. */ + struct pt_regs regs; /* Where the registers are actually stored */ +/* ptrace does not yet supply these. Someday.... */ + int u_fpvalid; /* True if math co-processor being used. */ + /* for this mess. Not yet used. */ + struct user_i387_struct i387; /* Math Co-processor registers. */ +/* The rest of this junk is to help gdb figure out what goes where */ + unsigned long int u_tsize; /* Text segment size (pages). */ + unsigned long int u_dsize; /* Data segment size (pages). */ + unsigned long int u_ssize; /* Stack segment size (pages). */ + unsigned long start_code; /* Starting virtual address of text. */ + unsigned long start_stack; /* Starting virtual address of stack area. + This is actually the bottom of the stack, + the top of the stack is always found in the + esp register. */ + long int signal; /* Signal that caused the core dump. */ + int reserved; /* No longer used */ + struct pt_regs * u_ar0; /* Used by gdb to help find the values for */ + /* the registers. */ + struct user_i387_struct* u_fpstate; /* Math Co-processor pointer. */ + unsigned long magic; /* To uniquely identify a core file */ + char u_comm[32]; /* User command that was responsible */ + int u_debugreg[8]; +}; +#define NBPG 4096 +#define UPAGES 1 +#define HOST_TEXT_START_ADDR (u.start_code) +#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG) + +#endif diff --git a/include/linux/utime.h b/include/linux/utime.h new file mode 100644 index 000000000..c6bf27b78 --- /dev/null +++ b/include/linux/utime.h @@ -0,0 +1,9 @@ +#ifndef _LINUX_UTIME_H +#define _LINUX_UTIME_H + +struct utimbuf { + time_t actime; + time_t modtime; +}; + +#endif diff --git a/include/linux/utsname.h b/include/linux/utsname.h new file mode 100644 index 000000000..7aef28fc3 --- /dev/null +++ b/include/linux/utsname.h @@ -0,0 +1,35 @@ +#ifndef _LINUX_UTSNAME_H +#define _LINUX_UTSNAME_H + +#define __OLD_UTS_LEN 8 + +struct oldold_utsname { + char sysname[9]; + char nodename[9]; + char release[9]; + char version[9]; + char machine[9]; +}; + +#define __NEW_UTS_LEN 64 + +struct old_utsname { + char sysname[65]; + char nodename[65]; + char release[65]; + char version[65]; + char machine[65]; +}; + +struct new_utsname { + char sysname[65]; + char nodename[65]; + char release[65]; + char version[65]; + char machine[65]; + char domainname[65]; +}; + +extern struct new_utsname system_utsname; + +#endif diff --git a/include/linux/vfs.h b/include/linux/vfs.h new file mode 100644 index 000000000..463df2fd7 --- /dev/null +++ b/include/linux/vfs.h @@ -0,0 +1,21 @@ +#ifndef _LINUX_VFS_H +#define _LINUX_VFS_H + +typedef struct { + long val[2]; +} fsid_t; + +struct statfs { + long f_type; + long f_bsize; + long f_blocks; + long f_bfree; + long f_bavail; + long f_files; + long f_ffree; + fsid_t f_fsid; + long f_namelen; + long f_spare[6]; +}; + +#endif diff --git a/include/linux/vm86.h b/include/linux/vm86.h new file mode 100644 index 000000000..ceb10358f --- /dev/null +++ b/include/linux/vm86.h @@ -0,0 +1,109 @@ +#ifndef _LINUX_VM86_H +#define _LINUX_VM86_H + +/* + * I'm guessing at the VIF/VIP flag usage, but hope that this is how + * the Pentium uses them. Linux will return from vm86 mode when both + * VIF and VIP is set. + * + * On a Pentium, we could probably optimize the virtual flags directly + * in the eflags register instead of doing it "by hand" in vflags... + * + * Linus + */ + +#define TF_MASK 0x00000100 +#define IF_MASK 0x00000200 +#define IOPL_MASK 0x00003000 +#define NT_MASK 0x00004000 +#define VM_MASK 0x00020000 +#define AC_MASK 0x00040000 +#define VIF_MASK 0x00080000 /* virtual interrupt flag */ +#define VIP_MASK 0x00100000 /* virtual interrupt pending */ +#define ID_MASK 0x00200000 + +#define BIOSSEG 0x0f000 + +#define CPU_086 0 +#define CPU_186 1 +#define CPU_286 2 +#define CPU_386 3 +#define CPU_486 4 +#define CPU_586 5 + +/* + * Return values for the 'vm86()' system call + */ +#define VM86_TYPE(retval) ((retval) & 0xff) +#define VM86_ARG(retval) ((retval) >> 8) + +#define VM86_SIGNAL 0 /* return due to signal */ +#define VM86_UNKNOWN 1 /* unhandled GP fault - IO-instruction or similar */ +#define VM86_INTx 2 /* int3/int x instruction (ARG = x) */ +#define VM86_STI 3 /* sti/popf/iret instruction enabled virtual interrupts */ + +/* + * This is the stack-layout when we have done a "SAVE_ALL" from vm86 + * mode - the main change is that the old segment descriptors aren't + * useful any more and are forced to be zero by the kernel (and the + * hardware when a trap occurs), and the real segment descriptors are + * at the end of the structure. Look at ptrace.h to see the "normal" + * setup. + */ + +struct vm86_regs { +/* + * normal regs, with special meaning for the segment descriptors.. + */ + long ebx; + long ecx; + long edx; + long esi; + long edi; + long ebp; + long eax; + long __null_ds; + long __null_es; + long __null_fs; + long __null_gs; + long orig_eax; + long eip; + unsigned short cs, __csh; + long eflags; + long esp; + unsigned short ss, __ssh; +/* + * these are specific to v86 mode: + */ + unsigned short es, __esh; + unsigned short ds, __dsh; + unsigned short fs, __fsh; + unsigned short gs, __gsh; +}; + +struct revectored_struct { + unsigned long __map[8]; /* 256 bits */ +}; + +struct vm86_struct { + struct vm86_regs regs; + unsigned long flags; + unsigned long screen_bitmap; + unsigned long cpu_type; + struct revectored_struct int_revectored; + struct revectored_struct int21_revectored; +}; + +/* + * flags masks + */ +#define VM86_SCREEN_BITMAP 0x0001 + +#ifdef __KERNEL__ + +void handle_vm86_fault(struct vm86_regs *, long); +void handle_vm86_debug(struct vm86_regs *, long); + +#endif + +#endif diff --git a/include/linux/vt.h b/include/linux/vt.h new file mode 100644 index 000000000..33f1ad659 --- /dev/null +++ b/include/linux/vt.h @@ -0,0 +1,42 @@ +#ifndef _LINUX_VT_H +#define _LINUX_VT_H + +/* 0x56 is 'V', to avoid collision with termios and kd */ + +#define VT_OPENQRY 0x5600 /* find available vt */ + +struct vt_mode { + char mode; /* vt mode */ + char waitv; /* if set, hang on writes if not active */ + short relsig; /* signal to raise on release req */ + short acqsig; /* signal to raise on acquisition */ + short frsig; /* unused (set to 0) */ +}; +#define VT_GETMODE 0x5601 /* get mode of active vt */ +#define VT_SETMODE 0x5602 /* set mode of active vt */ +#define VT_AUTO 0x00 /* auto vt switching */ +#define VT_PROCESS 0x01 /* process controls switching */ +#define VT_ACKACQ 0x02 /* acknowledge switch */ + +struct vt_stat { + ushort v_active; /* active vt */ + ushort v_signal; /* signal to send */ + ushort v_state; /* vt bitmask */ +}; +#define VT_GETSTATE 0x5603 /* get global vt state info */ +#define VT_SENDSIG 0x5604 /* signal to send to bitmask of vts */ + +#define VT_RELDISP 0x5605 /* release display */ + +#define VT_ACTIVATE 0x5606 /* make vt active */ +#define VT_WAITACTIVE 0x5607 /* wait for vt active */ +#define VT_DISALLOCATE 0x5608 /* free memory associated to vt */ + +struct vt_sizes { + ushort v_rows; /* number of rows */ + ushort v_cols; /* number of columns */ + ushort v_scrollsize; /* number of lines of scrollback */ +}; +#define VT_RESIZE 0x5609 /* set kernel's idea of screensize */ + +#endif /* _LINUX_VT_H */ diff --git a/include/linux/wait.h b/include/linux/wait.h new file mode 100644 index 000000000..90ffe7b3b --- /dev/null +++ b/include/linux/wait.h @@ -0,0 +1,38 @@ +#ifndef _LINUX_WAIT_H +#define _LINUX_WAIT_H + +#define WNOHANG 0x00000001 +#define WUNTRACED 0x00000002 + +#define __WCLONE 0x80000000 + +#ifdef __KERNEL__ + +struct wait_queue { + struct task_struct * task; + struct wait_queue * next; +}; + +struct semaphore { + int count; + struct wait_queue * wait; +}; + +#define MUTEX ((struct semaphore) { 1, NULL }) +#define MUTEX_LOCKED ((struct semaphore) { 0, NULL }) + +struct select_table_entry { + struct wait_queue wait; + struct wait_queue ** wait_address; +}; + +typedef struct select_table_struct { + int nr; + struct select_table_entry * entry; +} select_table; + +#define __MAX_SELECT_TABLE_ENTRIES (4096 / sizeof (struct select_table_entry)) + +#endif /* __KERNEL__ */ + +#endif diff --git a/include/linux/xd.h b/include/linux/xd.h new file mode 100644 index 000000000..64ae79953 --- /dev/null +++ b/include/linux/xd.h @@ -0,0 +1,139 @@ +#ifndef _LINUX_XD_H +#define _LINUX_XD_H + +/* + * This file contains the definitions for the IO ports and errors etc. for XT hard disk controllers (at least the DTC 5150X). + * + * Author: Pat Mackinlay, pat@it.com.au + * Date: 29/09/92 + * + * Revised: 01/01/93, ... + * + * Ref: DTC 5150X Controller Specification (thanks to Kevin Fowler, kevinf@agora.rain.com) + * Also thanks to: Salvador Abreu, Dave Thaler, Risto Kankkunen and Wim Van Dorst. + */ + +/* XT hard disk controller registers */ +#define XD_DATA (xd_iobase + 0x00) /* data RW register */ +#define XD_RESET (xd_iobase + 0x01) /* reset WO register */ +#define XD_STATUS (xd_iobase + 0x01) /* status RO register */ +#define XD_SELECT (xd_iobase + 0x02) /* select WO register */ +#define XD_JUMPER (xd_iobase + 0x02) /* jumper RO register */ +#define XD_CONTROL (xd_iobase + 0x03) /* DMAE/INTE WO register */ +#define XD_RESERVED (xd_iobase + 0x03) /* reserved */ + +/* XT hard disk controller commands (incomplete list) */ +#define CMD_TESTREADY 0x00 /* test drive ready */ +#define CMD_RECALIBRATE 0x01 /* recalibrate drive */ +#define CMD_SENSE 0x03 /* request sense */ +#define CMD_FORMATDRV 0x04 /* format drive */ +#define CMD_VERIFY 0x05 /* read verify */ +#define CMD_FORMATTRK 0x06 /* format track */ +#define CMD_FORMATBAD 0x07 /* format bad track */ +#define CMD_READ 0x08 /* read */ +#define CMD_WRITE 0x0A /* write */ +#define CMD_SEEK 0x0B /* seek */ + +/* Controller specific commands */ +#define CMD_DTCSETPARAM 0x0C /* set drive parameters (DTC 5150X only?) */ +#define CMD_DTCGETECC 0x0D /* get ecc error length (DTC 5150X only?) */ +#define CMD_DTCREADBUF 0x0E /* read sector buffer (DTC 5150X only?) */ +#define CMD_DTCWRITEBUF 0x0F /* write sector buffer (DTC 5150X only?) */ +#define CMD_DTCREMAPTRK 0x11 /* assign alternate track (DTC 5150X only?) */ +#define CMD_DTCGETPARAM 0xFB /* get drive parameters (DTC 5150X only?) */ +#define CMD_DTCSETSTEP 0xFC /* set step rate (DTC 5150X only?) */ +#define CMD_DTCSETGEOM 0xFE /* set geometry data (DTC 5150X only?) */ +#define CMD_DTCGETGEOM 0xFF /* get geometry data (DTC 5150X only?) */ +#define CMD_ST11GETGEOM 0xF8 /* get geometry data (Seagate ST11R/M only?) */ +#define CMD_WDSETPARAM 0x0C /* set drive parameters (WD 1004A27X only?) */ + +/* Bits for command status byte */ +#define CSB_ERROR 0x02 /* error */ +#define CSB_LUN 0x20 /* logical Unit Number */ + +/* XT hard disk controller status bits */ +#define STAT_READY 0x01 /* controller is ready */ +#define STAT_INPUT 0x02 /* data flowing from controller to host */ +#define STAT_COMMAND 0x04 /* controller in command phase */ +#define STAT_SELECT 0x08 /* controller is selected */ +#define STAT_REQUEST 0x10 /* controller requesting data */ +#define STAT_INTERRUPT 0x20 /* controller requesting interrupt */ + +/* XT hard disk controller control bits */ +#define PIO_MODE 0x00 /* control bits to set for PIO */ +#define DMA_MODE 0x03 /* control bits to set for DMA & interrupt */ + +#define XD_MAXDRIVES 2 /* maximum 2 drives */ +#define XD_TIMEOUT 100 /* 1 second timeout */ +#define XD_RETRIES 4 /* maximum 4 retries */ + +#undef DEBUG /* define for debugging output */ + +#ifdef DEBUG + #define DEBUG_STARTUP /* debug driver initialisation */ + #define DEBUG_OVERRIDE /* debug override geometry detection */ + #define DEBUG_READWRITE /* debug each read/write command */ + #define DEBUG_OTHER /* debug misc. interrupt/DMA stuff */ + #define DEBUG_COMMAND /* debug each controller command */ +#endif /* DEBUG */ + +/* this structure defines the XT drives and their types */ +typedef struct { + u_char heads; + u_short cylinders; + u_char sectors; + u_char control; +} XD_INFO; + +#define HDIO_GETGEO 0x0301 /* get drive geometry */ + +/* this structure is returned to the HDIO_GETGEO ioctl */ +typedef struct { + u_char heads; + u_char sectors; + u_short cylinders; + u_long start; +} XD_GEOMETRY; + +/* this structure defines a ROM BIOS signature */ +typedef struct { + u_long offset; + char *string; + void (*init_controller)(u_char *address); + void (*init_drive)(u_char drive); + char *name; +} XD_SIGNATURE; + +u_long xd_init (u_long mem_start,u_long mem_end); +void xd_setup (char *command,int *integers); +static u_char xd_detect (u_char *controller,u_char **address); +static u_char xd_initdrives (void (*init_drive)(u_char drive)); +static void xd_geninit (void); + +static int xd_open (struct inode *inode,struct file *file); +static void do_xd_request (void); +static int xd_ioctl (struct inode *inode,struct file *file,unsigned int cmd,unsigned long arg); +static void xd_release (struct inode *inode,struct file *file); +static int xd_reread_partitions (int dev); +static int xd_readwrite (u_char operation,u_char drive,char *buffer,u_int block,u_int count); +static void xd_recalibrate (u_char drive); + +static void xd_interrupt_handler (int unused); +static u_char xd_setup_dma (u_char opcode,u_char *buffer,u_int count); +static u_char *xd_build (u_char *cmdblk,u_char command,u_char drive,u_char head,u_short cylinder,u_char sector,u_char count,u_char control); +static inline u_char xd_waitport (u_short port,u_char flags,u_char mask,u_long timeout); +static u_int xd_command (u_char *command,u_char mode,u_char *indata,u_char *outdata,u_char *sense,u_long timeout); + +/* card specific setup and geometry gathering code */ +static void xd_dtc_init_controller (u_char *address); +static void xd_dtc_init_drive (u_char drive); +static void xd_wd_init_controller (u_char *address); +static void xd_wd_init_drive (u_char drive); +static void xd_seagate_init_controller (u_char *address); +static void xd_seagate_init_drive (u_char drive); +static void xd_omti_init_controller (u_char *address); +static void xd_omti_init_drive (u_char drive); +static void xd_setparam (u_char command,u_char drive,u_char heads,u_short cylinders,u_short rwrite,u_short wprecomp,u_char ecc); +static void xd_override_init_drive (u_char drive); + +#endif /* _LINUX_XD_H */ diff --git a/include/linux/xia_fs.h b/include/linux/xia_fs.h new file mode 100644 index 000000000..47f3e3f16 --- /dev/null +++ b/include/linux/xia_fs.h @@ -0,0 +1,115 @@ +#ifndef _XIA_FS_H +#define _XIA_FS_H + +/* + * include/linux/xia_fs.h + * + * Copyright (C) Q. Frank Xia, 1993. + * + * Based on Linus' minix_fs.h. + * Copyright (C) Linus Torvalds, 1991, 1992. + */ + +#define _XIAFS_SUPER_MAGIC 0x012FD16D +#define _XIAFS_ROOT_INO 1 +#define _XIAFS_BAD_INO 2 + +#define _XIAFS_NAME_LEN 248 + +#define _XIAFS_INODES_PER_BLOCK ((BLOCK_SIZE)/(sizeof(struct xiafs_inode))) + +struct xiafs_inode { /* 64 bytes */ + mode_t i_mode; + nlink_t i_nlinks; + uid_t i_uid; + gid_t i_gid; + size_t i_size; /* 8 */ + time_t i_ctime; + time_t i_atime; + time_t i_mtime; + daddr_t i_zone[8]; + daddr_t i_ind_zone; + daddr_t i_dind_zone; +}; + +/* + * linux super-block data on disk + */ +struct xiafs_super_block { + u_char s_boot_segment[512]; /* 1st sector reserved for boot */ + u_long s_zone_size; /* 0: the name says it */ + u_long s_nzones; /* 1: volume size, zone aligned */ + u_long s_ninodes; /* 2: # of inodes */ + u_long s_ndatazones; /* 3: # of data zones */ + u_long s_imap_zones; /* 4: # of imap zones */ + u_long s_zmap_zones; /* 5: # of zmap zones */ + u_long s_firstdatazone; /* 6: first data zone */ + u_long s_zone_shift; /* 7: z size = 1KB << z shift */ + u_long s_max_size; /* 8: max size of a single file */ + u_long s_reserved0; /* 9: reserved */ + u_long s_reserved1; /* 10: */ + u_long s_reserved2; /* 11: */ + u_long s_reserved3; /* 12: */ + u_long s_firstkernzone; /* 13: first kernel zone */ + u_long s_kernzones; /* 14: kernel size in zones */ + u_long s_magic; /* 15: magic number for xiafs */ +}; + +struct xiafs_direct { + ino_t d_ino; + u_short d_rec_len; + u_char d_name_len; + char d_name[_XIAFS_NAME_LEN+1]; +}; + +extern int xiafs_lookup(struct inode * dir,const char * name, int len, + struct inode ** result); +extern int xiafs_create(struct inode * dir,const char * name, int len, int mode, + struct inode ** result); +extern int xiafs_mkdir(struct inode * dir, const char * name, int len, int mode); +extern int xiafs_rmdir(struct inode * dir, const char * name, int len); +extern int xiafs_unlink(struct inode * dir, const char * name, int len); +extern int xiafs_symlink(struct inode * inode, const char * name, int len, + const char * symname); +extern int xiafs_link(struct inode * oldinode, struct inode * dir, + const char * name, int len); +extern int xiafs_mknod(struct inode * dir, const char * name, int len, + int mode, int rdev); +extern int xiafs_rename(struct inode * old_dir, const char * old_name, + int old_len, struct inode * new_dir, + const char * new_name, int new_len); +extern struct inode * xiafs_new_inode(struct inode * dir); +extern void xiafs_free_inode(struct inode * inode); +extern unsigned long xiafs_count_free_inodes(struct super_block *sb); +extern int xiafs_new_zone(struct super_block * sb, u_long prev_addr); +extern void xiafs_free_zone(struct super_block * sb, int block); +extern unsigned long xiafs_count_free_zones(struct super_block *sb); + +extern int xiafs_bmap(struct inode *,int); + +extern struct buffer_head * xiafs_getblk(struct inode *, int, int); +extern struct buffer_head * xiafs_bread(struct inode *, int, int); + +extern void xiafs_truncate(struct inode *); +extern void xiafs_put_super(struct super_block *); +extern struct super_block *xiafs_read_super(struct super_block *,void *,int); +extern void xiafs_read_inode(struct inode *); +extern void xiafs_write_inode(struct inode *); +extern void xiafs_put_inode(struct inode *); +extern void xiafs_statfs(struct super_block *, struct statfs *); +extern int xiafs_sync_inode(struct inode *); +extern int xiafs_sync_file(struct inode *, struct file *); + +extern struct inode_operations xiafs_file_inode_operations; +extern struct inode_operations xiafs_dir_inode_operations; +extern struct inode_operations xiafs_symlink_inode_operations; + +#endif /* _XIA_FS_H */ + + + + + + + + diff --git a/include/linux/xia_fs_i.h b/include/linux/xia_fs_i.h new file mode 100644 index 000000000..3000a44a5 --- /dev/null +++ b/include/linux/xia_fs_i.h @@ -0,0 +1,19 @@ +#ifndef _XIA_FS_I_H +#define _XIA_FS_I_H + +/* + * include/linux/xia_fs_i.h + * + * Copyright (C) Q. Frank Xia, 1993. + * + * Based on Linus' minix_fs_i.h. + * Copyright (C) Linus Torvalds, 1991, 1992. + */ + +struct xiafs_inode_info { /* for data zone pointers */ + unsigned long i_zone[8]; + unsigned long i_ind_zone; + unsigned long i_dind_zone; +}; + +#endif /* _XIA_FS_I_H */ diff --git a/include/linux/xia_fs_sb.h b/include/linux/xia_fs_sb.h new file mode 100644 index 000000000..1166ae965 --- /dev/null +++ b/include/linux/xia_fs_sb.h @@ -0,0 +1,36 @@ +#ifndef _XIA_FS_SB_H +#define _XIA_FS_SB_H + +/* + * include/linux/xia_fs_sb.h + * + * Copyright (C) Q. Frank Xia, 1993. + * + * Based on Linus' minix_fs_sb.h. + * Copyright (C) Linus Torvalds, 1991, 1992. + */ + +#define _XIAFS_IMAP_SLOTS 8 +#define _XIAFS_ZMAP_SLOTS 32 + +struct xiafs_sb_info { + u_long s_nzones; + u_long s_ninodes; + u_long s_ndatazones; + u_long s_imap_zones; + u_long s_zmap_zones; + u_long s_firstdatazone; + u_long s_zone_shift; + u_long s_max_size; /* 32 bytes */ + struct buffer_head * s_imap_buf[_XIAFS_IMAP_SLOTS]; /* 32 bytes */ + struct buffer_head * s_zmap_buf[_XIAFS_ZMAP_SLOTS]; /* 128 bytes */ + int s_imap_iznr[_XIAFS_IMAP_SLOTS]; /* 32 bytes */ + int s_zmap_zznr[_XIAFS_ZMAP_SLOTS]; /* 128 bytes */ + u_char s_imap_cached; /* flag for cached imap */ + u_char s_zmap_cached; /* flag for cached imap */ +}; + +#endif /* _XIA_FS_SB_H */ + + + |