diff options
Diffstat (limited to 'include')
281 files changed, 19147 insertions, 4304 deletions
diff --git a/include/asm-alpha/,fcntl.h, b/include/asm-alpha/,fcntl.h, new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/include/asm-alpha/,fcntl.h, diff --git a/include/asm-alpha/bitops.h b/include/asm-alpha/bitops.h index 987a026e3..420ffa02c 100644 --- a/include/asm-alpha/bitops.h +++ b/include/asm-alpha/bitops.h @@ -32,7 +32,7 @@ extern __inline__ unsigned long set_bit(unsigned long nr, void * addr) "=&r" (oldbit) :"r" (1UL << (nr & 63)), "m" (((unsigned long *) addr)[nr >> 6])); - return oldbit; + return oldbit != 0; } extern __inline__ unsigned long clear_bit(unsigned long nr, void * addr) @@ -54,7 +54,7 @@ extern __inline__ unsigned long clear_bit(unsigned long nr, void * addr) "=&r" (oldbit) :"r" (1UL << (nr & 63)), "m" (((unsigned long *) addr)[nr >> 6])); - return oldbit; + return oldbit != 0; } extern __inline__ unsigned long change_bit(unsigned long nr, void * addr) @@ -74,7 +74,7 @@ extern __inline__ unsigned long change_bit(unsigned long nr, void * addr) "=&r" (oldbit) :"r" (1UL << (nr & 63)), "m" (((unsigned long *) addr)[nr >> 6])); - return oldbit; + return oldbit != 0; } extern __inline__ unsigned long test_bit(int nr, void * addr) diff --git a/include/asm-alpha/bugs.h b/include/asm-alpha/bugs.h new file mode 100644 index 000000000..78030d1c7 --- /dev/null +++ b/include/asm-alpha/bugs.h @@ -0,0 +1,20 @@ +/* + * include/asm-alpha/bugs.h + * + * Copyright (C) 1994 Linus Torvalds + */ + +/* + * This is included by init/main.c to check for architecture-dependent bugs. + * + * Needs: + * void check_bugs(void); + */ + +/* + * I don't know of any alpha bugs yet.. Nice chip + */ + +static void check_bugs(void) +{ +} diff --git a/include/asm-alpha/byteorder.h b/include/asm-alpha/byteorder.h new file mode 100644 index 000000000..02902df90 --- /dev/null +++ b/include/asm-alpha/byteorder.h @@ -0,0 +1,84 @@ +#ifndef _ALPHA_BYTEORDER_H +#define _ALPHA_BYTEORDER_H + +#undef ntohl +#undef ntohs +#undef htonl +#undef htons + +#ifndef LITTLE_ENDIAN +#define LITTLE_ENDIAN +#endif + +#ifndef LITTLE_ENDIAN_BITFIELD +#define LITTLE_ENDIAN_BITFIELD +#endif + +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); + +extern unsigned long int __ntohl(unsigned long int); +extern unsigned short int __ntohs(unsigned short int); +extern unsigned long int __constant_ntohl(unsigned long int); +extern unsigned short int __constant_ntohs(unsigned short int); + +/* + * The constant and non-constant versions here are the same. + * Maybe I'll come up with an alpha-optimized routine for the + * non-constant ones (the constant ones don't need it: gcc + * will optimize it to the correct constant) + */ + +extern __inline__ unsigned long int +__ntohl(unsigned long int x) +{ + return (((x & 0x000000ffU) << 24) | + ((x & 0x0000ff00U) << 8) | + ((x & 0x00ff0000U) >> 8) | + ((x & 0xff000000U) >> 24)); +} + +#define __constant_ntohl(x) \ +((unsigned int)((((unsigned int)(x) & 0x000000ffU) << 24) | \ + (((unsigned int)(x) & 0x0000ff00U) << 8) | \ + (((unsigned int)(x) & 0x00ff0000U) >> 8) | \ + (((unsigned int)(x) & 0xff000000U) >> 24))) + +extern __inline__ unsigned short int +__ntohs(unsigned short int x) +{ + return (((x & 0x00ff) << 8) | + ((x & 0xff00) >> 8)); +} + +#define __constant_ntohs(x) \ +((unsigned short int)((((unsigned short int)(x) & 0x00ff) << 8) | \ + (((unsigned short int)(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 diff --git a/include/asm-alpha/console.h b/include/asm-alpha/console.h new file mode 100644 index 000000000..e88171fac --- /dev/null +++ b/include/asm-alpha/console.h @@ -0,0 +1,47 @@ +#ifndef __AXP_CONSOLE_H +#define __AXP_CONSOLE_H + +/* + * Console callback routine numbers + */ +#define CCB_GETC 0x01 +#define CCB_PUTS 0x02 +#define CCB_RESET_TERM 0x03 +#define CCB_SET_TERM_INT 0x04 +#define CCB_SET_TERM_CTL 0x05 +#define CCB_PROCESS_KEYCODE 0x06 + +#define CCB_OPEN 0x10 +#define CCB_CLOSE 0x11 +#define CCB_IOCTL 0x12 +#define CCB_READ 0x13 +#define CCB_WRITE 0x14 + +#define CCB_SET_ENV 0x20 +#define CCB_RESET_ENV 0x21 +#define CCB_GET_ENV 0x22 +#define CCB_SAVE_ENV 0x23 + +/* + * Environment variable numbers + */ +#define ENV_AUTO_ACTION 0x01 +#define ENV_BOOT_DEV 0x02 +#define ENV_BOOTDEF_DEV 0x03 +#define ENV_BOOTED_DEV 0x04 +#define ENV_BOOT_FILE 0x05 +#define ENV_BOOTED_FILE 0x06 +#define ENV_BOOT_OSFLAGS 0x07 +#define ENV_BOOTED_OSFLAGS 0x08 +#define ENV_BOOT_RESET 0x09 +#define ENV_DUMP_DEV 0x0A +#define ENV_ENABLE_AUDIT 0x0B +#define ENV_LICENCE 0x0C +#define ENV_CHAR_SET 0x0D +#define ENV_LANGUAGE 0x0E +#define ENV_TTY_DEV 0x0F + +extern unsigned long dispatch(unsigned long code, ...); +#define puts(x,l) dispatch(CCB_PUTS,0,x,l) + +#endif diff --git a/include/asm-alpha/delay.h b/include/asm-alpha/delay.h index 87e69f657..df73028c9 100644 --- a/include/asm-alpha/delay.h +++ b/include/asm-alpha/delay.h @@ -35,4 +35,13 @@ extern __inline__ void udelay(unsigned long usecs) __delay(usecs); } +/* + * 64-bit integers means we don't have to worry about overflow as + * on some other architectures.. + */ +extern __inline__ unsigned long muldiv(unsigned long a, unsigned long b, unsigned long c) +{ + return (a*b)/c; +} + #endif /* defined(__ALPHA_DELAY_H) */ diff --git a/include/asm-alpha/dirent.h b/include/asm-alpha/dirent.h new file mode 100644 index 000000000..07fe9e9e0 --- /dev/null +++ b/include/asm-alpha/dirent.h @@ -0,0 +1,11 @@ +#ifndef _ALPHA_DIRENT_H +#define _ALPHA_DIRENT_H + +struct dirent { + ino_t d_ino; + unsigned short d_reclen; + unsigned short d_namlen; + char d_name[256]; +}; + +#endif diff --git a/include/asm-alpha/dma.h b/include/asm-alpha/dma.h index caf437f30..4b327266d 100644 --- a/include/asm-alpha/dma.h +++ b/include/asm-alpha/dma.h @@ -1,11 +1,11 @@ /* * include/asm-alpha/dma.h * - * This is essentially the same as the i386 DMA stuff, as - * the AlphaPC uses normal EISA dma (but the DMA controller - * is not on the EISA bus, but on the local VL82c106 bus). - * - * These DMA-functions don't know about EISA DMA yet.. + * This is essentially the same as the i386 DMA stuff, as the AlphaPCs + * use ISA-compatible dma. The only extension is support for high-page + * registers that allow to set the top 8 bits of a 32-bit DMA address. + * This register should be written last when setting up a DMA address + * as this will also enable DMA across 64 KB boundaries. */ /* $Id: dma.h,v 1.7 1992/12/14 00:29:34 root Exp root $ @@ -20,8 +20,8 @@ #include <asm/io.h> /* need byte IO */ -#define dma_outb outb_local -#define dma_inb inb_local +#define dma_outb outb +#define dma_inb inb /* * NOTES about DMA transfers: @@ -73,6 +73,9 @@ #define MAX_DMA_CHANNELS 8 +/* The maximum address that we can perform a DMA transfer to on this platform */ +#define MAX_DMA_ADDRESS 0x1000000 + /* 8237 DMA controllers */ #define IO_DMA1_BASE 0x00 /* 8 bit slave DMA, channels 0..3 */ #define IO_DMA2_BASE 0xC0 /* 16 bit master DMA, ch 4(=slave input)..7 */ @@ -88,6 +91,7 @@ #define DMA1_RESET_REG 0x0D /* Master Clear (w) */ #define DMA1_CLR_MASK_REG 0x0E /* Clear Mask */ #define DMA1_MASK_ALL_REG 0x0F /* all-channels mask (w) */ +#define DMA1_EXT_MODE_REG (0x400 | DMA1_MODE_REG) #define DMA2_CMD_REG 0xD0 /* command register (w) */ #define DMA2_STAT_REG 0xD0 /* status register (r) */ @@ -99,6 +103,7 @@ #define DMA2_RESET_REG 0xDA /* Master Clear (w) */ #define DMA2_CLR_MASK_REG 0xDC /* Clear Mask */ #define DMA2_MASK_ALL_REG 0xDE /* all-channels mask (w) */ +#define DMA2_EXT_MODE_REG (0x400 | DMA2_MODE_REG) #define DMA_ADDR_0 0x00 /* DMA address registers */ #define DMA_ADDR_1 0x02 @@ -126,6 +131,15 @@ #define DMA_PAGE_6 0x89 #define DMA_PAGE_7 0x8A +#define DMA_HIPAGE_0 (0x400 | DMA_PAGE_0) +#define DMA_HIPAGE_1 (0x400 | DMA_PAGE_1) +#define DMA_HIPAGE_2 (0x400 | DMA_PAGE_2) +#define DMA_HIPAGE_3 (0x400 | DMA_PAGE_3) +#define DMA_HIPAGE_4 (0x400 | DMA_PAGE_4) +#define DMA_HIPAGE_5 (0x400 | DMA_PAGE_5) +#define DMA_HIPAGE_6 (0x400 | DMA_PAGE_6) +#define DMA_HIPAGE_7 (0x400 | DMA_PAGE_7) + #define DMA_MODE_READ 0x44 /* I/O to memory, no autoinit, increment, single mode */ #define DMA_MODE_WRITE 0x48 /* memory to I/O, no autoinit, increment, single mode */ #define DMA_MODE_CASCADE 0xC0 /* pass thru DREQ->HRQ, DACK<-HLDA only */ @@ -171,34 +185,49 @@ static __inline__ void set_dma_mode(unsigned int dmanr, char mode) dma_outb(mode | (dmanr&3), DMA2_MODE_REG); } +/* set extended mode for a specific DMA channel */ +static __inline__ void set_dma_ext_mode(unsigned int dmanr, char ext_mode) +{ + if (dmanr<=3) + dma_outb(ext_mode | dmanr, DMA1_EXT_MODE_REG); + else + dma_outb(ext_mode | (dmanr&3), DMA2_EXT_MODE_REG); +} + /* Set only the page register bits of the transfer address. * This is used for successive transfers when we know the contents of - * the lower 16 bits of the DMA current address register, but a 64k boundary - * may have been crossed. + * the lower 16 bits of the DMA current address register. */ -static __inline__ void set_dma_page(unsigned int dmanr, char pagenr) +static __inline__ void set_dma_page(unsigned int dmanr, unsigned int pagenr) { switch(dmanr) { case 0: dma_outb(pagenr, DMA_PAGE_0); + dma_outb((pagenr >> 8), DMA_HIPAGE_0); break; case 1: dma_outb(pagenr, DMA_PAGE_1); + dma_outb((pagenr >> 8), DMA_HIPAGE_1); break; case 2: dma_outb(pagenr, DMA_PAGE_2); + dma_outb((pagenr >> 8), DMA_HIPAGE_2); break; case 3: dma_outb(pagenr, DMA_PAGE_3); + dma_outb((pagenr >> 8), DMA_HIPAGE_3); break; case 5: dma_outb(pagenr & 0xfe, DMA_PAGE_5); + dma_outb((pagenr >> 8), DMA_HIPAGE_5); break; case 6: dma_outb(pagenr & 0xfe, DMA_PAGE_6); + dma_outb((pagenr >> 8), DMA_HIPAGE_6); break; case 7: dma_outb(pagenr & 0xfe, DMA_PAGE_7); + dma_outb((pagenr >> 8), DMA_HIPAGE_7); break; } } @@ -209,7 +238,6 @@ static __inline__ void set_dma_page(unsigned int dmanr, char pagenr) */ static __inline__ void set_dma_addr(unsigned int dmanr, unsigned int a) { - set_dma_page(dmanr, a>>16); if (dmanr <= 3) { dma_outb( a & 0xff, ((dmanr&3)<<1) + IO_DMA1_BASE ); dma_outb( (a>>8) & 0xff, ((dmanr&3)<<1) + IO_DMA1_BASE ); @@ -217,6 +245,7 @@ static __inline__ void set_dma_addr(unsigned int dmanr, unsigned int a) dma_outb( (a>>1) & 0xff, ((dmanr&3)<<2) + IO_DMA2_BASE ); dma_outb( (a>>9) & 0xff, ((dmanr&3)<<2) + IO_DMA2_BASE ); } + set_dma_page(dmanr, a>>16); /* set hipage last to enable 32-bit mode */ } @@ -265,7 +294,7 @@ static __inline__ int get_dma_residue(unsigned int dmanr) /* These are in kernel/dma.c: */ -extern int request_dma(unsigned int dmanr, char * deviceID); /* reserve a DMA channel */ +extern int request_dma(unsigned int dmanr, char * device_id); /* reserve a DMA channel */ extern void free_dma(unsigned int dmanr); /* release it again */ diff --git a/include/asm-alpha/errno.h b/include/asm-alpha/errno.h new file mode 100644 index 000000000..45c1ea0d5 --- /dev/null +++ b/include/asm-alpha/errno.h @@ -0,0 +1,134 @@ +#ifndef _ALPHA_ERRNO_H +#define _ALPHA_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 EDEADLK 11 /* Resource deadlock would occur */ +#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 EAGAIN 35 /* Try again */ +#define EWOULDBLOCK EAGAIN /* Operation would block */ +#define EINPROGRESS 36 /* Operation now in progress */ +#define EALREADY 37 /* Operation already in progress */ +#define ENOTSOCK 38 /* Socket operation on non-socket */ +#define EDESTADDRREQ 39 /* Destination address required */ +#define EMSGSIZE 40 /* Message too long */ +#define EPROTOTYPE 41 /* Protocol wrong type for socket */ +#define ENOPROTOOPT 42 /* Protocol not available */ +#define EPROTONOSUPPORT 43 /* Protocol not supported */ +#define ESOCKTNOSUPPORT 44 /* Socket type not supported */ +#define EOPNOTSUPP 45 /* Operation not supported on transport endpoint */ +#define EPFNOSUPPORT 46 /* Protocol family not supported */ +#define EAFNOSUPPORT 47 /* Address family not supported by protocol */ +#define EADDRINUSE 48 /* Address already in use */ +#define EADDRNOTAVAIL 49 /* Cannot assign requested address */ +#define ENETDOWN 50 /* Network is down */ +#define ENETUNREACH 51 /* Network is unreachable */ +#define ENETRESET 52 /* Network dropped connection because of reset */ +#define ECONNABORTED 53 /* Software caused connection abort */ +#define ECONNRESET 54 /* Connection reset by peer */ +#define ENOBUFS 55 /* No buffer space available */ +#define EISCONN 56 /* Transport endpoint is already connected */ +#define ENOTCONN 57 /* Transport endpoint is not connected */ +#define ESHUTDOWN 58 /* Cannot send after transport endpoint shutdown */ +#define ETOOMANYREFS 59 /* Too many references: cannot splice */ +#define ETIMEDOUT 60 /* Connection timed out */ +#define ECONNREFUSED 61 /* Connection refused */ +#define ELOOP 62 /* Too many symbolic links encountered */ +#define ENAMETOOLONG 63 /* File name too long */ +#define EHOSTDOWN 64 /* Host is down */ +#define EHOSTUNREACH 65 /* No route to host */ +#define ENOTEMPTY 66 /* Directory not empty */ + +#define EUSERS 68 /* Too many users */ +#define EDQUOT 69 /* Quota exceeded */ +#define ESTALE 70 /* Stale NFS file handle */ +#define EREMOTE 71 /* Object is remote */ + +#define ENOLCK 77 /* No record locks available */ +#define ENOSYS 78 /* Function not implemented */ + +#define ENOMSG 80 /* No message of desired type */ +#define EIDRM 81 /* Identifier removed */ +#define ENOSR 82 /* Out of streams resources */ +#define ETIME 83 /* Timer expired */ +#define EBADMSG 84 /* Not a data message */ +#define EPROTO 85 /* Protocol error */ +#define ENODATA 86 /* No data available */ +#define ENOSTR 87 /* Device not a stream */ + +#define ENOPKG 92 /* Package not installed */ + +#define EILSEQ 116 /* Illegal byte sequence */ + +/* The following are just random noise.. */ +#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 ENONET 64 /* Machine is not on the network */ +#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 EMULTIHOP 72 /* Multihop attempted */ +#define EDOTDOT 73 /* RFS specific error */ +#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 ERESTART 85 /* Interrupted system call should be restarted */ +#define ESTRPIPE 86 /* Streams pipe error */ +#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 */ + +#endif diff --git a/include/asm-alpha/fcntl.h b/include/asm-alpha/fcntl.h new file mode 100644 index 000000000..e4cd88361 --- /dev/null +++ b/include/asm-alpha/fcntl.h @@ -0,0 +1,52 @@ +#ifndef _ALPHA_FCNTL_H +#define _ALPHA_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 01000 /* not fcntl */ +#define O_TRUNC 02000 /* not fcntl */ +#define O_EXCL 04000 /* not fcntl */ +#define O_NOCTTY 010000 /* not fcntl */ + +#define O_NONBLOCK 00004 +#define O_APPEND 00010 +#define O_NDELAY O_NONBLOCK +#define O_SYNC 040000 +#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 7 +#define F_SETLK 8 +#define F_SETLKW 9 + +#define F_SETOWN 5 /* for sockets. */ +#define F_GETOWN 6 /* for sockets. */ + +/* for F_[GET|SET]FL */ +#define FD_CLOEXEC 1 /* actually anything with low bit set goes */ + +#define F_RDLCK 1 +#define F_WRLCK 2 +#define F_UNLCK 8 + +/* For bsd flock () */ +#define F_EXLCK 16 /* or 3 */ +#define F_SHLCK 32 /* 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/asm-alpha/hwrpb.h b/include/asm-alpha/hwrpb.h new file mode 100644 index 000000000..35204d7c2 --- /dev/null +++ b/include/asm-alpha/hwrpb.h @@ -0,0 +1,158 @@ +#ifndef _HWRPB_H +#define _HWRPB_H + +#define INIT_HWRPB ((struct hwrpb_struct *) 0x10000000) + +/* + * DEC processor types for Alpha systems. Found in HWRPB. + * These values are architected. + */ + +#define EV3_CPU 1 /* EV3 */ +#define EV4_CPU 2 /* EV4 (21064) */ +#define LCA4_CPU 4 /* LCA4 (21066/21068) */ +#define EV5_CPU 5 /* EV5 (21164) */ +#define EV45_CPU 6 /* EV4.5 (21064/xxx) */ + +/* + * DEC system types for Alpha systems. Found in HWRPB. + * These values are architected. + */ + +#define ST_ADU 1 /* Alpha ADU systype */ +#define ST_DEC_4000 2 /* Cobra systype */ +#define ST_DEC_7000 3 /* Ruby systype */ +#define ST_DEC_3000_500 4 /* Flamingo systype */ +#define ST_DEC_2000_300 6 /* Jensen systype */ +#define ST_DEC_3000_300 7 /* Pelican systype */ +#define ST_DEC_2100_A500 9 /* Sable systype */ +#define ST_DEC_AXPVME_64 10 /* AXPvme system type */ +#define ST_DEC_AXPPCI_33 11 /* NoName system type */ +#define ST_DEC_TLASER 12 /* Turbolaser systype */ +#define ST_DEC_2100_A50 13 /* Avanti systype */ +#define ST_DEC_MUSTANG 14 /* Mustang systype */ +#define ST_DEC_ALCOR 15 /* Alcor systype */ +#define ST_DEC_1000 17 /* Mikasa systype */ +#define ST_DEC_EB66 19 /* EB66 systype */ +#define ST_DEC_EB64P 20 /* EB64+ systype */ + +struct pcb_struct { + unsigned long ksp; + unsigned long usp; + unsigned long ptbr; + unsigned int pcc; + unsigned int asn; + unsigned long unique; + unsigned long flags; + unsigned long res1, res2; +}; + +struct percpu_struct { + unsigned long hwpcb[16]; + unsigned long flags; + unsigned long pal_mem_size; + unsigned long pal_scratch_size; + unsigned long pal_mem_pa; + unsigned long pal_scratch_pa; + unsigned long pal_revision; + unsigned long type; + unsigned long variation; + unsigned long revision; + unsigned long serial_no[2]; + unsigned long logout_area_pa; + unsigned long logout_area_len; + unsigned long halt_PCBB; + unsigned long halt_PC; + unsigned long halt_PS; + unsigned long halt_arg; + unsigned long halt_ra; + unsigned long halt_pv; + unsigned long halt_reason; + unsigned long res; + unsigned long ipc_buffer[21]; + unsigned long palcode_avail[16]; + unsigned long compatibility; +}; + +struct procdesc_struct { + unsigned long weird_vms_stuff; + unsigned long address; +}; + +struct vf_map_struct { + unsigned long va; + unsigned long pa; + unsigned long count; +}; + +struct crb_struct { + struct procdesc_struct * dispatch_va; + struct procdesc_struct * dispatch_pa; + struct procdesc_struct * fixup_va; + struct procdesc_struct * fixup_pa; + /* virtual->physical map */ + unsigned long map_entries; + unsigned long map_pages; + struct vf_map_struct map[1]; +}; + +struct memclust_struct { + unsigned long start_pfn; + unsigned long numpages; + unsigned long numtested; + unsigned long bitmap_va; + unsigned long bitmap_pa; + unsigned long bitmap_chksum; + unsigned long usage; +}; + +struct memdesc_struct { + unsigned long chksum; + unsigned long optional_pa; + unsigned long numclusters; + struct memclust_struct cluster[0]; +}; + +struct hwrpb_struct { + unsigned long phys_addr; /* check: physical address of the hwrpb */ + unsigned long id; /* check: "HWRPB\0\0\0" */ + unsigned long revision; + unsigned long size; /* size of hwrpb */ + unsigned long cpuid; + unsigned long pagesize; /* 8192, I hope */ + unsigned long pa_bits; /* number of physical address bits */ + unsigned long max_asn; + unsigned char ssn[16]; /* system serial number: big bother is watching */ + unsigned long sys_type; + unsigned long sys_variation; + unsigned long sys_revision; + unsigned long intr_freq; /* interval clock frequency * 4096 */ + unsigned long cycle_freq; /* cycle counter frequency */ + unsigned long vptb; /* Virtual Page Table Base address */ + unsigned long res1; + unsigned long tbhb_offset; /* Translation Buffer Hint Block */ + unsigned long nr_processors; + unsigned long processor_size; + unsigned long processor_offset; + unsigned long ctb_nr; + unsigned long ctb_size; /* console terminal block size */ + unsigned long ctbt_offset; /* console terminal block table offset */ + unsigned long crb_offset; /* console callback routine block */ + unsigned long mddt_offset; /* memory data descriptor table */ + unsigned long cdb_offset; /* configuration data block (or NULL) */ + unsigned long frut_offset; /* FRU table (or NULL) */ + void (*save_terminal)(unsigned long); + unsigned long save_terminal_data; + void (*restore_terminal)(unsigned long); + unsigned long restore_terminal_data; + void (*CPU_restart)(unsigned long); + unsigned long CPU_restart_data; + unsigned long res2; + unsigned long res3; + unsigned long chksum; + unsigned long rxrdy; + unsigned long txrdy; + unsigned long dsrdbt_offset; /* "Dynamic System Recognition Data Block Table" Whee */ +}; + +#endif diff --git a/include/asm-alpha/io.h b/include/asm-alpha/io.h index 969fc96d8..e567c750b 100644 --- a/include/asm-alpha/io.h +++ b/include/asm-alpha/io.h @@ -1,41 +1,38 @@ #ifndef __ALPHA_IO_H #define __ALPHA_IO_H -/* - * Defines for the AlphaPC EISA IO and memory address space. - */ +#include <linux/config.h> -#ifndef mb -#define mb() __asm__ __volatile__("mb": : :"memory") -#endif +#include <asm/system.h> /* - * NOTE! Currently it never uses the HAE register, so these work only - * for the low 25 bits of EISA addressing. That covers all of the IO - * address space (16 bits), and most of the "normal" EISA memory space. - * I'll fix it eventually, but I'll need to come up with a clean way - * to handle races with interrupt services wanting to change HAE... + * The hae (hardware address extension) register is used to + * access high IO addresses. To avoid doing an external cycle + * every time we need to set the hae, we have a hae cache in + * memory. The kernel entry code makes sure that the hae is + * preserved across interrupts, so it is safe to set the hae + * once and then depend on it staying the same in kernel code. */ +extern struct hae { + unsigned long cache; + unsigned long *reg; +} hae; /* - * NOTE 2! The memory operations do not set any memory barriers, as it's - * not needed for cases like a frame buffer that is essentially memory-like. - * You need to do them by hand if the operations depend on ordering. - * - * Similarly, the port IO operations do a "mb" only after a write operation: - * if an mb is needed before (as in the case of doing memory mapped IO - * first, and then a port IO operation to the same device), it needs to be - * done by hand. - * - * After the above has bitten me 100 times, I'll give up and just do the - * mb all the time, but right now I'm hoping this will work out. Avoiding - * mb's may potentially be a noticeable speed improvement, but I can't - * honestly say I've tested it. - * - * Handling interrupts that need to do mb's to synchronize to non-interrupts - * is another fun race area. Don't do it (because if you do, I'll have to - * do *everything* with interrupts disabled, ugh). + * We try to avoid hae updates (thus the cache), but when we + * do need to update the hae, we need to do it atomically, so + * that any interrupts wouldn't get confused with the hae + * register not being up-to-date with respect to the hardware + * value. */ +extern inline void set_hae(unsigned long new_hae) +{ + unsigned long ipl = swpipl(7); + hae.cache = new_hae; + *hae.reg = new_hae; + mb(); + setipl(ipl); +} /* * Virtual -> physical identity mapping starts at this offset @@ -43,137 +40,27 @@ #define IDENT_ADDR (0xfffffc0000000000UL) /* - * EISA Interrupt Acknowledge address - */ -#define EISA_INTA (IDENT_ADDR + 0x100000000UL) - -/* - * FEPROM addresses - */ -#define EISA_FEPROM0 (IDENT_ADDR + 0x180000000UL) -#define EISA_FEPROM1 (IDENT_ADDR + 0x1A0000000UL) - -/* - * VL82C106 base address - */ -#define EISA_VL82C106 (IDENT_ADDR + 0x1C0000000UL) - -/* - * EISA "Host Address Extension" address (bits 25-31 of the EISA address) - */ -#define EISA_HAE (IDENT_ADDR + 0x1D0000000UL) - -/* - * "SYSCTL" register address + * Change virtual addresses to physical addresses and vv. */ -#define EISA_SYSCTL (IDENT_ADDR + 0x1E0000000UL) - -/* - * "spare" register address - */ -#define EISA_SPARE (IDENT_ADDR + 0x1F0000000UL) - -/* - * EISA memory address offset - */ -#define EISA_MEM (IDENT_ADDR + 0x200000000UL) - -/* - * EISA IO address offset - */ -#define EISA_IO (IDENT_ADDR + 0x300000000UL) - -/* - * IO functions - * - * The "local" functions are those that don't go out to the EISA bus, - * but instead act on the VL82C106 chip directly.. This is mainly the - * keyboard, RTC, printer and first two serial lines.. - */ -extern inline unsigned long inb_local(unsigned long addr) -{ - long result = *(volatile int *) ((addr << 9) + EISA_VL82C106); - return 0xffUL & result; -} - -extern inline void outb_local(unsigned char b, unsigned long addr) -{ - *(volatile unsigned int *) ((addr << 9) + EISA_VL82C106) = b; - mb(); -} - -extern inline unsigned long inb(unsigned long addr) -{ - long result = *(volatile int *) ((addr << 7) + EISA_IO + 0x00); - result >>= (addr & 3) * 8; - return 0xffUL & result; -} - -extern inline unsigned long inw(unsigned long addr) -{ - long result = *(volatile int *) ((addr << 7) + EISA_IO + 0x20); - result >>= (addr & 3) * 8; - return 0xffffUL & result; -} - -extern inline unsigned long inl(unsigned long addr) -{ - return *(volatile unsigned int *) ((addr << 7) + EISA_IO + 0x60); -} - -extern inline void outb(unsigned char b, unsigned long addr) +extern inline unsigned long virt_to_phys(void * address) { - *(volatile unsigned int *) ((addr << 7) + EISA_IO + 0x00) = b * 0x01010101; - mb(); + return 0xffffffffUL & (unsigned long) address; } -extern inline void outw(unsigned short b, unsigned long addr) +extern inline void * phys_to_virt(unsigned long address) { - *(volatile unsigned int *) ((addr << 7) + EISA_IO + 0x20) = b * 0x00010001; - mb(); -} - -extern inline void outl(unsigned int b, unsigned long addr) -{ - *(volatile unsigned int *) ((addr << 7) + EISA_IO + 0x60) = b; - mb(); + return (void *) (address + IDENT_ADDR); } /* - * Memory functions + * There are different version of the alpha motherboards: the + * "interesting" (read: slightly braindead) Jensen type hardware + * and the PCI version */ -extern inline unsigned long readb(unsigned long addr) -{ - long result = *(volatile int *) ((addr << 7) + EISA_MEM + 0x00); - result >>= (addr & 3) * 8; - return 0xffUL & result; -} - -extern inline unsigned long readw(unsigned long addr) -{ - long result = *(volatile int *) ((addr << 7) + EISA_MEM + 0x20); - result >>= (addr & 3) * 8; - return 0xffffUL & result; -} - -extern inline unsigned long readl(unsigned long addr) -{ - return *(volatile unsigned int *) ((addr << 7) + EISA_MEM + 0x60); -} - -extern inline void writeb(unsigned short b, unsigned long addr) -{ - *(volatile unsigned int *) ((addr << 7) + EISA_MEM + 0x00) = b * 0x01010101; -} - -extern inline void writew(unsigned short b, unsigned long addr) -{ - *(volatile unsigned int *) ((addr << 7) + EISA_MEM + 0x20) = b * 0x00010001; -} - -extern inline void writel(unsigned int b, unsigned long addr) -{ - *(volatile unsigned int *) ((addr << 7) + EISA_MEM + 0x60) = b; -} +#ifdef CONFIG_PCI +#include <asm/lca.h> /* get chip-specific definitions */ +#else +#include <asm/jensen.h> +#endif #endif diff --git a/include/asm-alpha/ioctl.h b/include/asm-alpha/ioctl.h new file mode 100644 index 000000000..a981caadf --- /dev/null +++ b/include/asm-alpha/ioctl.h @@ -0,0 +1,57 @@ +#ifndef _ALPHA_IOCTL_H +#define _ALPHA_IOCTL_H + +/* + * The original linux ioctl numbering scheme was just a general + * "anything goes" setup, where more or less random numbers were + * assigned. Sorry, I was clueless when I started out on this. + * + * On the alpha, we'll try to clean it up a bit, using a more sane + * ioctl numbering, and also trying to be compatible with OSF/1 in + * the process. I'd like to clean it up for the i386 as well, but + * it's so painful recognizing both the new and the old numbers.. + */ + +#define _IOC_NRBITS 8 +#define _IOC_TYPEBITS 8 +#define _IOC_SIZEBITS 13 +#define _IOC_DIRBITS 3 + +#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1) +#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1) +#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1) +#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1) + +#define _IOC_NRSHIFT 0 +#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS) +#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS) +#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS) + +/* + * Direction bits _IOC_NONE could be 0, but OSF/1 gives it a bit. + * And this turns out useful to catch old ioctl numbers in header + * files for us. + */ +#define _IOC_NONE 1U +#define _IOC_READ 2U +#define _IOC_WRITE 4U + +#define _IOC(dir,type,nr,size) \ + (((dir) << _IOC_DIRSHIFT) | \ + ((type) << _IOC_TYPESHIFT) | \ + ((nr) << _IOC_NRSHIFT) | \ + ((size) << _IOC_SIZESHIFT)) + +/* used to create numbers */ +#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0) +#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size)) +#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size)) +#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size)) + +/* used to decode them.. */ +#define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK) +#define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK) +#define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK) +#define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK) + +#endif diff --git a/include/asm-alpha/ipsum.h b/include/asm-alpha/ipsum.h new file mode 100644 index 000000000..8146cb734 --- /dev/null +++ b/include/asm-alpha/ipsum.h @@ -0,0 +1,45 @@ +#ifndef __ASM_IPSUM_H +#define __ASM_IPSUM_H + +/* + * This routine computes a UDP checksum. + */ +extern inline unsigned short udp_check(struct udphdr *uh, int len, u32 saddr, u32 daddr) +{ + /* uhh.. eventually */ + return 0; +} + +/* + * This routine computes a TCP checksum. + */ +extern inline unsigned short tcp_check(struct tcphdr *th, int len, u32 saddr, u32 daddr) +{ + /* uhh.. eventually */ + return 0; +} + + +/* + * This routine does all the checksum computations that don't + * require anything special (like copying or special headers). + */ + +extern inline unsigned short ip_compute_csum(unsigned char * buff, int len) +{ + /* uhh.. eventually */ + return 0; +} + +/* + * This is a version of ip_compute_csum() optimized for IP headers, which + * always checksum on 4 octet boundaries. + */ + +static inline unsigned short ip_fast_csum(unsigned char * buff, int wlen) +{ + /* uhh.. eventually */ + return 0; +} + +#endif diff --git a/include/asm-alpha/jensen.h b/include/asm-alpha/jensen.h new file mode 100644 index 000000000..952d56375 --- /dev/null +++ b/include/asm-alpha/jensen.h @@ -0,0 +1,290 @@ +#ifndef __ALPHA_JENSEN_H +#define __ALPHA_JENSEN_H + +/* + * Defines for the AlphaPC EISA IO and memory address space. + */ + +/* + * NOTE! The memory operations do not set any memory barriers, as it's + * not needed for cases like a frame buffer that is essentially memory-like. + * You need to do them by hand if the operations depend on ordering. + * + * Similarly, the port IO operations do a "mb" only after a write operation: + * if an mb is needed before (as in the case of doing memory mapped IO + * first, and then a port IO operation to the same device), it needs to be + * done by hand. + * + * After the above has bitten me 100 times, I'll give up and just do the + * mb all the time, but right now I'm hoping this will work out. Avoiding + * mb's may potentially be a noticeable speed improvement, but I can't + * honestly say I've tested it. + * + * Handling interrupts that need to do mb's to synchronize to non-interrupts + * is another fun race area. Don't do it (because if you do, I'll have to + * do *everything* with interrupts disabled, ugh). + */ + +/* + * EISA Interrupt Acknowledge address + */ +#define EISA_INTA (IDENT_ADDR + 0x100000000UL) + +/* + * FEPROM addresses + */ +#define EISA_FEPROM0 (IDENT_ADDR + 0x180000000UL) +#define EISA_FEPROM1 (IDENT_ADDR + 0x1A0000000UL) + +/* + * VL82C106 base address + */ +#define EISA_VL82C106 (IDENT_ADDR + 0x1C0000000UL) + +/* + * EISA "Host Address Extension" address (bits 25-31 of the EISA address) + */ +#define EISA_HAE (IDENT_ADDR + 0x1D0000000UL) + +/* + * "SYSCTL" register address + */ +#define EISA_SYSCTL (IDENT_ADDR + 0x1E0000000UL) + +/* + * "spare" register address + */ +#define EISA_SPARE (IDENT_ADDR + 0x1F0000000UL) + +/* + * EISA memory address offset + */ +#define EISA_MEM (IDENT_ADDR + 0x200000000UL) + +/* + * EISA IO address offset + */ +#define EISA_IO (IDENT_ADDR + 0x300000000UL) + +/* + * Change virtual addresses to bus addresses and vv. + * + * NOTE! On the Jensen, the physical address is the same + * as the bus address, but this is not necessarily true on + * other alpha hardware. + */ +#define virt_to_bus virt_to_phys +#define bus_to_virt phys_to_virt + +#define HAE_ADDRESS EISA_HAE + +/* + * Handle the "host address register". This needs to be set + * to the high 7 bits of the EISA address. This is also needed + * for EISA IO addresses, which are only 16 bits wide (the + * hae needs to be set to 0). + * + * HAE isn't needed for the local IO operations, though. + */ +#define __HAE_MASK 0x1ffffff +extern inline void __set_hae(unsigned long addr) +{ + /* hae on the Jensen is bits 31:25 shifted right */ + addr >>= 25; + if (addr != hae.cache) + set_hae(addr); +} + +/* + * IO functions + * + * The "local" functions are those that don't go out to the EISA bus, + * but instead act on the VL82C106 chip directly.. This is mainly the + * keyboard, RTC, printer and first two serial lines.. + * + * The local stuff makes for some complications, but it seems to be + * gone in the PCI version. I hope I can get DEC suckered^H^H^H^H^H^H^H^H + * convinced that I need one of the newer machines. + */ +extern inline unsigned int __local_inb(unsigned long addr) +{ + long result = *(volatile int *) ((addr << 9) + EISA_VL82C106); + return 0xffUL & result; +} + +extern inline void __local_outb(unsigned char b, unsigned long addr) +{ + *(volatile unsigned int *) ((addr << 9) + EISA_VL82C106) = b; + mb(); +} + +extern unsigned int __bus_inb(unsigned long addr); +extern inline unsigned int ___bus_inb(unsigned long addr) +{ + long result; + + __set_hae(0); + result = *(volatile int *) ((addr << 7) + EISA_IO + 0x00); + result >>= (addr & 3) * 8; + return 0xffUL & result; +} + +extern void __bus_outb(unsigned char b, unsigned long addr); +extern inline void ___bus_outb(unsigned char b, unsigned long addr) +{ + __set_hae(0); + *(volatile unsigned int *) ((addr << 7) + EISA_IO + 0x00) = b * 0x01010101; + mb(); +} + +/* + * It seems gcc is not very good at optimizing away logical + * operations that result in operations across inline functions. + * Which is why this is a macro. + */ +#define __is_local(addr) ( \ +/* keyboard */ (addr == 0x60 || addr == 0x64) || \ +/* RTC */ (addr == 0x170 || addr == 0x171) || \ +/* mb COM2 */ (addr >= 0x2f8 && addr <= 0x2ff) || \ +/* mb LPT1 */ (addr >= 0x3bc && addr <= 0x3be) || \ +/* mb COM2 */ (addr >= 0x3f8 && addr <= 0x3ff)) + +extern inline unsigned int __inb(unsigned long addr) +{ + if (__is_local(addr)) + return __local_inb(addr); + return __bus_inb(addr); +} + +extern inline void __outb(unsigned char b, unsigned long addr) +{ + if (__is_local(addr)) + __local_outb(b, addr); + else + __bus_outb(b, addr); +} + +extern inline unsigned int __inw(unsigned long addr) +{ + long result; + + __set_hae(0); + result = *(volatile int *) ((addr << 7) + EISA_IO + 0x20); + result >>= (addr & 3) * 8; + return 0xffffUL & result; +} + +extern inline unsigned int __inl(unsigned long addr) +{ + __set_hae(0); + return *(volatile unsigned int *) ((addr << 7) + EISA_IO + 0x60); +} + +extern inline void __outw(unsigned short b, unsigned long addr) +{ + __set_hae(0); + *(volatile unsigned int *) ((addr << 7) + EISA_IO + 0x20) = b * 0x00010001; + mb(); +} + +extern inline void __outl(unsigned int b, unsigned long addr) +{ + __set_hae(0); + *(volatile unsigned int *) ((addr << 7) + EISA_IO + 0x60) = b; + mb(); +} + +/* + * Memory functions. + */ +extern inline unsigned long __readb(unsigned long addr) +{ + long result; + + __set_hae(addr); + addr &= __HAE_MASK; + result = *(volatile int *) ((addr << 7) + EISA_MEM + 0x00); + result >>= (addr & 3) * 8; + return 0xffUL & result; +} + +extern inline unsigned long __readw(unsigned long addr) +{ + long result; + + __set_hae(addr); + addr &= __HAE_MASK; + result = *(volatile int *) ((addr << 7) + EISA_MEM + 0x20); + result >>= (addr & 3) * 8; + return 0xffffUL & result; +} + +extern inline unsigned long __readl(unsigned long addr) +{ + __set_hae(addr); + addr &= __HAE_MASK; + return *(volatile unsigned int *) ((addr << 7) + EISA_MEM + 0x60); +} + +extern inline void __writeb(unsigned short b, unsigned long addr) +{ + __set_hae(addr); + addr &= __HAE_MASK; + *(volatile unsigned int *) ((addr << 7) + EISA_MEM + 0x00) = b * 0x01010101; +} + +extern inline void __writew(unsigned short b, unsigned long addr) +{ + __set_hae(addr); + addr &= __HAE_MASK; + *(volatile unsigned int *) ((addr << 7) + EISA_MEM + 0x20) = b * 0x00010001; +} + +extern inline void __writel(unsigned int b, unsigned long addr) +{ + __set_hae(addr); + addr &= __HAE_MASK; + *(volatile unsigned int *) ((addr << 7) + EISA_MEM + 0x60) = b; +} + +/* + * The above have so much overhead that it probably doesn't make + * sense to have them inlined (better icache behaviour). + */ +extern unsigned int inb(unsigned long addr); +extern unsigned int inw(unsigned long addr); +extern unsigned int inl(unsigned long addr); + +extern void outb(unsigned char b, unsigned long addr); +extern void outw(unsigned short b, unsigned long addr); +extern void outl(unsigned int b, unsigned long addr); + +extern unsigned long readb(unsigned long addr); +extern unsigned long readw(unsigned long addr); +extern unsigned long readl(unsigned long addr); + +extern void writeb(unsigned short b, unsigned long addr); +extern void writew(unsigned short b, unsigned long addr); +extern void writel(unsigned int b, unsigned long addr); + +#define inb(port) \ +(__builtin_constant_p((port))?__inb(port):(inb)(port)) + +#define outb(x, port) \ +(__builtin_constant_p((port))?__outb((x),(port)):(outb)((x),(port))) + +#define inb_p inb +#define outb_p outb + +/* + * The Alpha Jensen hardware for some rather strange reason puts + * the RTC clock at 0x170 instead of 0x70. Probably due to some + * misguided idea about using 0x70 for NMI stuff. + * + * These defines will override the defaults when doing RTC queries + */ +#define RTC_PORT(x) (0x170+(x)) +#define RTC_ADDR(x) (x) +#define RTC_ALWAYS_BCD 0 + +#endif diff --git a/include/asm-alpha/lca.h b/include/asm-alpha/lca.h new file mode 100644 index 000000000..c3f58650f --- /dev/null +++ b/include/asm-alpha/lca.h @@ -0,0 +1,312 @@ +#ifndef __ALPHA_LCA__H +#define __ALPHA_LCA__H + +/* + * Low Cost Alpha (LCA) definitions (these apply to 21066 and 21068, + * for example). + * + * This file is based on: + * + * DECchip 21066 and DECchip 21068 Alpha AXP Microprocessors + * Hardware Reference Manual; Digital Equipment Corp.; May 1994; + * Maynard, MA; Order Number: EC-N2681-71. + */ + +/* + * NOTE: The LCA uses a Host Address Extension (HAE) register to access + * PCI addresses that are beyond the first 27 bits of address + * space. Updating the HAE requires an external cycle (and + * a memory barrier), which tends to be slow. Instead of updating + * it on each sparse memory access, we keep the current HAE value + * cached in variable cache_hae. Only if the cached HAE differs + * from the desired HAE value do we actually updated HAE register. + * The HAE register is preserved by the interrupt handler entry/exit + * code, so this scheme works even in the presence of interrupts. + * + * Dense memory space doesn't require the HAE, but is restricted to + * aligned 32 and 64 bit accesses. Special Cycle and Interrupt + * Acknowledge cycles may also require the use of the HAE. The LCA + * limits I/O address space to the bottom 24 bits of address space, + * but this easily covers the 16 bit ISA I/O address space. + */ + +/* + * NOTE 2! The memory operations do not set any memory barriers, as + * it's not needed for cases like a frame buffer that is essentially + * memory-like. You need to do them by hand if the operations depend + * on ordering. + * + * Similarly, the port I/O operations do a "mb" only after a write + * operation: if an mb is needed before (as in the case of doing + * memory mapped I/O first, and then a port I/O operation to the same + * device), it needs to be done by hand. + * + * After the above has bitten me 100 times, I'll give up and just do + * the mb all the time, but right now I'm hoping this will work out. + * Avoiding mb's may potentially be a noticeable speed improvement, + * but I can't honestly say I've tested it. + * + * Handling interrupts that need to do mb's to synchronize to + * non-interrupts is another fun race area. Don't do it (because if + * you do, I'll have to do *everything* with interrupts disabled, + * ugh). + */ + +#define LCA_DMA_WIN_BASE (1024*1024*1024) +#define LCA_DMA_WIN_SIZE (1024*1024*1024) + +/* + * Translate physical memory address as seen on (PCI) bus into + * a kernel virtual address and vv. + */ +extern inline unsigned long virt_to_bus(void * address) +{ + return virt_to_phys(address) + LCA_DMA_WIN_BASE; +} + +extern inline void * bus_to_virt(unsigned long address) +{ + return phys_to_virt(address - LCA_DMA_WIN_BASE); +} + +/* + * Memory Controller registers: + */ +#define LCA_MEM_BCR0 (IDENT_ADDR + 0x120000000UL) +#define LCA_MEM_BCR1 (IDENT_ADDR + 0x120000008UL) +#define LCA_MEM_BCR2 (IDENT_ADDR + 0x120000010UL) +#define LCA_MEM_BCR3 (IDENT_ADDR + 0x120000018UL) +#define LCA_MEM_BMR0 (IDENT_ADDR + 0x120000020UL) +#define LCA_MEM_BMR1 (IDENT_ADDR + 0x120000028UL) +#define LCA_MEM_BMR2 (IDENT_ADDR + 0x120000030UL) +#define LCA_MEM_BMR3 (IDENT_ADDR + 0x120000038UL) +#define LCA_MEM_BTR0 (IDENT_ADDR + 0x120000040UL) +#define LCA_MEM_BTR1 (IDENT_ADDR + 0x120000048UL) +#define LCA_MEM_BTR2 (IDENT_ADDR + 0x120000050UL) +#define LCA_MEM_BTR3 (IDENT_ADDR + 0x120000058UL) +#define LCA_MEM_GTR (IDENT_ADDR + 0x120000060UL) +#define LCA_MEM_ESR (IDENT_ADDR + 0x120000068UL) +#define LCA_MEM_EAR (IDENT_ADDR + 0x120000070UL) +#define LCA_MEM_CAR (IDENT_ADDR + 0x120000078UL) +#define LCA_MEM_VGR (IDENT_ADDR + 0x120000080UL) +#define LCA_MEM_PLM (IDENT_ADDR + 0x120000088UL) +#define LCA_MEM_FOR (IDENT_ADDR + 0x120000090UL) + +/* + * I/O Controller registers: + */ +#define LCA_IOC_HAE (IDENT_ADDR + 0x180000000UL) +#define LCA_IOC_CONF (IDENT_ADDR + 0x180000020UL) +#define LCA_IOC_STAT0 (IDENT_ADDR + 0x180000040UL) +#define LCA_IOC_STAT1 (IDENT_ADDR + 0x180000060UL) +#define LCA_IOC_TBIA (IDENT_ADDR + 0x180000080UL) +#define LCA_IOC_TB_ENA (IDENT_ADDR + 0x1800000a0UL) +#define LCA_IOC_SFT_RST (IDENT_ADDR + 0x1800000c0UL) +#define LCA_IOC_PAR_DIS (IDENT_ADDR + 0x1800000e0UL) +#define LCA_IOC_W_BASE0 (IDENT_ADDR + 0x180000100UL) +#define LCA_IOC_W_BASE1 (IDENT_ADDR + 0x180000120UL) +#define LCA_IOC_W_MASK0 (IDENT_ADDR + 0x180000140UL) +#define LCA_IOC_W_MASK1 (IDENT_ADDR + 0x180000160UL) +#define LCA_IOC_T_BASE0 (IDENT_ADDR + 0x180000180UL) +#define LCA_IOC_T_BASE1 (IDENT_ADDR + 0x1800001a0UL) +#define LCA_IOC_TB_TAG0 (IDENT_ADDR + 0x188000000UL) +#define LCA_IOC_TB_TAG1 (IDENT_ADDR + 0x188000020UL) +#define LCA_IOC_TB_TAG2 (IDENT_ADDR + 0x188000040UL) +#define LCA_IOC_TB_TAG3 (IDENT_ADDR + 0x188000060UL) +#define LCA_IOC_TB_TAG4 (IDENT_ADDR + 0x188000070UL) +#define LCA_IOC_TB_TAG5 (IDENT_ADDR + 0x1880000a0UL) +#define LCA_IOC_TB_TAG6 (IDENT_ADDR + 0x1880000c0UL) +#define LCA_IOC_TB_TAG7 (IDENT_ADDR + 0x1880000e0UL) + +/* + * Memory spaces: + */ +#define LCA_IACK_SC (IDENT_ADDR + 0x1a0000000UL) +#define LCA_CONF (IDENT_ADDR + 0x1e0000000UL) +#define LCA_IO (IDENT_ADDR + 0x1c0000000UL) +#define LCA_SPARSE_MEM (IDENT_ADDR + 0x200000000UL) +#define LCA_DENSE_MEM (IDENT_ADDR + 0x300000000UL) + +/* + * Bit definitions for I/O Controller status register 0: + */ +#define LCA_IOC_STAT0_CMD 0xf +#define LCA_IOC_STAT0_ERR (1<<4) +#define LCA_IOC_STAT0_LOST (1<<5) +#define LCA_IOC_STAT0_THIT (1<<6) +#define LCA_IOC_STAT0_TREF (1<<7) +#define LCA_IOC_STAT0_CODE_SHIFT 8 +#define LCA_IOC_STAT0_CODE_MASK 0x7 +#define LCA_IOC_STAT0_P_NBR_SHIFT 13 +#define LCA_IOC_STAT0_P_NBR_MASK 0x7ffff + +#define HAE_ADDRESS LCA_IOC_HAE + +/* + * I/O functions: + * + * Unlike Jensen, the Noname machines have no concept of local + * I/O---everything goes over the PCI bus. + * + * There is plenty room for optimization here. In particular, + * the Alpha's insb/insw/extb/extw should be useful in moving + * data to/from the right byte-lanes. + */ + +#define vuip volatile unsigned int * + +extern inline unsigned int __inb(unsigned long addr) +{ + long result = *(vuip) ((addr << 5) + LCA_IO + 0x00); + result >>= (addr & 3) * 8; + return 0xffUL & result; +} + +extern inline void __outb(unsigned char b, unsigned long addr) +{ + unsigned int w; + + asm ("insbl %2,%1,%0" : "r="(w) : "ri"(addr & 0x3), "r"(b)); + *(vuip) ((addr << 5) + LCA_IO + 0x00) = w; + mb(); +} + +extern inline unsigned int __inw(unsigned long addr) +{ + long result = *(vuip) ((addr << 5) + LCA_IO + 0x08); + result >>= (addr & 3) * 8; + return 0xffffUL & result; +} + +extern inline void __outw(unsigned short b, unsigned long addr) +{ + unsigned int w; + + asm ("inswl %2,%1,%0" : "r="(w) : "ri"(addr & 0x3), "r"(b)); + *(vuip) ((addr << 5) + LCA_IO + 0x08) = w; + mb(); +} + +extern inline unsigned int __inl(unsigned long addr) +{ + return *(vuip) ((addr << 5) + LCA_IO + 0x18); +} + +extern inline void __outl(unsigned int b, unsigned long addr) +{ + *(vuip) ((addr << 5) + LCA_IO + 0x18) = b; + mb(); +} + + +/* + * Memory functions. 64-bit and 32-bit accesses are done through + * dense memory space, everything else through sparse space. + */ +extern inline unsigned long __readb(unsigned long addr) +{ + unsigned long result, shift, msb; + + shift = (addr & 0x3) * 8; + if (addr >= (1UL << 24)) { + msb = addr & 0xf8000000; + addr -= msb; + if (msb != hae.cache) { + set_hae(msb); + } + } + result = *(vuip) ((addr << 5) + LCA_SPARSE_MEM + 0x00); + result >>= shift; + return 0xffUL & result; +} + +extern inline unsigned long __readw(unsigned long addr) +{ + unsigned long result, shift, msb; + + shift = (addr & 0x3) * 8; + if (addr >= (1UL << 24)) { + msb = addr & 0xf8000000; + addr -= msb; + if (msb != hae.cache) { + set_hae(msb); + } + } + result = *(vuip) ((addr << 5) + LCA_SPARSE_MEM + 0x08); + result >>= shift; + return 0xffffUL & result; +} + +extern inline unsigned long __readl(unsigned long addr) +{ + return *(vuip) (addr + LCA_DENSE_MEM); +} + +extern inline void __writeb(unsigned char b, unsigned long addr) +{ + unsigned long msb; + + if (addr >= (1UL << 24)) { + msb = addr & 0xf8000000; + addr -= msb; + if (msb != hae.cache) { + set_hae(msb); + } + } + *(vuip) ((addr << 5) + LCA_SPARSE_MEM + 0x00) = b * 0x01010101; +} + +extern inline void __writew(unsigned short b, unsigned long addr) +{ + unsigned long msb; + + if (addr >= (1UL << 24)) { + msb = addr & 0xf8000000; + addr -= msb; + if (msb != hae.cache) { + set_hae(msb); + } + } + *(vuip) ((addr << 5) + LCA_SPARSE_MEM + 0x08) = b * 0x00010001; +} + +extern inline void __writel(unsigned int b, unsigned long addr) +{ + *(vuip) (addr + LCA_DENSE_MEM) = b; +} + +/* + * Most of the above have so much overhead that it probably doesn't + * make sense to have them inlined (better icache behavior). + */ +extern unsigned int inb(unsigned long addr); +extern unsigned int inw(unsigned long addr); +extern unsigned int inl(unsigned long addr); + +extern void outb(unsigned char b, unsigned long addr); +extern void outw(unsigned short b, unsigned long addr); +extern void outl(unsigned int b, unsigned long addr); + +extern unsigned long readb(unsigned long addr); +extern unsigned long readw(unsigned long addr); + +extern void writeb(unsigned short b, unsigned long addr); +extern void writew(unsigned short b, unsigned long addr); + +#define inb(port) \ +(__builtin_constant_p((port))?__inb(port):(inb)(port)) + +#define outb(x, port) \ +(__builtin_constant_p((port))?__outb((x),(port)):(outb)((x),(port))) + +#define inb_p inb +#define outb_p outb + +#define readl(addr) __readl(addr) +#define writel(b,addr) __writel(b,addr) + +#undef vuip + +extern unsigned long lca_init (unsigned long mem_start, unsigned long mem_end); + +#endif diff --git a/include/asm-alpha/page.h b/include/asm-alpha/page.h index 6a09532f9..316bc9dd1 100644 --- a/include/asm-alpha/page.h +++ b/include/asm-alpha/page.h @@ -1,6 +1,53 @@ #ifndef _ALPHA_PAGE_H #define _ALPHA_PAGE_H +/* PAGE_SHIFT determines the page size */ +#define PAGE_SHIFT 13 +#define PAGE_SIZE (1UL << PAGE_SHIFT) +#define PAGE_MASK (~(PAGE_SIZE-1)) + +#ifdef __KERNEL__ + +#define CONFIG_STRICT_MM_TYPECHECKS + +#ifdef CONFIG_STRICT_MM_TYPECHECKS +/* + * These are used to make use of C type-checking.. + */ +typedef struct { unsigned long pte; } pte_t; +typedef struct { unsigned long pmd; } pmd_t; +typedef struct { unsigned long pgd; } pgd_t; +typedef struct { unsigned long pgprot; } pgprot_t; + +#define pte_val(x) ((x).pte) +#define pmd_val(x) ((x).pmd) +#define pgd_val(x) ((x).pgd) +#define pgprot_val(x) ((x).pgprot) + +#define __pte(x) ((pte_t) { (x) } ) +#define __pgd(x) ((pgd_t) { (x) } ) +#define __pgprot(x) ((pgprot_t) { (x) } ) + +#else +/* + * .. while these make it easier on the compiler + */ +typedef unsigned long pte_t; +typedef unsigned long pmd_t; +typedef unsigned long pgd_t; +typedef unsigned long pgprot_t; + +#define pte_val(x) (x) +#define pmd_val(x) (x) +#define pgd_val(x) (x) +#define pgprot_val(x) (x) + +#define __pte(x) (x) +#define __pgd(x) (x) +#define __pgprot(x) (x) + +#endif + #define invalidate_all() \ __asm__ __volatile__( \ "lda $16,-2($31)\n\t" \ @@ -13,37 +60,16 @@ __asm__ __volatile__( \ ".long 51" \ : : :"$1", "$16", "$17", "$22","$23","$24","$25") - /* PAGE_SHIFT determines the page size */ -#define PAGE_SHIFT 13 -#define PGDIR_SHIFT 23 -#define PAGE_SIZE (1UL << PAGE_SHIFT) -#define PGDIR_SIZE (1UL << PGDIR_SHIFT) +#define copy_page(from,to) memcpy((void *) to, (void *) from, PAGE_SIZE) -#ifdef __KERNEL__ - - /* number of bits that fit into a memory pointer */ -#define BITS_PER_PTR (8*sizeof(unsigned long)) - /* to mask away the intra-page address bits */ -#define PAGE_MASK (~(PAGE_SIZE-1)) - /* to mask away the intra-page address bits */ -#define PGDIR_MASK (~(PGDIR_SIZE-1)) - /* to align the pointer to the (next) page boundary */ +/* to align the pointer to the (next) page boundary */ #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK) - /* to align the pointer to a pointer address */ -#define PTR_MASK (~(sizeof(void*)-1)) - - /* sizeof(void*)==1<<SIZEOF_PTR_LOG2 */ - /* 64-bit machines, beware! SRB. */ -#define SIZEOF_PTR_LOG2 4 - - /* to find an entry in a page-table-directory */ -#define PAGE_DIR_OFFSET(base,address) ((unsigned long*)((base)+\ - ((unsigned long)(address)>>(PAGE_SHIFT-SIZEOF_PTR_LOG2)*2&PTR_MASK&~PAGE_MASK))) - /* to find an entry in a page-table */ -#define PAGE_PTR(address) \ - ((unsigned long)(address)>>(PAGE_SHIFT-SIZEOF_PTR_LOG2)&PTR_MASK&~PAGE_MASK) - /* the no. of pointers that fit on a page */ -#define PTRS_PER_PAGE (PAGE_SIZE/sizeof(void*)) + +#define PAGE_OFFSET 0xFFFFFC0000000000 +#define MAP_NR(addr) ((((unsigned long) (addr)) - PAGE_OFFSET) >> PAGE_SHIFT) +#define MAP_PAGE_RESERVED (1<<31) + +typedef unsigned int mem_map_t; #endif /* __KERNEL__ */ diff --git a/include/asm-alpha/param.h b/include/asm-alpha/param.h new file mode 100644 index 000000000..03f57ecff --- /dev/null +++ b/include/asm-alpha/param.h @@ -0,0 +1,20 @@ +#ifndef _ASMAXP_PARAM_H +#define _ASMAXP_PARAM_H + +#ifndef HZ +#define HZ 1024 +#endif + +#define EXEC_PAGESIZE 8192 + +#ifndef NGROUPS +#define NGROUPS 32 +#endif + +#ifndef NOGROUP +#define NOGROUP (-1) +#endif + +#define MAXHOSTNAMELEN 64 /* max length of hostname */ + +#endif diff --git a/include/asm-alpha/pgtable.h b/include/asm-alpha/pgtable.h new file mode 100644 index 000000000..51425af46 --- /dev/null +++ b/include/asm-alpha/pgtable.h @@ -0,0 +1,423 @@ +#ifndef _ALPHA_PGTABLE_H +#define _ALPHA_PGTABLE_H + +/* + * This file contains the functions and defines necessary to modify and use + * the alpha page table tree. + * + * This hopefully works with any standard alpha page-size, as defined + * in <asm/page.h> (currently 8192). + */ + +/* PMD_SHIFT determines the size of the area a second-level page table can map */ +#define PMD_SHIFT (PAGE_SHIFT + (PAGE_SHIFT-3)) +#define PMD_SIZE (1UL << PMD_SHIFT) +#define PMD_MASK (~(PMD_SIZE-1)) + +/* PGDIR_SHIFT determines what a third-level page table entry can map */ +#define PGDIR_SHIFT (PAGE_SHIFT + 2*(PAGE_SHIFT-3)) +#define PGDIR_SIZE (1UL << PGDIR_SHIFT) +#define PGDIR_MASK (~(PGDIR_SIZE-1)) + +/* + * entries per page directory level: the alpha is three-level, with + * all levels having a one-page page table. + * + * The PGD is special: the last entry is reserved for self-mapping. + */ +#define PTRS_PER_PTE (1UL << (PAGE_SHIFT-3)) +#define PTRS_PER_PMD (1UL << (PAGE_SHIFT-3)) +#define PTRS_PER_PGD ((1UL << (PAGE_SHIFT-3))-1) + +/* the no. of pointers that fit on a page: this will go away */ +#define PTRS_PER_PAGE (1UL << (PAGE_SHIFT-3)) + +#define VMALLOC_START 0xFFFFFE0000000000 +#define VMALLOC_VMADDR(x) ((unsigned long)(x)) + +/* + * OSF/1 PAL-code-imposed page table bits + */ +#define _PAGE_VALID 0x0001 +#define _PAGE_FOR 0x0002 /* used for page protection (fault on read) */ +#define _PAGE_FOW 0x0004 /* used for page protection (fault on write) */ +#define _PAGE_FOE 0x0008 /* used for page protection (fault on exec) */ +#define _PAGE_ASM 0x0010 +#define _PAGE_KRE 0x0100 /* xxx - see below on the "accessed" bit */ +#define _PAGE_URE 0x0200 /* xxx */ +#define _PAGE_KWE 0x1000 /* used to do the dirty bit in software */ +#define _PAGE_UWE 0x2000 /* used to do the dirty bit in software */ + +/* .. and these are ours ... */ +#define _PAGE_COW 0x10000 +#define _PAGE_DIRTY 0x20000 +#define _PAGE_ACCESSED 0x40000 + +/* + * NOTE! The "accessed" bit isn't necessarily exact: it can be kept exactly + * by software (use the KRE/URE/KWE/UWE bits appropriately), but I'll fake it. + * Under Linux/AXP, the "accessed" bit just means "read", and I'll just use + * the KRE/URE bits to watch for it. That way we don't need to overload the + * KWE/UWE bits with both handling dirty and accessed. + * + * Note that the kernel uses the accessed bit just to check whether to page + * out a page or not, so it doesn't have to be exact anyway. + */ + +#define __DIRTY_BITS (_PAGE_DIRTY | _PAGE_KWE | _PAGE_UWE) +#define __ACCESS_BITS (_PAGE_ACCESSED | _PAGE_KRE | _PAGE_URE) + +#define _PFN_MASK 0xFFFFFFFF00000000 + +#define _PAGE_TABLE (_PAGE_VALID | __DIRTY_BITS | __ACCESS_BITS) +#define _PAGE_CHG_MASK (_PFN_MASK | __DIRTY_BITS | __ACCESS_BITS) + +/* + * All the normal masks have the "page accessed" bits on, as any time they are used, + * the page is accessed. They are cleared only by the page-out routines + */ +#define PAGE_NONE __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOR | _PAGE_FOW | _PAGE_FOE) +#define PAGE_SHARED __pgprot(_PAGE_VALID | __ACCESS_BITS) +#define PAGE_COPY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_COW) +#define PAGE_READONLY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW) +#define PAGE_KERNEL __pgprot(_PAGE_VALID | _PAGE_ASM | _PAGE_KRE | _PAGE_KWE) + +#define _PAGE_NORMAL(x) __pgprot(_PAGE_VALID | __ACCESS_BITS | (x)) + +#define _PAGE_P(x) _PAGE_NORMAL((x) | (((x) & _PAGE_FOW)?0:(_PAGE_FOW | _PAGE_COW))) +#define _PAGE_S(x) _PAGE_NORMAL(x) + +/* + * The hardware can handle write-only mappings, but as the alpha + * architecture does byte-wide writes with a read-modify-write + * sequence, it's not practical to have write-without-read privs. + * Thus the "-w- -> rw-" and "-wx -> rwx" mapping here (and in + * arch/alpha/mm/fault.c) + */ + /* xwr */ +#define __P000 _PAGE_P(_PAGE_FOE | _PAGE_FOW | _PAGE_FOR) +#define __P001 _PAGE_P(_PAGE_FOE | _PAGE_FOW) +#define __P010 _PAGE_P(_PAGE_FOE) +#define __P011 _PAGE_P(_PAGE_FOE) +#define __P100 _PAGE_P(_PAGE_FOW | _PAGE_FOR) +#define __P101 _PAGE_P(_PAGE_FOW) +#define __P110 _PAGE_P(0) +#define __P111 _PAGE_P(0) + +#define __S000 _PAGE_S(_PAGE_FOE | _PAGE_FOW | _PAGE_FOR) +#define __S001 _PAGE_S(_PAGE_FOE | _PAGE_FOW) +#define __S010 _PAGE_S(_PAGE_FOE) +#define __S011 _PAGE_S(_PAGE_FOE) +#define __S100 _PAGE_S(_PAGE_FOW | _PAGE_FOR) +#define __S101 _PAGE_S(_PAGE_FOW) +#define __S110 _PAGE_S(0) +#define __S111 _PAGE_S(0) + +/* + * BAD_PAGETABLE is used when we need a bogus page-table, while + * BAD_PAGE is used for a bogus page. + * + * ZERO_PAGE is a global shared page that is always zero: used + * for zero-mapped memory areas etc.. + */ +extern pte_t __bad_page(void); +extern pmd_t * __bad_pagetable(void); + +extern unsigned long __zero_page(void); + +#define BAD_PAGETABLE __bad_pagetable() +#define BAD_PAGE __bad_page() +#define ZERO_PAGE __zero_page() + +/* number of bits that fit into a memory pointer */ +#define BITS_PER_PTR (8*sizeof(unsigned long)) + +/* to align the pointer to a pointer address */ +#define PTR_MASK (~(sizeof(void*)-1)) + +/* sizeof(void*)==1<<SIZEOF_PTR_LOG2 */ +#define SIZEOF_PTR_LOG2 3 + +/* to find an entry in a page-table */ +#define PAGE_PTR(address) \ + ((unsigned long)(address)>>(PAGE_SHIFT-SIZEOF_PTR_LOG2)&PTR_MASK&~PAGE_MASK) + +extern unsigned long high_memory; + +/* + * Conversion functions: convert a page and protection to a page entry, + * and a page entry and page directory to the page they refer to. + */ +extern inline pte_t mk_pte(unsigned long page, pgprot_t pgprot) +{ pte_t pte; pte_val(pte) = ((page-PAGE_OFFSET) << (32-PAGE_SHIFT)) | pgprot_val(pgprot); return pte; } + +extern inline pte_t pte_modify(pte_t pte, pgprot_t newprot) +{ pte_val(pte) = (pte_val(pte) & _PAGE_CHG_MASK) | pgprot_val(newprot); return pte; } + +extern inline void pmd_set(pmd_t * pmdp, pte_t * ptep) +{ pmd_val(*pmdp) = _PAGE_TABLE | ((((unsigned long) ptep) - PAGE_OFFSET) << (32-PAGE_SHIFT)); } + +extern inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp) +{ pgd_val(*pgdp) = _PAGE_TABLE | ((((unsigned long) pmdp) - PAGE_OFFSET) << (32-PAGE_SHIFT)); } + +extern inline unsigned long pte_page(pte_t pte) +{ return PAGE_OFFSET + ((pte_val(pte) & _PFN_MASK) >> (32-PAGE_SHIFT)); } + +extern inline unsigned long pmd_page(pmd_t pmd) +{ return PAGE_OFFSET + ((pmd_val(pmd) & _PFN_MASK) >> (32-PAGE_SHIFT)); } + +extern inline unsigned long pgd_page(pgd_t pgd) +{ return PAGE_OFFSET + ((pgd_val(pgd) & _PFN_MASK) >> (32-PAGE_SHIFT)); } + +extern inline int pte_none(pte_t pte) { return !pte_val(pte); } +extern inline int pte_present(pte_t pte) { return pte_val(pte) & _PAGE_VALID; } +extern inline int pte_inuse(pte_t *ptep) { return mem_map[MAP_NR(ptep)] != 1; } +extern inline void pte_clear(pte_t *ptep) { pte_val(*ptep) = 0; } +extern inline void pte_reuse(pte_t * ptep) +{ + if (!(mem_map[MAP_NR(ptep)] & MAP_PAGE_RESERVED)) + mem_map[MAP_NR(ptep)]++; +} + +extern inline int pmd_none(pmd_t pmd) { return !pmd_val(pmd); } +extern inline int pmd_bad(pmd_t pmd) { return (pmd_val(pmd) & ~_PFN_MASK) != _PAGE_TABLE || pmd_page(pmd) > high_memory; } +extern inline int pmd_present(pmd_t pmd) { return pmd_val(pmd) & _PAGE_VALID; } +extern inline int pmd_inuse(pmd_t *pmdp) { return mem_map[MAP_NR(pmdp)] != 1; } +extern inline void pmd_clear(pmd_t * pmdp) { pmd_val(*pmdp) = 0; } +extern inline void pmd_reuse(pmd_t * pmdp) +{ + if (!(mem_map[MAP_NR(pmdp)] & MAP_PAGE_RESERVED)) + mem_map[MAP_NR(pmdp)]++; +} + +extern inline int pgd_none(pgd_t pgd) { return !pgd_val(pgd); } +extern inline int pgd_bad(pgd_t pgd) { return (pgd_val(pgd) & ~_PFN_MASK) != _PAGE_TABLE || pgd_page(pgd) > high_memory; } +extern inline int pgd_present(pgd_t pgd) { return pgd_val(pgd) & _PAGE_VALID; } +extern inline int pgd_inuse(pgd_t *pgdp) { return mem_map[MAP_NR(pgdp)] != 1; } +extern inline void pgd_clear(pgd_t * pgdp) { pgd_val(*pgdp) = 0; } +extern inline void pgd_reuse(pgd_t * pgdp) +{ + if (!(mem_map[MAP_NR(pgdp)] & MAP_PAGE_RESERVED)) + mem_map[MAP_NR(pgdp)]++; +} + +/* + * The following only work if pte_present() is true. + * Undefined behaviour if not.. + */ +extern inline int pte_read(pte_t pte) { return !(pte_val(pte) & _PAGE_FOR); } +extern inline int pte_write(pte_t pte) { return !(pte_val(pte) & _PAGE_FOW); } +extern inline int pte_exec(pte_t pte) { return !(pte_val(pte) & _PAGE_FOE); } +extern inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRTY; } +extern inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED; } +extern inline int pte_cow(pte_t pte) { return pte_val(pte) & _PAGE_COW; } + +extern inline pte_t pte_wrprotect(pte_t pte) { pte_val(pte) |= _PAGE_FOW; return pte; } +extern inline pte_t pte_rdprotect(pte_t pte) { pte_val(pte) |= _PAGE_FOR; return pte; } +extern inline pte_t pte_exprotect(pte_t pte) { pte_val(pte) |= _PAGE_FOE; return pte; } +extern inline pte_t pte_mkclean(pte_t pte) { pte_val(pte) &= ~(__DIRTY_BITS); return pte; } +extern inline pte_t pte_mkold(pte_t pte) { pte_val(pte) &= ~(__ACCESS_BITS); return pte; } +extern inline pte_t pte_uncow(pte_t pte) { pte_val(pte) &= ~_PAGE_COW; return pte; } +extern inline pte_t pte_mkwrite(pte_t pte) { pte_val(pte) &= ~_PAGE_FOW; return pte; } +extern inline pte_t pte_mkread(pte_t pte) { pte_val(pte) &= ~_PAGE_FOR; return pte; } +extern inline pte_t pte_mkexec(pte_t pte) { pte_val(pte) &= ~_PAGE_FOE; return pte; } +extern inline pte_t pte_mkdirty(pte_t pte) { pte_val(pte) |= __DIRTY_BITS; return pte; } +extern inline pte_t pte_mkyoung(pte_t pte) { pte_val(pte) |= __ACCESS_BITS; return pte; } +extern inline pte_t pte_mkcow(pte_t pte) { pte_val(pte) |= _PAGE_COW; return pte; } + +/* + * To set the page-dir. Note the self-mapping in the last entry + * + * Also note that if we update the current process ptbr, we need to + * update the PAL-cached ptbr value as well.. There doesn't seem to + * be any "wrptbr" PAL-insn, but we can do a dummy swpctx to ourself + * instead. + */ +extern inline void SET_PAGE_DIR(struct task_struct * tsk, pgd_t * pgdir) +{ + pgd_val(pgdir[PTRS_PER_PGD]) = pte_val(mk_pte((unsigned long) pgdir, PAGE_KERNEL)); + tsk->tss.ptbr = ((unsigned long) pgdir - PAGE_OFFSET) >> PAGE_SHIFT; + if (tsk == current) + __asm__ __volatile__( + "bis %0,%0,$16\n\t" + "call_pal %1" + : /* no outputs */ + : "r" (&tsk->tss), "i" (PAL_swpctx) + : "$0", "$1", "$16", "$22", "$23", "$24", "$25"); +} + +#define PAGE_DIR_OFFSET(tsk,address) pgd_offset((tsk),(address)) + +/* to find an entry in a page-table-directory. */ +extern inline pgd_t * pgd_offset(struct task_struct * tsk, unsigned long address) +{ + return (pgd_t *) ((tsk->tss.ptbr << PAGE_SHIFT) + PAGE_OFFSET) + + ((address >> PGDIR_SHIFT) & (PTRS_PER_PAGE - 1)); +} + +/* Find an entry in the second-level page table.. */ +extern inline pmd_t * pmd_offset(pgd_t * dir, unsigned long address) +{ + return (pmd_t *) pgd_page(*dir) + ((address >> PMD_SHIFT) & (PTRS_PER_PAGE - 1)); +} + +/* Find an entry in the third-level page table.. */ +extern inline pte_t * pte_offset(pmd_t * dir, unsigned long address) +{ + return (pte_t *) pmd_page(*dir) + ((address >> PAGE_SHIFT) & (PTRS_PER_PAGE - 1)); +} + +/* + * Allocate and free page tables. The xxx_kernel() versions are + * used to allocate a kernel page table - this turns on ASN bits + * if any, and marks the page tables reserved. + */ +extern inline void pte_free_kernel(pte_t * pte) +{ + mem_map[MAP_NR(pte)] = 1; + free_page((unsigned long) pte); +} + +extern inline pte_t * pte_alloc_kernel(pmd_t *pmd, unsigned long address) +{ + address = (address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1); + if (pmd_none(*pmd)) { + pte_t *page = (pte_t *) get_free_page(GFP_KERNEL); + if (pmd_none(*pmd)) { + if (page) { + pmd_set(pmd, page); + mem_map[MAP_NR(page)] = MAP_PAGE_RESERVED; + return page + address; + } + pmd_set(pmd, (pte_t *) BAD_PAGETABLE); + return NULL; + } + free_page((unsigned long) page); + } + if (pmd_bad(*pmd)) { + printk("Bad pmd in pte_alloc: %08lx\n", pmd_val(*pmd)); + pmd_set(pmd, (pte_t *) BAD_PAGETABLE); + return NULL; + } + return (pte_t *) pmd_page(*pmd) + address; +} + +extern inline void pmd_free_kernel(pmd_t * pmd) +{ + mem_map[MAP_NR(pmd)] = 1; + free_page((unsigned long) pmd); +} + +extern inline pmd_t * pmd_alloc_kernel(pgd_t *pgd, unsigned long address) +{ + address = (address >> PMD_SHIFT) & (PTRS_PER_PMD - 1); + if (pgd_none(*pgd)) { + pmd_t *page = (pmd_t *) get_free_page(GFP_KERNEL); + if (pgd_none(*pgd)) { + if (page) { + pgd_set(pgd, page); + mem_map[MAP_NR(page)] = MAP_PAGE_RESERVED; + return page + address; + } + pgd_set(pgd, BAD_PAGETABLE); + return NULL; + } + free_page((unsigned long) page); + } + if (pgd_bad(*pgd)) { + printk("Bad pgd in pmd_alloc: %08lx\n", pgd_val(*pgd)); + pgd_set(pgd, BAD_PAGETABLE); + return NULL; + } + return (pmd_t *) pgd_page(*pgd) + address; +} + +extern inline void pte_free(pte_t * pte) +{ + free_page((unsigned long) pte); +} + +extern inline pte_t * pte_alloc(pmd_t *pmd, unsigned long address) +{ + address = (address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1); + if (pmd_none(*pmd)) { + pte_t *page = (pte_t *) get_free_page(GFP_KERNEL); + if (pmd_none(*pmd)) { + if (page) { + pmd_set(pmd, page); + return page + address; + } + pmd_set(pmd, (pte_t *) BAD_PAGETABLE); + return NULL; + } + free_page((unsigned long) page); + } + if (pmd_bad(*pmd)) { + printk("Bad pmd in pte_alloc: %08lx\n", pmd_val(*pmd)); + pmd_set(pmd, (pte_t *) BAD_PAGETABLE); + return NULL; + } + return (pte_t *) pmd_page(*pmd) + address; +} + +extern inline void pmd_free(pmd_t * pmd) +{ + free_page((unsigned long) pmd); +} + +extern inline pmd_t * pmd_alloc(pgd_t *pgd, unsigned long address) +{ + address = (address >> PMD_SHIFT) & (PTRS_PER_PMD - 1); + if (pgd_none(*pgd)) { + pmd_t *page = (pmd_t *) get_free_page(GFP_KERNEL); + if (pgd_none(*pgd)) { + if (page) { + pgd_set(pgd, page); + return page + address; + } + pgd_set(pgd, BAD_PAGETABLE); + return NULL; + } + free_page((unsigned long) page); + } + if (pgd_bad(*pgd)) { + printk("Bad pgd in pmd_alloc: %08lx\n", pgd_val(*pgd)); + pgd_set(pgd, BAD_PAGETABLE); + return NULL; + } + return (pmd_t *) pgd_page(*pgd) + address; +} + +extern inline void pgd_free(pgd_t * pgd) +{ + free_page((unsigned long) pgd); +} + +extern inline pgd_t * pgd_alloc(void) +{ + return (pgd_t *) get_free_page(GFP_KERNEL); +} + +extern pgd_t swapper_pg_dir[1024]; + +/* + * The alpha doesn't have any external MMU info: the kernel page + * tables contain all the necessary information. + */ +extern inline void update_mmu_cache(struct vm_area_struct * vma, + unsigned long address, pte_t pte) +{ +} + +/* + * Non-present pages: high 24 bits are offset, next 8 bits type, + * low 32 bits zero.. + */ +extern inline pte_t mk_swap_pte(unsigned long type, unsigned long offset) +{ pte_t pte; pte_val(pte) = (type << 32) | (offset << 40); return pte; } + +#define SWP_TYPE(entry) (((entry) >> 32) & 0xff) +#define SWP_OFFSET(entry) ((entry) >> 40) +#define SWP_ENTRY(type,offset) pte_val(mk_swap_pte((type),(offset))) + +#endif /* _ALPHA_PGTABLE_H */ diff --git a/include/asm-alpha/processor.h b/include/asm-alpha/processor.h new file mode 100644 index 000000000..2e953e3cd --- /dev/null +++ b/include/asm-alpha/processor.h @@ -0,0 +1,75 @@ +/* + * include/asm-alpha/processor.h + * + * Copyright (C) 1994 Linus Torvalds + */ + +#ifndef __ASM_ALPHA_PROCESSOR_H +#define __ASM_ALPHA_PROCESSOR_H + +/* + * We have a 41-bit user address space: 2TB user VM... + */ +#define TASK_SIZE (0x40000000000UL) + +/* + * Bus types + */ +#define EISA_bus 1 +#define EISA_bus__is_a_macro /* for versions in ksyms.c */ +#define MCA_bus 0 +#define MCA_bus__is_a_macro /* for versions in ksyms.c */ + +/* + * The alpha has no problems with write protection + */ +#define wp_works_ok 1 +#define wp_works_ok__is_a_macro /* for versions in ksyms.c */ + +struct thread_struct { + unsigned long ksp; + unsigned long usp; + unsigned long ptbr; + unsigned int pcc; + unsigned int asn; + unsigned long unique; + unsigned long flags; + unsigned long res1, res2; +}; + +#define INIT_MMAP { &init_task, 0xfffffc0000000000, 0xfffffc0010000000, \ + PAGE_SHARED, VM_READ | VM_WRITE | VM_EXEC } + +#define INIT_TSS { \ + 0, 0, 0, \ + 0, 0, 0, \ + 0, 0, 0, \ +} + +#include <asm/ptrace.h> + +/* + * Return saved PC of a blocked thread. This assumes the frame pointer + * is the 6th saved long on the kernel stack and that the saved return + * address is the first long in the frame. This all holds provided the + * thread blocked through a call to schedule(). + */ +extern inline unsigned long thread_saved_pc(struct thread_struct *t) +{ + unsigned long fp; + + fp = ((unsigned long*)t->ksp)[6]; + return *(unsigned long*)fp; +} + +/* + * Do necessary setup to start up a newly executed thread. + */ +static inline void start_thread(struct pt_regs * regs, unsigned long pc, unsigned long sp) +{ + regs->pc = pc; + regs->ps = 8; + wrusp(sp); +} + +#endif /* __ASM_ALPHA_PROCESSOR_H */ diff --git a/include/asm-alpha/ptrace.h b/include/asm-alpha/ptrace.h new file mode 100644 index 000000000..7bda114cd --- /dev/null +++ b/include/asm-alpha/ptrace.h @@ -0,0 +1,70 @@ +#ifndef _ASMAXP_PTRACE_H +#define _ASMAXP_PTRACE_H + + +/* + * This struct defines the way the registers are stored on the + * kernel stack during a system call or other kernel entry + * + * NOTE! I want to minimize the overhead of system calls, so this + * struct has as little information as possible. I does not have + * + * - floating point regs: the kernel doesn't change those + * - r9-15: saved by the C compiler + * + * This makes "fork()" and "exec()" a bit more complex, but should + * give us low system call latency. + */ + +struct pt_regs { + unsigned long r0; + unsigned long r1; + unsigned long r2; + unsigned long r3; + unsigned long r4; + unsigned long r5; + unsigned long r6; + unsigned long r7; + unsigned long r8; + unsigned long r19; + unsigned long r20; + unsigned long r21; + unsigned long r22; + unsigned long r23; + unsigned long r24; + unsigned long r25; + unsigned long r26; + unsigned long r27; + unsigned long r28; + unsigned long hae; +/* These are saved by PAL-code: */ + unsigned long ps; + unsigned long pc; + unsigned long gp; + unsigned long r16; + unsigned long r17; + unsigned long r18; +}; + +/* + * This is the extended stack used by signal handlers and the context + * switcher: it's pushed after the normal "struct pt_regs". + */ +struct switch_stack { + unsigned long r9; + unsigned long r10; + unsigned long r11; + unsigned long r12; + unsigned long r13; + unsigned long r14; + unsigned long r15; + unsigned long r26; + unsigned long fp[32]; +}; + +#ifdef __KERNEL__ +#define user_mode(regs) ((regs)->ps & 8) +extern void show_regs(struct pt_regs *); +#endif + +#endif diff --git a/include/asm-alpha/resource.h b/include/asm-alpha/resource.h new file mode 100644 index 000000000..daf5c4037 --- /dev/null +++ b/include/asm-alpha/resource.h @@ -0,0 +1,24 @@ +#ifndef _ALPHA_RESOURCE_H +#define _ALPHA_RESOURCE_H + +/* + * 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 */ +#define RLIMIT_NOFILE 6 /* max number of open files */ +#define RLIMIT_AS 7 /* address space limit(?) */ +#define RLIMIT_NPROC 8 /* max number of processes */ + +#ifdef notdef +#define RLIMIT_MEMLOCK 9 /* max locked-in-memory address space*/ +#endif + +#define RLIM_NLIMITS 9 + +#endif diff --git a/include/asm-alpha/segment.h b/include/asm-alpha/segment.h index 763a66c16..ed3770607 100644 --- a/include/asm-alpha/segment.h +++ b/include/asm-alpha/segment.h @@ -3,6 +3,59 @@ #include <linux/string.h> +/* + * Uh, these should become the main single-value transfer routines.. + * They automatically use the right size if we just have the right + * pointer type.. + */ +#define put_user(x,ptr) __put_user((unsigned long)(x),(ptr),sizeof(*(ptr))) +#define get_user(ptr) __get_user((ptr),sizeof(*(ptr))) + +/* + * This is a silly but good way to make sure that + * the __put_user function is indeed always optimized, + * and that we use the correct sizes.. + */ +extern int bad_user_access_length(void); + +/* I should make this use unaligned transfers etc.. */ +static inline void __put_user(unsigned long x, void * y, int size) +{ + switch (size) { + case 1: + *(char *) y = x; + break; + case 2: + *(short *) y = x; + break; + case 4: + *(int *) y = x; + break; + case 8: + *(long *) y = x; + break; + default: + bad_user_access_length(); + } +} + +/* I should make this use unaligned transfers etc.. */ +static inline unsigned long __get_user(void * y, int size) +{ + switch (size) { + case 1: + return *(unsigned char *) y; + case 2: + return *(unsigned short *) y; + case 4: + return *(unsigned int *) y; + case 8: + return *(unsigned long *) y; + default: + return bad_user_access_length(); + } +} + static inline unsigned char get_user_byte(const char * addr) { return *addr; @@ -63,9 +116,19 @@ static inline void put_user_quad(unsigned long val,long * addr) #define memcpy_tofs(to, from, n) memcpy((to),(from),(n)) +/* + * For segmented architectures, these are used to specify which segment + * to use for the above functions. + * + * The alpha is not segmented, so these are just dummies. + */ + +#define KERNEL_DS 0 +#define USER_DS 1 + static inline unsigned long get_fs(void) { - return 0; + return 1; } static inline unsigned long get_ds(void) diff --git a/include/asm-alpha/signal.h b/include/asm-alpha/signal.h new file mode 100644 index 000000000..83f3d80ee --- /dev/null +++ b/include/asm-alpha/signal.h @@ -0,0 +1,114 @@ +#ifndef _ASMAXP_SIGNAL_H +#define _ASMAXP_SIGNAL_H + +typedef unsigned long sigset_t; /* at least 32 bits */ + +#define _NSIG 32 +#define NSIG _NSIG + +/* + * Linux/AXP has different signal numbers that Linux/i386: I'm trying + * to make it OSF/1 binary compatible, at least for normal binaries. + */ +#define SIGHUP 1 +#define SIGINT 2 +#define SIGQUIT 3 +#define SIGILL 4 +#define SIGTRAP 5 +#define SIGABRT 6 +#define SIGEMT 7 +#define SIGFPE 8 +#define SIGKILL 9 +#define SIGBUS 10 +#define SIGSEGV 11 +#define SIGSYS 12 +#define SIGPIPE 13 +#define SIGALRM 14 +#define SIGTERM 15 +#define SIGURG 16 +#define SIGSTOP 17 +#define SIGTSTP 18 +#define SIGCONT 19 +#define SIGCHLD 20 +#define SIGTTIN 21 +#define SIGTTOU 22 +#define SIGIO 23 +#define SIGXCPU 24 +#define SIGXFSZ 25 +#define SIGVTALRM 26 +#define SIGPROF 27 +#define SIGWINCH 28 +#define SIGINFO 29 +#define SIGUSR1 30 +#define SIGUSR2 31 + +#define SIGPOLL SIGIO + +/* + * 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 0x00000004 + +#define SA_STACK 0x00000001 +#define SA_RESTART 0x00000002 +#define SA_INTERRUPT 0x20000000 +#define SA_NOMASK 0x00000008 +#define SA_ONESHOT 0x00000010 + +#define SIG_BLOCK 1 /* for blocking signals */ +#define SIG_UNBLOCK 2 /* for unblocking signals */ +#define SIG_SETMASK 3 /* 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; + unsigned int sa_flags; +}; + +#ifdef __KERNEL__ + +struct sigcontext_struct { + /* + * what should we have here? I'd probably better use the same + * stack layout as OSF/1, just in case we ever want to try + * running their binaries.. + * + * This is the basic layout, but I don't know if we'll ever + * actually fill in all the values.. + */ + long sc_onstack; + long sc_mask; + long sc_pc; + long sc_ps; + long sc_regs[32]; + long sc_ownedfp; + long sc_fpregs[32]; + unsigned long sc_fpcr; + unsigned long sc_fp_control; + unsigned long sc_reserved1, sc_reserved2; + unsigned long sc_ssize; + char * sc_sbase; + unsigned long sc_traparg_a0; + unsigned long sc_traparg_a1; + unsigned long sc_traparg_a2; + unsigned long sc_fp_trap_pc; + unsigned long sc_fp_trigger_sum; + unsigned long sc_fp_trigger_inst; + unsigned long sc_retcode[2]; +}; + +#endif + +#endif diff --git a/include/asm-alpha/stat.h b/include/asm-alpha/stat.h new file mode 100644 index 000000000..275383002 --- /dev/null +++ b/include/asm-alpha/stat.h @@ -0,0 +1,40 @@ +#ifndef _ALPHA_STAT_H +#define _ALPHA_STAT_H + +struct old_stat { + unsigned int st_dev; + unsigned int st_ino; + unsigned int st_mode; + unsigned int st_nlink; + unsigned int st_uid; + unsigned int st_gid; + unsigned int st_rdev; + long st_size; + unsigned int st_atime, st_res1; + unsigned int st_mtime, st_res2; + unsigned int st_ctime, st_res3; + unsigned int st_blkize; + int st_blocks; + unsigned int st_flags; + unsigned int st_gen; +}; + +struct new_stat { + unsigned int st_dev; + unsigned int st_ino; + unsigned int st_mode; + unsigned int st_nlink; + unsigned int st_uid; + unsigned int st_gid; + unsigned int st_rdev; + long st_size; + unsigned int st_atime, st_res1; + unsigned int st_mtime, st_res2; + unsigned int st_ctime, st_res3; + unsigned int st_blksize; + int st_blocks; + unsigned int st_flags; + unsigned int st_gen; +}; + +#endif diff --git a/include/asm-alpha/statfs.h b/include/asm-alpha/statfs.h new file mode 100644 index 000000000..b2cd89057 --- /dev/null +++ b/include/asm-alpha/statfs.h @@ -0,0 +1,27 @@ +#ifndef _ALPHA_STATFS_H +#define _ALPHA_STATFS_H + +typedef struct { + int val[2]; +} fsid_t; + +/* + * The OSF/1 statfs structure is much larger, but this should + * match the beginning, at least. + */ +struct statfs { + short f_type; + short f_flags; + int f_fsize; + int f_bsize; + int f_blocks; + int f_bfree; + int f_bavail; + int f_files; + int f_ffree; + fsid_t f_fsid; + /* linux-specific entries start here.. */ + int f_namelen; +}; + +#endif diff --git a/include/asm-alpha/string.h b/include/asm-alpha/string.h index e90d55003..1c6fe64ec 100644 --- a/include/asm-alpha/string.h +++ b/include/asm-alpha/string.h @@ -1,19 +1,15 @@ #ifndef __ALPHA_STRING_H #define __ALPHA_STRING_H -/* This doesn't actually work that well for unaligned stuff ;-p */ -extern inline void * memcpy(void * to, const void * from, size_t n) -{ - const unsigned long * f = from; - unsigned long * t = to; - int size = n; +extern void * __constant_c_memset(void *, unsigned long, long); +extern void * __memset(void *, char, size_t); +extern void * __memcpy(void *, const void *, size_t); - for (;;) { - size -= 8; - if (size < 0) - return to; - *(t++) = *(f++); - } -} +#define memset(s, c, count) \ +(__builtin_constant_p(c) ? \ + __constant_c_memset((s),(0x01010101UL*(unsigned char)c),(count)) : \ + __memset((s),(c),(count))) + +#define memcpy(d,s,count) __memcpy((d),(s),(count)) #endif diff --git a/include/asm-alpha/system.h b/include/asm-alpha/system.h index 54a83bdb3..cbed1ded7 100644 --- a/include/asm-alpha/system.h +++ b/include/asm-alpha/system.h @@ -10,12 +10,22 @@ * We leave one page for the initial stack page, and one page for * the initial process structure. Also, the console eats 3 MB for * the initial bootloader (one of which we can reclaim later). - * So the initial load address is 0xfffffc0000304000UL + * With a few other pages for various reasons, we'll use an initial + * load address of 0xfffffc0000310000UL */ -#define INIT_PCB 0xfffffc0000300000 +#define BOOT_PCB 0x20000000 +#define BOOT_ADDR 0x20000000 +#define BOOT_SIZE (16*1024) + +#define KERNEL_START 0xfffffc0000300000 +#define SWAPPER_PGD 0xfffffc0000300000 #define INIT_STACK 0xfffffc0000302000 -#define START_ADDR 0xfffffc0000304000 -#define START_SIZE (32*1024) +#define EMPTY_PGT 0xfffffc0000304000 +#define EMPTY_PGE 0xfffffc0000308000 +#define ZERO_PGE 0xfffffc000030A000 + +#define START_ADDR 0xfffffc0000310000 +#define START_SIZE (2*1024*1024) /* * Common PAL-code @@ -43,7 +53,8 @@ /* * OSF specific PAL-code */ -#define PAL_mtpr_mces 17 +#define PAL_rdmces 16 +#define PAL_wrmces 17 #define PAL_wrfen 43 #define PAL_wrvptptr 45 #define PAL_jtopal 46 @@ -62,19 +73,95 @@ #define PAL_rtsys 61 #define PAL_rti 63 -#ifndef mb -#define mb() __asm__ __volatile__("mb": : :"memory") -#endif +#ifndef __ASSEMBLY__ + +extern void wrent(void *, unsigned long); +extern void wrkgp(unsigned long); +extern void wrusp(unsigned long); +extern unsigned long rdusp(void); + +#define halt() __asm__ __volatile__(".long 0"); + +extern void alpha_switch_to(unsigned long pctxp); + +#define switch_to(p) do { \ + current = p; \ + alpha_switch_to((unsigned long) &(p)->tss - 0xfffffc0000000000); \ +} while (0) + +#define mb() \ +__asm__ __volatile__("mb": : :"memory") + +#define draina() \ +__asm__ __volatile__ ("call_pal %0" : : "i" (PAL_draina) : "memory") + +#define getipl() \ +({ unsigned long __old_ipl; \ +__asm__ __volatile__( \ + "call_pal 54\n\t" \ + "bis $0,$0,%0" \ + : "=r" (__old_ipl) \ + : : "$0", "$1", "$16", "$22", "$23", "$24", "$25"); \ +__old_ipl; }) + +#define setipl(__new_ipl) \ +__asm__ __volatile__( \ + "bis %0,%0,$16\n\t" \ + "call_pal 53" \ + : : "r" (__new_ipl) \ + : "$0", "$1", "$16", "$22", "$23", "$24", "$25") #define swpipl(__new_ipl) \ ({ unsigned long __old_ipl; \ __asm__ __volatile__( \ "bis %1,%1,$16\n\t" \ - ".long 53\n\t" \ + "call_pal 53\n\t" \ "bis $0,$0,%0" \ : "=r" (__old_ipl) \ : "r" (__new_ipl) \ : "$0", "$1", "$16", "$22", "$23", "$24", "$25"); \ __old_ipl; }) +#define cli() setipl(7) +#define sti() setipl(0) +#define save_flags(flags) do { flags = getipl(); } while (0) +#define restore_flags(flags) setipl(flags) + +extern inline unsigned long xchg_u32(int * m, unsigned long val) +{ + unsigned long dummy, dummy2; + + __asm__ __volatile__( + "\n1:\t" + "ldl_l %0,%1\n\t" + "bis %2,%2,%3\n\t" + "stl_c %3,%1\n\t" + "beq %3,1b\n" + : "=r" (val), "=m" (*m), "=r" (dummy), "=r" (dummy2) + : "1" (*m), "2" (val)); + return val; +} + +extern inline unsigned long xchg_u64(long * m, unsigned long val) +{ + unsigned long dummy, dummy2; + + __asm__ __volatile__( + "\n1:\t" + "ldq_l %0,%1\n\t" + "bis %2,%2,%3\n\t" + "stq_c %3,%1\n\t" + "beq %3,1b\n" + : "=r" (val), "=m" (*m), "=r" (dummy), "=r" (dummy2) + : "1" (*m), "2" (val)); + return val; +} + +extern inline void * xchg_ptr(void *m, void *val) +{ + return (void *) xchg_u64((long *) m, (unsigned long) val); +} + +#endif /* __ASSEMBLY__ */ + #endif diff --git a/include/asm-alpha/termios.h b/include/asm-alpha/termios.h new file mode 100644 index 000000000..4eb45be99 --- /dev/null +++ b/include/asm-alpha/termios.h @@ -0,0 +1,334 @@ +#ifndef _ALPHA_TERMIOS_H +#define _ALPHA_TERMIOS_H + +#include <linux/types.h> + +#include <asm/ioctl.h> + +struct sgttyb { + char sg_ispeed; + char sg_ospeed; + char sg_erase; + char sg_kill; + short sg_flags; +}; + +struct tchars { + char t_intrc; + char t_quitc; + char t_startc; + char t_stopc; + char t_eofc; + char t_brkc; +}; + +struct ltchars { + char t_suspc; + char t_dsuspc; + char t_rprntc; + char t_flushc; + char t_werasc; + char t_lnextc; +}; + +#define FIOCLEX _IO('f', 1) +#define FIONCLEX _IO('f', 2) +#define FIOASYNC _IOW('f', 125, int) +#define FIONBIO _IOW('f', 126, int) +#define FIONREAD _IOR('f', 127, int) +#define TIOCINQ FIONREAD + +#define TIOCGETP _IOR('t', 8, struct sgttyb) +#define TIOCSETP _IOW('t', 9, struct sgttyb) +#define TIOCSETN _IOW('t', 10, struct sgttyb) /* TIOCSETP wo flush */ + +#define TIOCSETC _IOW('t', 17, struct tchars) +#define TIOCGETC _IOR('t', 18, struct tchars) +#define TCGETS _IOR('t', 19, struct termios) +#define TCSETS _IOW('t', 20, struct termios) +#define TCSETSW _IOW('t', 21, struct termios) +#define TCSETSF _IOW('t', 22, struct termios) + +#define TCGETA _IOR('t', 23, struct termio) +#define TCSETA _IOW('t', 24, struct termio) +#define TCSETAW _IOW('t', 25, struct termio) +#define TCSETAF _IOW('t', 28, struct termio) + +#define TCSBRK _IO('t', 29) +#define TCXONC _IO('t', 30) +#define TCFLSH _IO('t', 31) + +#define TIOCSWINSZ _IOW('t', 103, struct winsize) +#define TIOCGWINSZ _IOR('t', 104, struct winsize) + +#define TIOCGLTC _IOR('t', 116, struct ltchars) +#define TIOCSLTC _IOW('t', 117, struct ltchars) +#define TIOCSPGRP _IOW('t', 118, int) +#define TIOCGPGRP _IOR('t', 119, int) + +#define TIOCEXCL 0x540C +#define TIOCNXCL 0x540D +#define TIOCSCTTY 0x540E + +#define TIOCOUTQ 0x5411 +#define TIOCSTI 0x5412 +#define TIOCMGET 0x5415 +#define TIOCMBIS 0x5416 +#define TIOCMBIC 0x5417 +#define TIOCMSET 0x5418 +#define TIOCGSOFTCAR 0x5419 +#define TIOCSSOFTCAR 0x541A +#define TIOCLINUX 0x541C +#define TIOCCONS 0x541D +#define TIOCGSERIAL 0x541E +#define TIOCSSERIAL 0x541F +#define TIOCPKT 0x5420 + +#define TIOCNOTTY 0x5422 +#define TIOCSETD 0x5423 +#define TIOCGETD 0x5424 +#define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ +#define TIOCTTYGSTRUCT 0x5426 /* For debugging only */ + +#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 */ +#define TIOCSERGETMULTI 0x545A /* Get multiport config */ +#define TIOCSERSETMULTI 0x545B /* Set multiport config */ + +/* 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_cc[NCCS]; /* control characters */ + cc_t c_line; /* line discipline (== c_cc[19]) */ + int c_ispeed; /* input speed */ + int c_ospeed; /* output speed */ +}; + +/* c_cc characters */ +#define VEOF 0 +#define VEOL 1 +#define VEOL2 2 +#define VERASE 3 +#define VWERASE 4 +#define VKILL 5 +#define VREPRINT 6 +#define VSWTC 7 +#define VINTR 8 +#define VQUIT 9 +#define VSUSP 10 +#define VSTART 12 +#define VSTOP 13 +#define VLNEXT 14 +#define VDISCARD 15 +#define VTIME 17 +#define VMIN 16 + +/* + * ..and the same for c_cc in the termio structure.. + * Oh, how I love being backwardly compatible. + */ +#define _VINTR 0 +#define _VQUIT 1 +#define _VERASE 2 +#define _VKILL 3 +#define _VEOF 4 +#define _VMIN 4 +#define _VEOL 5 +#define _VTIME 5 +#define _VEOL2 6 +#define _VSWTC 7 + +#ifdef __KERNEL__ +/* 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 "\004\000\000\177\027\025\022\000\003\034\032\000\021\023\026\025\000\001" +#endif + +/* 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 IXON 0001000 +#define IXOFF 0002000 +#define IXANY 0004000 +#define IUCLC 0010000 +#define IMAXBEL 0020000 + +/* c_oflag bits */ +#define OPOST 0000001 +#define ONLCR 0000002 +#define OLCUC 0000004 + +#define OCRNL 0000010 +#define ONOCR 0000020 +#define ONLRET 0000040 + +#define OFILL 00000100 +#define OFDEL 00000200 +#define NLDLY 00001400 +#define NL0 00000000 +#define NL1 00000400 +#define NL2 00001000 +#define NL3 00001400 +#define TABDLY 00006000 +#define TAB0 00000000 +#define TAB1 00002000 +#define TAB2 00004000 +#define TAB3 00006000 +#define CRDLY 00030000 +#define CR0 00000000 +#define CR1 00010000 +#define CR2 00020000 +#define CR3 00030000 +#define FFDLY 00040000 +#define FF0 00000000 +#define FF1 00040000 +#define BSDLY 00100000 +#define BS0 00000000 +#define BS1 00100000 +#define VTDLY 00200000 +#define VT0 00000000 +#define VT1 00200000 +#define XTABS 01000000 /* Hmm.. Linux/i386 considers this part of TABDLY.. */ + +/* c_cflag bit meaning */ +#define CBAUD 0000377 +#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 CBAUDEX 0000020 +#define B57600 00020 +#define B115200 00021 +#define B230400 00022 + +#define CSIZE 00001400 +#define CS5 00000000 +#define CS6 00000400 +#define CS7 00001000 +#define CS8 00001400 + +#define CSTOPB 00002000 +#define CREAD 00004000 +#define PARENB 00010000 +#define PARODD 00020000 +#define HUPCL 00040000 + +#define CLOCAL 00100000 +#define CRTSCTS 020000000000 /* flow control */ + +/* c_lflag bits */ +#define ISIG 0x00000080 +#define ICANON 0x00000100 +#define XCASE 0x00004000 +#define ECHO 0x00000008 +#define ECHOE 0x00000002 +#define ECHOK 0x00000004 +#define ECHONL 0x00000010 +#define NOFLSH 0x80000000 +#define TOSTOP 0x00400000 +#define ECHOCTL 0x00000040 +#define ECHOPRT 0x00000020 +#define ECHOKE 0x00000001 +#define FLUSHO 0x00800000 +#define PENDIN 0x20000000 +#define IEXTEN 0x00000400 + +/* 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/asm-alpha/types.h b/include/asm-alpha/types.h index b532a6641..2654e4b42 100644 --- a/include/asm-alpha/types.h +++ b/include/asm-alpha/types.h @@ -1,6 +1,73 @@ #ifndef _ALPHA_TYPES_H #define _ALPHA_TYPES_H +#ifndef _SIZE_T +#define _SIZE_T +typedef unsigned long size_t; +#endif + +#ifndef _SSIZE_T +#define _SSIZE_T +typedef long ssize_t; +#endif + +#ifndef _PTRDIFF_T +#define _PTRDIFF_T +typedef long ptrdiff_t; +#endif + +#ifndef _TIME_T +#define _TIME_T +typedef long time_t; +#endif + +#ifndef _CLOCK_T +#define _CLOCK_T +typedef long clock_t; +#endif + +typedef int pid_t; +typedef unsigned int uid_t; +typedef unsigned int gid_t; +typedef unsigned int dev_t; +typedef unsigned int ino_t; +typedef unsigned int mode_t; +typedef unsigned int umode_t; +typedef unsigned short nlink_t; +typedef int daddr_t; +typedef long off_t; + +/* + * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the + * header files exported to user space + */ + +typedef __signed__ char __s8; +typedef unsigned char __u8; + +typedef __signed__ short __s16; +typedef unsigned short __u16; + +typedef __signed__ int __s32; +typedef unsigned int __u32; + +/* + * There are 32-bit compilers for the alpha out there.. + */ +#if ((~0UL) == 0xffffffff) + +#if defined(__GNUC__) && !defined(__STRICT_ANSI__) +typedef __signed__ long long __s64; +typedef unsigned long long __u64; +#endif + +#else + +typedef __signed__ long __s64; +typedef unsigned long __u64; + +#endif + /* * These aren't exported outside the kernel to avoid name space clashes */ diff --git a/include/asm-alpha/unaligned.h b/include/asm-alpha/unaligned.h new file mode 100644 index 000000000..071477496 --- /dev/null +++ b/include/asm-alpha/unaligned.h @@ -0,0 +1,112 @@ +#ifndef __ALPHA_UNALIGNED_H +#define __ALPHA_UNALIGNED_H + +/* + * inline functions to do unaligned accesses.. See entUna in traps.c + */ +extern inline unsigned long ldq_u(unsigned long * r11) +{ + unsigned long r1,r2; + __asm__("ldq_u %0,%3\n\t" + "ldq_u %1,%4\n\t" + "extql %0,%2,%0\n\t" + "extqh %1,%2,%1\n\t" + "bis %1,%0,%0" + :"=&r" (r1), "=&r" (r2) + :"r" (r11), + "m" (*r11), + "m" (*(unsigned long *)(7+(char *) r11))); + return r1; +} + +extern inline unsigned long ldl_u(unsigned int * r11) +{ + unsigned long r1,r2; + __asm__("ldq_u %0,%3\n\t" + "ldq_u %1,%4\n\t" + "extll %0,%2,%0\n\t" + "extlh %1,%2,%1\n\t" + "bis %1,%0,%0" + :"=&r" (r1), "=&r" (r2) + :"r" (r11), + "m" (*r11), + "m" (*(unsigned long *)(3+(char *) r11))); + return r1; +} + +extern inline unsigned long ldw_u(unsigned short * r11) +{ + unsigned long r1,r2; + __asm__("ldq_u %0,%3\n\t" + "ldq_u %1,%4\n\t" + "extwl %0,%2,%0\n\t" + "extwh %1,%2,%1\n\t" + "bis %1,%0,%0" + :"=&r" (r1), "=&r" (r2) + :"r" (r11), + "m" (*r11), + "m" (*(unsigned long *)(1+(char *) r11))); + return r1; +} + +extern inline void stq_u(unsigned long r5, unsigned long * r11) +{ + unsigned long r1,r2,r3,r4; + + __asm__("ldq_u %3,%1\n\t" + "ldq_u %2,%0\n\t" + "insqh %6,%7,%5\n\t" + "insql %6,%7,%4\n\t" + "mskqh %3,%7,%3\n\t" + "mskql %2,%7,%2\n\t" + "bis %3,%5,%3\n\t" + "bis %2,%4,%2\n\t" + "stq_u %3,%1\n\t" + "stq_u %2,%0" + :"=m" (*r11), + "=m" (*(unsigned long *)(7+(char *) r11)), + "=&r" (r1), "=&r" (r2), "=&r" (r3), "=&r" (r4) + :"r" (r5), "r" (r11)); +} + +extern inline void stl_u(unsigned long r5, unsigned int * r11) +{ + unsigned long r1,r2,r3,r4; + + __asm__("ldq_u %3,%1\n\t" + "ldq_u %2,%0\n\t" + "inslh %6,%7,%5\n\t" + "insll %6,%7,%4\n\t" + "msklh %3,%7,%3\n\t" + "mskll %2,%7,%2\n\t" + "bis %3,%5,%3\n\t" + "bis %2,%4,%2\n\t" + "stq_u %3,%1\n\t" + "stq_u %2,%0" + :"=m" (*r11), + "=m" (*(unsigned long *)(3+(char *) r11)), + "=&r" (r1), "=&r" (r2), "=&r" (r3), "=&r" (r4) + :"r" (r5), "r" (r11)); +} + +extern inline void stw_u(unsigned long r5, unsigned short * r11) +{ + unsigned long r1,r2,r3,r4; + + __asm__("ldq_u %3,%1\n\t" + "ldq_u %2,%0\n\t" + "inswh %6,%7,%5\n\t" + "inswl %6,%7,%4\n\t" + "mskwh %3,%7,%3\n\t" + "mskwl %2,%7,%2\n\t" + "bis %3,%5,%3\n\t" + "bis %2,%4,%2\n\t" + "stq_u %3,%1\n\t" + "stq_u %2,%0" + :"=m" (*r11), + "=m" (*(unsigned long *)(1+(char *) r11)), + "=&r" (r1), "=&r" (r2), "=&r" (r3), "=&r" (r4) + :"r" (r5), "r" (r11)); +} + +#endif diff --git a/include/asm-alpha/unistd.h b/include/asm-alpha/unistd.h index 6ee2843fa..11a940a57 100644 --- a/include/asm-alpha/unistd.h +++ b/include/asm-alpha/unistd.h @@ -12,83 +12,138 @@ #define _syscall0(type,name) \ type name(void) \ { \ -long __res; \ -__asm__ __volatile__ (".long 131" \ - : "=a" (__res) \ - : "0" (__NR_##name)); \ -if (__res >= 0) \ - return (type) __res; \ -errno = -__res; \ -return -1; \ + return (type) -1; \ } #define _syscall1(type,name,type1,arg1) \ type name(type1 arg1) \ { \ -long __res; \ -__asm__ __volatile__ (".long 131" \ - : "=a" (__res) \ - : "0" (__NR_##name),"b" ((long)(arg1))); \ -if (__res >= 0) \ - return (type) __res; \ -errno = -__res; \ -return -1; \ + return (type) -1; \ } #define _syscall2(type,name,type1,arg1,type2,arg2) \ type name(type1 arg1,type2 arg2) \ { \ -long __res; \ -__asm__ __volatile__ (".long 131" \ - : "=a" (__res) \ - : "0" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2))); \ -if (__res >= 0) \ - return (type) __res; \ -errno = -__res; \ -return -1; \ + return (type) -1; \ } #define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \ type name(type1 arg1,type2 arg2,type3 arg3) \ { \ -long __res; \ -__asm__ __volatile__ (".long 131" \ - : "=a" (__res) \ - : "0" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2)), \ - "d" ((long)(arg3))); \ -if (__res>=0) \ - return (type) __res; \ -errno=-__res; \ -return -1; \ + return (type) -1; \ } #define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \ type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \ { \ -long __res; \ -__asm__ __volatile__ (".long 131" \ - : "=a" (__res) \ - : "0" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2)), \ - "d" ((long)(arg3)),"S" ((long)(arg4))); \ -if (__res>=0) \ - return (type) __res; \ -errno=-__res; \ -return -1; \ + return (type) -1; \ } #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ type5,arg5) \ type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \ { \ -long __res; \ -__asm__ __volatile__ (".long 131" \ - : "=a" (__res) \ - : "0" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2)), \ - "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5))); \ -if (__res>=0) \ - return (type) __res; \ -errno=-__res; \ -return -1; \ + return (type) -1; \ } +#ifdef __KERNEL_SYSCALLS__ + +extern unsigned long kernel_fork(void); +static inline unsigned long fork(void) +{ + return kernel_fork(); +} + +extern void sys_idle(void); +static inline void idle(void) +{ + sys_idle(); +} + +extern int sys_setup(void); +static inline int setup(void) +{ + return sys_setup(); +} + +extern int sys_open(const char *, int, int); +static inline int open(const char * name, int mode, int flags) +{ + return sys_open(name, mode, flags); +} + +extern int sys_dup(int); +static inline int dup(int fd) +{ + return sys_dup(fd); +} + +static inline int close(int fd) +{ + return sys_close(fd); +} + +extern int sys_exit(int); +static inline int _exit(int value) +{ + return sys_exit(value); +} + +#define exit(x) _exit(x) + +extern int sys_write(int, const char *, int); +static inline int write(int fd, const char * buf, int nr) +{ + return sys_write(fd, buf, nr); +} + +extern int sys_read(int, char *, int); +static inline int read(int fd, char * buf, int nr) +{ + return sys_read(fd, buf, nr); +} + +extern int do_execve(char *, char **, char **, struct pt_regs *); +extern void ret_from_sys_call(void); +static inline int execve(char * file, char ** argvp, char ** envp) +{ + int i; + struct pt_regs regs; + + memset(®s, 0, sizeof(regs)); + i = do_execve(file, argvp, envp, ®s); + if (!i) { + __asm__ __volatile__("bis %0,%0,$30\n\t" + "bis %1,%1,$26\n\t" + "ret $31,($26),1\n\t" + : :"r" (®s), "r" (ret_from_sys_call)); + } + return -1; +} + +extern int sys_setsid(void); +static inline int setsid(void) +{ + return sys_setsid(); +} + +extern int sys_sync(void); +static inline int sync(void) +{ + return sys_sync(); +} + +extern int sys_waitpid(int, int *, int); +static inline pid_t waitpid(int pid, int * wait_stat, int flags) +{ + return sys_waitpid(pid,wait_stat,flags); +} + +static inline pid_t wait(int * wait_stat) +{ + return waitpid(-1,wait_stat,0); +} + +#endif + #endif /* _ALPHA_UNISTD_H */ diff --git a/include/asm-generic/bitops.h b/include/asm-generic/bitops.h deleted file mode 100644 index 7b0350da1..000000000 --- a/include/asm-generic/bitops.h +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef _ASM_GENERIC_BITOPS_H -#define _ASM_GENERIC_BITOPS_H - -/* - * For the benefit of those who are trying to port Linux to another - * architecture, here are some C-language equivalents. You should - * recode these in the native assembly language, if at all possible. - * To guarantee atomicity, these routines call cli() and sti() to - * disable interrupts while they operate. (You have to provide inline - * routines to cli() and sti().) - * - * Also note, these routines assume that you have 32 bit integers. - * You will have to change this if you are trying to port Linux to the - * Alpha architecture or to a Cray. :-) - * - * C language equivalents written by Theodore Ts'o, 9/26/92 - */ - -#ifdef __USE_GENERIC_set_bit -extern __inline__ int set_bit(int nr, void * addr) -{ - int mask, retval; - int *a = addr; - - a += nr >> 5; - mask = 1 << (nr & 0x1f); - cli(); - retval = (mask & *a) != 0; - *a |= mask; - sti(); - return retval; -} -#endif - -#ifdef __USE_GENERIC_clear_bit -extern __inline__ int clear_bit(int nr, void * addr) -{ - int mask, retval; - int *a = addr; - - a += nr >> 5; - mask = 1 << (nr & 0x1f); - cli(); - retval = (mask & *a) != 0; - *a &= ~mask; - sti(); - return retval; -} -#endif - -#ifdef __USE_GENERIC_test_bit -extern __inline__ int test_bit(int nr, void * addr) -{ - int mask; - int *a = addr; - - a += nr >> 5; - mask = 1 << (nr & 0x1f); - return ((mask & *a) != 0); -} -#endif - -#ifdef __USE_GENERIC_find_first_zero_bit -#error "Generic find_first_zero_bit() not written yet." -#endif - -#ifdef __USE_GENERIC_find_next_zero_bit -#error "Generic find_next_zero_bit() not written yet." -#endif - -#endif /* _ASM_GENERIC_BITOPS_H */ diff --git a/include/asm-generic/string.h b/include/asm-generic/string.h deleted file mode 100644 index c9cf8b483..000000000 --- a/include/asm-generic/string.h +++ /dev/null @@ -1,213 +0,0 @@ -/* - * include/asm-generic/string.h - * - * This file is subject to the terms and conditions of the GNU General Public - * License. See the file "COPYING" in the main directory of this archive - * for more details. - */ - -#ifndef _ASM_GENERIC_STRING_H_ -#define _ASM_GENERIC_STRING_H_ - -/* - * Portable string functions. These are not complete: - * memcpy() and memmove() are still missing. - */ - -#ifdef __USE_PORTABLE_strcpy -extern inline char * strcpy(char * dest,const char *src) -{ - char *xdest = dest; - - while(*dest++ = *src++); - - return xdest; -} -#endif - -#ifdef __USE_PORTABLE_strncpy -extern inline char * strncpy(char * dest,const char *src,size_t count) -{ - char *xdest = dest; - - while((*dest++ = *src++) && --count); - - return dest; -} -#endif - -#ifdef __USE_PORTABLE_strcat -extern inline char * strcat(char * dest, const char * src) -{ - char *tmp = dest; - - while (*dest) - dest++; - while ((*dest++ = *src++)) - ; - - return tmp; -} -#endif - -#ifdef __USE_PORTABLE_strncat -extern inline char * strncat(char *dest, const char *src, size_t count) -{ - char *tmp = dest; - - if (count) { - while (*dest) - dest++; - while ((*dest++ = *src++)) { - if (--count == 0) - break; - } - } - - return tmp; -} -#endif - -#ifdef __USE_PORTABLE_strcmp -extern int strcmp(const char * cs,const char * ct) -{ - register char __res; - - while(1) { - if(__res = *cs - *ct++ && *cs++) - break; - } - - return __res; -} -#endif - -#ifdef __USE_PORTABLE_strncmp -extern inline int strncmp(const char * cs,const char * ct,size_t count) -{ - register char __res; - - while(count) { - if(__res = *cs - *ct++ || !*cs++) - break; - count--; - } - - return __res; -} -#endif - -#ifdef __USE_PORTABLE_strchr -extern inline char * strchr(const char * s,char c) -{ - const char ch = c; - - for(; *s != ch; ++s) - if (*s == '\0') - return( NULL ); - return( (char *) s); -} -#endif - -#ifdef __USE_PORTABLE_strlen -extern inline size_t strlen(const char * s) -{ - const char *sc; - for (sc = s; *sc != '\0'; ++sc) ; - return(sc - s); -} -#endif - -#ifdef __USE_PORTABLE_strspn -extern inline size_t strspn(const char *s, const char *accept) -{ - const char *p; - const char *a; - size_t count = 0; - - for (p = s; *p != '\0'; ++p) - { - for (a = accept; *a != '\0'; ++a) - if (*p == *a) - break; - if (*a == '\0') - return count; - else - ++count; - } - - return count; -} -#endif - -#ifdef __USE_PORTABLE_strpbrk -extern inline char * strpbrk(const char * cs,const char * ct) -{ - const char *sc1,*sc2; - - for( sc1 = cs; *sc1 != '\0'; ++sc1) - for( sc2 = ct; *sc2 != '\0'; ++sc2) - if (*sc1 == *sc2) - return((char *) sc1); - return( NULL ); -} -#endif - -#ifdef __USE_PORTABLE_strtok - -extern char * ___strtok; - -extern inline char * strtok(char * s,const char * ct) -{ - char *sbegin, *send; - - sbegin = s ? s : ___strtok; - if (!sbegin) { - return NULL; - } - sbegin += strspn(sbegin,ct); - if (*sbegin == '\0') { - ___strtok = NULL; - return( NULL ); - } - send = strpbrk( sbegin, ct); - if (send && *send != '\0') - *send++ = '\0'; - ___strtok = send; - return (sbegin); -} -#endif - -#ifdef __USE_PORTABLE_memset -extern inline void * memset(void * s,char c,size_t count) -{ - void *xs = s; - - while(n--) - *s++ = c; - - return xs; -} -#endif - -#ifdef __USE_PORTABLE_memcpy -#error "Portable memcpy() not implemented yet" -#endif - -#ifdef __USE_PORTABLE_memmove -#error "Portable memmove() not implemented yet" -#endif - -#ifdef __USE_PORTABLE_memcmp -extern inline int memcmp(const void * cs,const void * ct,size_t count) -{ - const unsigned char *su1, *su2; - - for( su1 = cs, su2 = ct; 0 < count; ++su1, ++su2, count--) - if (*su1 != *su2) - return((*su1 < *su2) ? -1 : +1); - return(0); -} -#endif - -#endif /* _ASM_GENERIC_STRING_H_ */ diff --git a/include/asm-i386/bitops.h b/include/asm-i386/bitops.h index 36b0bedc0..ee339bd64 100644 --- a/include/asm-i386/bitops.h +++ b/include/asm-i386/bitops.h @@ -132,18 +132,4 @@ extern inline unsigned long ffz(unsigned long word) return word; } -/* - * ffoz = Find First One in word and set to Zero. Undefined if no one exists, - * so code should check against 0UL first.. - */ -extern inline unsigned long ffzc(unsigned long word) -{ - __asm__("bsf %2,%1\n\t" - "btrl %1,%0" - : "=m" (current->signal),"=r" (signr) - : "1" (signr)); - - return word; -} - #endif /* _I386_BITOPS_H */ diff --git a/include/asm-i386/bugs.h b/include/asm-i386/bugs.h new file mode 100644 index 000000000..2d40c0d9b --- /dev/null +++ b/include/asm-i386/bugs.h @@ -0,0 +1,116 @@ +/* + * include/asm-i386/bugs.h + * + * Copyright (C) 1994 Linus Torvalds + */ + +/* + * This is included by init/main.c to check for architecture-dependent bugs. + * + * Needs: + * void check_bugs(void); + */ + +#define CONFIG_BUGi386 + +static void no_halt(char *s, int *ints) +{ + hlt_works_ok = 0; +} + +static void no_387(char *s, int *ints) +{ + hard_math = 0; + __asm__("movl %%cr0,%%eax\n\t" + "orl $0xE,%%eax\n\t" + "movl %%eax,%%cr0\n\t" : : : "ax"); +} + +static char fpu_error = 0; + +static void copro_timeout(void) +{ + fpu_error = 1; + timer_table[COPRO_TIMER].expires = jiffies+100; + timer_active |= 1<<COPRO_TIMER; + printk("387 failed: trying to reset\n"); + send_sig(SIGFPE, last_task_used_math, 1); + outb_p(0,0xf1); + outb_p(0,0xf0); +} + +static void check_fpu(void) +{ + static double x = 4195835.0; + static double y = 3145727.0; + unsigned short control_word; + + if (!hard_math) { +#ifndef CONFIG_MATH_EMULATION + printk("No coprocessor found and no math emulation present.\n"); + printk("Giving up.\n"); + for (;;) ; +#endif + return; + } + /* + * check if exception 16 works correctly.. This is truly evil + * code: it disables the high 8 interrupts to make sure that + * the irq13 doesn't happen. But as this will lead to a lockup + * if no exception16 arrives, it depends on the fact that the + * high 8 interrupts will be re-enabled by the next timer tick. + * So the irq13 will happen eventually, but the exception 16 + * should get there first.. + */ + printk("Checking 386/387 coupling... "); + timer_table[COPRO_TIMER].expires = jiffies+50; + timer_table[COPRO_TIMER].fn = copro_timeout; + timer_active |= 1<<COPRO_TIMER; + __asm__("clts ; fninit ; fnstcw %0 ; fwait":"=m" (*&control_word)); + control_word &= 0xffc0; + __asm__("fldcw %0 ; fwait": :"m" (*&control_word)); + outb_p(inb_p(0x21) | (1 << 2), 0x21); + __asm__("fldz ; fld1 ; fdiv %st,%st(1) ; fwait"); + timer_active &= ~(1<<COPRO_TIMER); + if (fpu_error) + return; + if (!ignore_irq13) { + printk("Ok, fpu using old IRQ13 error reporting\n"); + return; + } + __asm__("fninit\n\t" + "fldl %1\n\t" + "fdivl %2\n\t" + "fmull %2\n\t" + "fldl %1\n\t" + "fsubp %%st,%%st(1)\n\t" + "fistpl %0\n\t" + "fwait\n\t" + "fninit" + : "=m" (*&fdiv_bug) + : "m" (*&x), "m" (*&y)); + if (!fdiv_bug) { + printk("Ok, fpu using exception 16 error reporting.\n"); + return; + + } + printk("Hmm, FDIV bug i%c86 system\n", '0'+x86); +} + +static void check_hlt(void) +{ + printk("Checking 'hlt' instruction... "); + if (!hlt_works_ok) { + printk("disabled\n"); + return; + } + __asm__ __volatile__("hlt ; hlt ; hlt ; hlt"); + printk("Ok.\n"); +} + +static void check_bugs(void) +{ + check_fpu(); + check_hlt(); + system_utsname.machine[1] = '0' + x86; +} diff --git a/include/asm-i386/byteorder.h b/include/asm-i386/byteorder.h new file mode 100644 index 000000000..03eb42f8e --- /dev/null +++ b/include/asm-i386/byteorder.h @@ -0,0 +1,81 @@ +#ifndef _I386_BYTEORDER_H +#define _I386_BYTEORDER_H + +#undef ntohl +#undef ntohs +#undef htonl +#undef htons + +#ifndef LITTLE_ENDIAN +#define LITTLE_ENDIAN 1234 +#endif + +#ifndef LITTLE_ENDIAN_BITFIELD +#define LITTLE_ENDIAN_BITFIELD +#endif + +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); + +extern unsigned long int __ntohl(unsigned long int); +extern unsigned short int __ntohs(unsigned short int); +extern unsigned long int __constant_ntohl(unsigned long int); +extern unsigned short int __constant_ntohs(unsigned short int); + +extern __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; +} + +#define __constant_ntohl(x) \ + ((unsigned long int)((((unsigned long int)(x) & 0x000000ffU) << 24) | \ + (((unsigned long int)(x) & 0x0000ff00U) << 8) | \ + (((unsigned long int)(x) & 0x00ff0000U) >> 8) | \ + (((unsigned long int)(x) & 0xff000000U) >> 24))) + +extern __inline__ unsigned short int +__ntohs(unsigned short int x) +{ + __asm__("xchgb %b0,%h0" /* swap bytes */ + : "=q" (x) + : "0" (x)); + return x; +} + +#define __constant_ntohs(x) \ + ((unsigned short int)((((unsigned short int)(x) & 0x00ff) << 8) | \ + (((unsigned short int)(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 diff --git a/include/asm-i386/delay.h b/include/asm-i386/delay.h index 7ff5f769c..e408db01b 100644 --- a/include/asm-i386/delay.h +++ b/include/asm-i386/delay.h @@ -32,4 +32,15 @@ extern __inline__ void udelay(unsigned long usecs) __delay(usecs); } +extern __inline__ unsigned long muldiv(unsigned long a, unsigned long b, unsigned long c) +{ + __asm__("mull %1 ; divl %2" + :"=a" (a) + :"d" (b), + "r" (c), + "0" (a) + :"dx"); + return a; +} + #endif /* defined(_I386_DELAY_H) */ diff --git a/include/asm-i386/dma.h b/include/asm-i386/dma.h index 63540f159..e5e3251b2 100644 --- a/include/asm-i386/dma.h +++ b/include/asm-i386/dma.h @@ -70,7 +70,7 @@ #define MAX_DMA_CHANNELS 8 /* The maximum address that we can perform a DMA transfer to on this platform */ -#define MAX_DMA_ADDRESS 0xffffff +#define MAX_DMA_ADDRESS 0x1000000 /* 8237 DMA controllers */ #define IO_DMA1_BASE 0x00 /* 8 bit slave DMA, channels 0..3 */ @@ -264,7 +264,7 @@ static __inline__ int get_dma_residue(unsigned int dmanr) /* These are in kernel/dma.c: */ -extern int request_dma(unsigned int dmanr, char * deviceID); /* reserve a DMA channel */ +extern int request_dma(unsigned int dmanr, char * device_id); /* reserve a DMA channel */ extern void free_dma(unsigned int dmanr); /* release it again */ diff --git a/include/asm-i386/errno.h b/include/asm-i386/errno.h new file mode 100644 index 000000000..4ff8c5c78 --- /dev/null +++ b/include/asm-i386/errno.h @@ -0,0 +1,127 @@ +#ifndef _I386_ERRNO_H +#define _I386_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 */ + +#endif diff --git a/include/asm-i386/fcntl.h b/include/asm-i386/fcntl.h new file mode 100644 index 000000000..0cb8fcdba --- /dev/null +++ b/include/asm-i386/fcntl.h @@ -0,0 +1,64 @@ +#ifndef _I386_FCNTL_H +#define _I386_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 */ + +/* for posix fcntl() and lockf() */ +#define F_RDLCK 0 +#define F_WRLCK 1 +#define F_UNLCK 2 + +/* for old implementation of bsd flock () */ +#define F_EXLCK 4 /* or 3 */ +#define F_SHLCK 8 /* or 4 */ + +/* operations for bsd flock(), also used by the kernel implementation */ +#define LOCK_SH 1 /* shared lock */ +#define LOCK_EX 2 /* exclusive lock */ +#define LOCK_NB 4 /* or'd with one of the above to prevent + blocking */ +#define LOCK_UN 8 /* remove lock */ + +#ifdef __KERNEL__ +#define F_POSIX 1 +#define F_FLOCK 2 +#endif /* __KERNEL__ */ + +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/asm-i386/head.h b/include/asm-i386/head.h deleted file mode 100644 index c77f02bdf..000000000 --- a/include/asm-i386/head.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef _ASM_I386_HEAD_H -#define _ASM_I386_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/asm-i386/in.h b/include/asm-i386/in.h deleted file mode 100644 index 91b2f4d04..000000000 --- a/include/asm-i386/in.h +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef _ASM_I386_IN_H -#define _ASM_I386_IN_H - -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 /* _ASM_I386_IN_H */ diff --git a/include/asm-i386/interrupt.h b/include/asm-i386/interrupt.h deleted file mode 100644 index 30ccb5b15..000000000 --- a/include/asm-i386/interrupt.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef _ASM_I386_INTERRUPT_H -#define _ASM_I386_INTERRUPT_H - -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 /* _ASM_I386_INTERRUPT_H */ diff --git a/include/asm-i386/io.h b/include/asm-i386/io.h index 09c494ce8..4b7163592 100644 --- a/include/asm-i386/io.h +++ b/include/asm-i386/io.h @@ -38,6 +38,28 @@ #endif /* + * Change virtual addresses to physical addresses and vv. + * These are trivial on the 1:1 Linux/i386 mapping (but if we ever + * make the kernel segment mapped at 0, we need to do translation + * on the i386 as well) + */ +extern inline unsigned long virt_to_phys(void * address) +{ + return (unsigned long) address; +} + +extern inline void * phys_to_virt(unsigned long address) +{ + return (void *) address; +} + +/* + * IO bus memory addresses are also 1:1 with the physical address + */ +#define virt_to_bus virt_to_phys +#define bus_to_virt phys_to_virt + +/* * Talk about misusing macros.. */ diff --git a/include/asm-i386/mm.h b/include/asm-i386/mm.h deleted file mode 100644 index 56df7bf23..000000000 --- a/include/asm-i386/mm.h +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef _ASM_I386_MM_H -#define _ASM_I386_MM_H - -#if defined (__KERNEL__) - -#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 invalidate() \ -__asm__ __volatile__("movl %%cr3,%%eax\n\tmovl %%eax,%%cr3": : :"ax") - -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; -} - -/* - * memory.c & swap.c - */ -extern void mem_init(unsigned long low_start_mem, - unsigned long start_mem, unsigned long end_mem); - -#endif /* __KERNEL__ */ - -#endif /* _ASM_I386_MM_H */ diff --git a/include/asm-i386/page.h b/include/asm-i386/page.h index 129848b04..7ab435bbf 100644 --- a/include/asm-i386/page.h +++ b/include/asm-i386/page.h @@ -1,40 +1,69 @@ #ifndef _I386_PAGE_H #define _I386_PAGE_H +/* PAGE_SHIFT determines the page size */ +#define PAGE_SHIFT 12 +#define PAGE_SIZE (1UL << PAGE_SHIFT) +#define PAGE_MASK (~(PAGE_SIZE-1)) + +#ifdef __KERNEL__ + +#define CONFIG_STRICT_MM_TYPECHECKS + +#ifdef CONFIG_STRICT_MM_TYPECHECKS +/* + * These are used to make use of C type-checking.. + */ +typedef struct { unsigned long pte; } pte_t; +typedef struct { unsigned long pmd; } pmd_t; +typedef struct { unsigned long pgd; } pgd_t; +typedef struct { unsigned long pgprot; } pgprot_t; + +#define pte_val(x) ((x).pte) +#define pmd_val(x) ((x).pmd) +#define pgd_val(x) ((x).pgd) +#define pgprot_val(x) ((x).pgprot) + +#define __pte(x) ((pte_t) { (x) } ) +#define __pmd(x) ((pmd_t) { (x) } ) +#define __pgd(x) ((pgd_t) { (x) } ) +#define __pgprot(x) ((pgprot_t) { (x) } ) + +#else +/* + * .. while these make it easier on the compiler + */ +typedef unsigned long pte_t; +typedef unsigned long pmd_t; +typedef unsigned long pgd_t; +typedef unsigned long pgprot_t; + +#define pte_val(x) (x) +#define pmd_val(x) (x) +#define pgd_val(x) (x) +#define pgprot_val(x) (x) + +#define __pte(x) (x) +#define __pmd(x) (x) +#define __pgd(x) (x) +#define __pgprot(x) (x) + +#endif + #define invalidate() \ __asm__ __volatile__("movl %%cr3,%%eax\n\tmovl %%eax,%%cr3": : :"ax") - /* PAGE_SHIFT determines the page size */ -#define PAGE_SHIFT 12 -#define PGDIR_SHIFT 22 -#define PAGE_SIZE (1UL << PAGE_SHIFT) -#define PGDIR_SIZE (1UL << PGDIR_SHIFT) +#define copy_page(from,to) memcpy((void *) to, (void *) from, PAGE_SIZE) -#ifdef __KERNEL__ +/* to align the pointer to the (next) page boundary */ +#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK) + +/* This handles the memory map.. */ +#define PAGE_OFFSET 0 +#define MAP_NR(addr) (((unsigned long)(addr)) >> PAGE_SHIFT) +#define MAP_PAGE_RESERVED (1<<15) - /* number of bits that fit into a memory pointer */ -#define BITS_PER_PTR (8*sizeof(unsigned long)) - /* to mask away the intra-page address bits */ -#define PAGE_MASK (~(PAGE_SIZE-1)) - /* to mask away the intra-page address bits */ -#define PGDIR_MASK (~(PGDIR_SIZE-1)) - /* to align the pointer to the (next) page boundary */ -#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK) - /* to align the pointer to a pointer address */ -#define PTR_MASK (~(sizeof(void*)-1)) - - /* sizeof(void*)==1<<SIZEOF_PTR_LOG2 */ - /* 64-bit machines, beware! SRB. */ -#define SIZEOF_PTR_LOG2 2 - - /* to find an entry in a page-table-directory */ -#define PAGE_DIR_OFFSET(base,address) ((unsigned long*)((base)+\ - ((unsigned long)(address)>>(PAGE_SHIFT-SIZEOF_PTR_LOG2)*2&PTR_MASK&~PAGE_MASK))) - /* to find an entry in a page-table */ -#define PAGE_PTR(address) \ - ((unsigned long)(address)>>(PAGE_SHIFT-SIZEOF_PTR_LOG2)&PTR_MASK&~PAGE_MASK) - /* the no. of pointers that fit on a page */ -#define PTRS_PER_PAGE (PAGE_SIZE/sizeof(void*)) +typedef unsigned short mem_map_t; #endif /* __KERNEL__ */ diff --git a/include/asm-i386/param.h b/include/asm-i386/param.h new file mode 100644 index 000000000..f821b8643 --- /dev/null +++ b/include/asm-i386/param.h @@ -0,0 +1,20 @@ +#ifndef _ASMi386_PARAM_H +#define _ASMi386_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/asm-i386/pgtable.h b/include/asm-i386/pgtable.h new file mode 100644 index 000000000..0099de93a --- /dev/null +++ b/include/asm-i386/pgtable.h @@ -0,0 +1,338 @@ +#ifndef _I386_PGTABLE_H +#define _I386_PGTABLE_H + +/* + * The Linux memory management assumes a three-level page table setup. On + * the i386, we use that, but "fold" the mid level into the top-level page + * table, so that we physically have the same two-level page table as the + * i386 mmu expects. + * + * This file contains the functions and defines necessary to modify and use + * the i386 page table tree. + */ + +/* PMD_SHIFT determines the size of the area a second-level page table can map */ +#define PMD_SHIFT 22 +#define PMD_SIZE (1UL << PMD_SHIFT) +#define PMD_MASK (~(PMD_SIZE-1)) + +/* PGDIR_SHIFT determines what a third-level page table entry can map */ +#define PGDIR_SHIFT 22 +#define PGDIR_SIZE (1UL << PGDIR_SHIFT) +#define PGDIR_MASK (~(PGDIR_SIZE-1)) + +/* + * entries per page directory level: the i386 is two-level, so + * we don't really have any PMD directory physically. + */ +#define PTRS_PER_PTE 1024 +#define PTRS_PER_PMD 1 +#define PTRS_PER_PGD 1024 + +/* Just any arbitrary offset to the start of the vmalloc VM area: the + * current 8MB value just means that there will be a 8MB "hole" after the + * physical memory until the kernel virtual memory starts. That means that + * any out-of-bounds memory accesses will hopefully be caught. + * The vmalloc() routines leaves a hole of 4kB between each vmalloced + * area for the same reason. ;) + */ +#define VMALLOC_OFFSET (8*1024*1024) +#define VMALLOC_START ((high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1)) +#define VMALLOC_VMADDR(x) (TASK_SIZE + (unsigned long)(x)) + +#define _PAGE_PRESENT 0x001 +#define _PAGE_RW 0x002 +#define _PAGE_USER 0x004 +#define _PAGE_PCD 0x010 +#define _PAGE_ACCESSED 0x020 +#define _PAGE_DIRTY 0x040 +#define _PAGE_COW 0x200 /* implemented in software (one of the AVL bits) */ + +#define _PAGE_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED | _PAGE_DIRTY) +#define _PAGE_CHG_MASK (PAGE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY) + +#define PAGE_NONE __pgprot(_PAGE_PRESENT | _PAGE_ACCESSED) +#define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED) +#define PAGE_COPY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED | _PAGE_COW) +#define PAGE_READONLY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED) +#define PAGE_KERNEL __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED) + +/* + * The i386 can't do page protection for execute, and considers that the same are read. + * Also, write permissions imply read permissions. This is the closest we can get.. + */ +#define __P000 PAGE_NONE +#define __P001 PAGE_READONLY +#define __P010 PAGE_COPY +#define __P011 PAGE_COPY +#define __P100 PAGE_READONLY +#define __P101 PAGE_READONLY +#define __P110 PAGE_COPY +#define __P111 PAGE_COPY + +#define __S000 PAGE_NONE +#define __S001 PAGE_READONLY +#define __S010 PAGE_SHARED +#define __S011 PAGE_SHARED +#define __S100 PAGE_READONLY +#define __S101 PAGE_READONLY +#define __S110 PAGE_SHARED +#define __S111 PAGE_SHARED + +/* + * Define this if things work differently on a i386 and a i486: + * it will (on a i486) warn about kernel memory accesses that are + * done without a 'verify_area(VERIFY_WRITE,..)' + */ +#undef CONFIG_TEST_VERIFY_AREA + +/* page table for 0-4MB for everybody */ +extern unsigned long pg0[1024]; +/* zero page used for unitialized stuff */ +extern unsigned long empty_zero_page[1024]; + +/* + * BAD_PAGETABLE is used when we need a bogus page-table, while + * BAD_PAGE is used for a bogus page. + * + * ZERO_PAGE is a global shared page that is always zero: used + * for zero-mapped memory areas etc.. + */ +extern pte_t __bad_page(void); +extern pte_t * __bad_pagetable(void); + +#define BAD_PAGETABLE __bad_pagetable() +#define BAD_PAGE __bad_page() +#define ZERO_PAGE ((unsigned long) empty_zero_page) + +/* number of bits that fit into a memory pointer */ +#define BITS_PER_PTR (8*sizeof(unsigned long)) + +/* to align the pointer to a pointer address */ +#define PTR_MASK (~(sizeof(void*)-1)) + +/* sizeof(void*)==1<<SIZEOF_PTR_LOG2 */ +/* 64-bit machines, beware! SRB. */ +#define SIZEOF_PTR_LOG2 2 + +/* to find an entry in a page-table */ +#define PAGE_PTR(address) \ +((unsigned long)(address)>>(PAGE_SHIFT-SIZEOF_PTR_LOG2)&PTR_MASK&~PAGE_MASK) + +/* to set the page-dir */ +#define SET_PAGE_DIR(tsk,pgdir) \ +do { \ + (tsk)->tss.cr3 = (unsigned long) (pgdir); \ + if ((tsk) == current) \ + __asm__ __volatile__("movl %0,%%cr3": :"a" ((tsk)->tss.cr3)); \ +} while (0) + +extern unsigned long high_memory; + +extern inline int pte_none(pte_t pte) { return !pte_val(pte); } +extern inline int pte_present(pte_t pte) { return pte_val(pte) & _PAGE_PRESENT; } +extern inline int pte_inuse(pte_t *ptep) { return mem_map[MAP_NR(ptep)] != 1; } +extern inline void pte_clear(pte_t *ptep) { pte_val(*ptep) = 0; } +extern inline void pte_reuse(pte_t * ptep) +{ + if (!(mem_map[MAP_NR(ptep)] & MAP_PAGE_RESERVED)) + mem_map[MAP_NR(ptep)]++; +} + +extern inline int pmd_none(pmd_t pmd) { return !pmd_val(pmd); } +extern inline int pmd_bad(pmd_t pmd) { return (pmd_val(pmd) & ~PAGE_MASK) != _PAGE_TABLE || pmd_val(pmd) > high_memory; } +extern inline int pmd_present(pmd_t pmd) { return pmd_val(pmd) & _PAGE_PRESENT; } +extern inline int pmd_inuse(pmd_t *pmdp) { return 0; } +extern inline void pmd_clear(pmd_t * pmdp) { pmd_val(*pmdp) = 0; } +extern inline void pmd_reuse(pmd_t * pmdp) { } + +/* + * The "pgd_xxx()" functions here are trivial for a folded two-level + * setup: the pgd is never bad, and a pmd always exists (as it's folded + * into the pgd entry) + */ +extern inline int pgd_none(pgd_t pgd) { return 0; } +extern inline int pgd_bad(pgd_t pgd) { return 0; } +extern inline int pgd_present(pgd_t pgd) { return 1; } +extern inline int pgd_inuse(pgd_t * pgdp) { return mem_map[MAP_NR(pgdp)] != 1; } +extern inline void pgd_clear(pgd_t * pgdp) { } +extern inline void pgd_reuse(pgd_t * pgdp) +{ + if (!(mem_map[MAP_NR(pgdp)] & MAP_PAGE_RESERVED)) + mem_map[MAP_NR(pgdp)]++; +} + +/* + * The following only work if pte_present() is true. + * Undefined behaviour if not.. + */ +extern inline int pte_read(pte_t pte) { return pte_val(pte) & _PAGE_USER; } +extern inline int pte_write(pte_t pte) { return pte_val(pte) & _PAGE_RW; } +extern inline int pte_exec(pte_t pte) { return pte_val(pte) & _PAGE_USER; } +extern inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRTY; } +extern inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED; } +extern inline int pte_cow(pte_t pte) { return pte_val(pte) & _PAGE_COW; } + +extern inline pte_t pte_wrprotect(pte_t pte) { pte_val(pte) &= ~_PAGE_RW; return pte; } +extern inline pte_t pte_rdprotect(pte_t pte) { pte_val(pte) &= ~_PAGE_USER; return pte; } +extern inline pte_t pte_exprotect(pte_t pte) { pte_val(pte) &= ~_PAGE_USER; return pte; } +extern inline pte_t pte_mkclean(pte_t pte) { pte_val(pte) &= ~_PAGE_DIRTY; return pte; } +extern inline pte_t pte_mkold(pte_t pte) { pte_val(pte) &= ~_PAGE_ACCESSED; return pte; } +extern inline pte_t pte_uncow(pte_t pte) { pte_val(pte) &= ~_PAGE_COW; return pte; } +extern inline pte_t pte_mkwrite(pte_t pte) { pte_val(pte) |= _PAGE_RW; return pte; } +extern inline pte_t pte_mkread(pte_t pte) { pte_val(pte) |= _PAGE_USER; return pte; } +extern inline pte_t pte_mkexec(pte_t pte) { pte_val(pte) |= _PAGE_USER; return pte; } +extern inline pte_t pte_mkdirty(pte_t pte) { pte_val(pte) |= _PAGE_DIRTY; return pte; } +extern inline pte_t pte_mkyoung(pte_t pte) { pte_val(pte) |= _PAGE_ACCESSED; return pte; } +extern inline pte_t pte_mkcow(pte_t pte) { pte_val(pte) |= _PAGE_COW; return pte; } + +/* + * Conversion functions: convert a page and protection to a page entry, + * and a page entry and page directory to the page they refer to. + */ +extern inline pte_t mk_pte(unsigned long page, pgprot_t pgprot) +{ pte_t pte; pte_val(pte) = page | pgprot_val(pgprot); return pte; } + +extern inline pte_t pte_modify(pte_t pte, pgprot_t newprot) +{ pte_val(pte) = (pte_val(pte) & _PAGE_CHG_MASK) | pgprot_val(newprot); return pte; } + +extern inline unsigned long pte_page(pte_t pte) +{ return pte_val(pte) & PAGE_MASK; } + +extern inline unsigned long pmd_page(pmd_t pmd) +{ return pmd_val(pmd) & PAGE_MASK; } + +/* to find an entry in a page-table-directory */ +extern inline pgd_t * pgd_offset(struct task_struct * tsk, unsigned long address) +{ + return (pgd_t *) tsk->tss.cr3 + (address >> PGDIR_SHIFT); +} + +/* Find an entry in the second-level page table.. */ +extern inline pmd_t * pmd_offset(pgd_t * dir, unsigned long address) +{ + return (pmd_t *) dir; +} + +/* Find an entry in the third-level page table.. */ +extern inline pte_t * pte_offset(pmd_t * dir, unsigned long address) +{ + return (pte_t *) pmd_page(*dir) + ((address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)); +} + +/* + * Allocate and free page tables. The xxx_kernel() versions are + * used to allocate a kernel page table - this turns on ASN bits + * if any, and marks the page tables reserved. + */ +extern inline void pte_free_kernel(pte_t * pte) +{ + mem_map[MAP_NR(pte)] = 1; + free_page((unsigned long) pte); +} + +extern inline pte_t * pte_alloc_kernel(pmd_t * pmd, unsigned long address) +{ + address = (address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1); + if (pmd_none(*pmd)) { + pte_t * page = (pte_t *) get_free_page(GFP_KERNEL); + if (pmd_none(*pmd)) { + if (page) { + pmd_val(*pmd) = _PAGE_TABLE | (unsigned long) page; + mem_map[MAP_NR(page)] = MAP_PAGE_RESERVED; + return page + address; + } + pmd_val(*pmd) = _PAGE_TABLE | (unsigned long) BAD_PAGETABLE; + return NULL; + } + free_page((unsigned long) page); + } + if (pmd_bad(*pmd)) { + printk("Bad pmd in pte_alloc: %08lx\n", pmd_val(*pmd)); + pmd_val(*pmd) = _PAGE_TABLE | (unsigned long) BAD_PAGETABLE; + return NULL; + } +printk("pte_alloc_kernel(): %08x\n", pmd_page(*pmd) + address) + return (pte_t *) pmd_page(*pmd) + address; +} + +/* + * allocating and freeing a pmd is trivial: the 1-entry pmd is + * inside the pgd, so has no extra memory associated with it. + */ +extern inline void pmd_free_kernel(pmd_t * pmd) +{ +} + +extern inline pmd_t * pmd_alloc_kernel(pgd_t * pgd, unsigned long address) +{ + return (pmd_t *) pgd; +} + +extern inline void pte_free(pte_t * pte) +{ + free_page((unsigned long) pte); +} + +extern inline pte_t * pte_alloc(pmd_t * pmd, unsigned long address) +{ + address = (address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1); + if (pmd_none(*pmd)) { + pte_t * page = (pte_t *) get_free_page(GFP_KERNEL); + if (pmd_none(*pmd)) { + if (page) { + pmd_val(*pmd) = _PAGE_TABLE | (unsigned long) page; + return page + address; + } + pmd_val(*pmd) = _PAGE_TABLE | (unsigned long) BAD_PAGETABLE; + return NULL; + } + free_page((unsigned long) page); + } + if (pmd_bad(*pmd)) { + printk("Bad pmd in pte_alloc: %08lx\n", pmd_val(*pmd)); + pmd_val(*pmd) = _PAGE_TABLE | (unsigned long) BAD_PAGETABLE; + return NULL; + } + return (pte_t *) pmd_page(*pmd) + address; +} + +/* + * allocating and freeing a pmd is trivial: the 1-entry pmd is + * inside the pgd, so has no extra memory associated with it. + */ +extern inline void pmd_free(pmd_t * pmd) +{ +} + +extern inline pmd_t * pmd_alloc(pgd_t * pgd, unsigned long address) +{ + return (pmd_t *) pgd; +} + +extern inline void pgd_free(pgd_t * pgd) +{ + free_page((unsigned long) pgd); +} + +extern inline pgd_t * pgd_alloc(void) +{ + return (pgd_t *) get_free_page(GFP_KERNEL); +} + +extern pgd_t swapper_pg_dir[1024]; + +/* + * The i386 doesn't have any external MMU info: the kernel page + * tables contain all the necessary information. + */ +extern inline void update_mmu_cache(struct vm_area_struct * vma, + unsigned long address, pte_t pte) +{ +} + +#define SWP_TYPE(entry) (((entry) >> 1) & 0x7f) +#define SWP_OFFSET(entry) ((entry) >> 8) +#define SWP_ENTRY(type,offset) (((type) << 1) | ((offset) << 8)) + +#endif /* _I386_PAGE_H */ diff --git a/include/asm-i386/processor.h b/include/asm-i386/processor.h new file mode 100644 index 000000000..8acef7a19 --- /dev/null +++ b/include/asm-i386/processor.h @@ -0,0 +1,135 @@ +/* + * include/asm-i386/processor.h + * + * Copyright (C) 1994 Linus Torvalds + */ + +#ifndef __ASM_I386_PROCESSOR_H +#define __ASM_I386_PROCESSOR_H + +/* + * System setup and hardware bug flags.. + */ +extern char hard_math; +extern char x86; /* lower 4 bits */ +extern char x86_vendor_id[13]; +extern char x86_model; /* lower 4 bits */ +extern char x86_mask; /* lower 4 bits */ +extern int x86_capability; /* field of flags */ +extern int fdiv_bug; +extern char ignore_irq13; +extern char wp_works_ok; /* doesn't work on a 386 */ +extern char hlt_works_ok; /* problems on some 486Dx4's and old 386's */ + +/* + * 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 +#define MCA_bus__is_a_macro /* for versions in ksyms.c */ + +/* + * 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 (0xC0000000UL) + +/* + * Size of io_bitmap in longwords: 32 is ports 0-0x3ff. + */ +#define IO_BITMAP_SIZE 32 + +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 thread_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; +/* floating point info */ + union i387_union i387; +/* virtual 86 mode info */ + struct vm86_struct * vm86_info; + unsigned long screen_bitmap; + unsigned long v86flags, v86mask, v86mode; +}; + +#define INIT_MMAP { &init_task, 0, 0x40000000, PAGE_SHARED, VM_READ | VM_WRITE | VM_EXEC } + +#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 */ \ + NULL, 0, 0, 0, 0 /* vm86_info */ \ +} + +static inline void start_thread(struct pt_regs * regs, unsigned long eip, unsigned long esp) +{ + regs->cs = USER_CS; + regs->ds = regs->es = regs->ss = regs->fs = regs->gs = USER_DS; + regs->eip = eip; + regs->esp = esp; +} + +#endif /* __ASM_I386_PROCESSOR_H */ diff --git a/include/asm-i386/ptrace.h b/include/asm-i386/ptrace.h index 294acc7bd..e379542cf 100644 --- a/include/asm-i386/ptrace.h +++ b/include/asm-i386/ptrace.h @@ -1,15 +1,5 @@ -#ifndef _ASM_I386_PTRACE_H -#define _ASM_I386_PTRACE_H - -/* - * linux/include/asm-i386/ptrace.h */ - * - * machine dependend structs and defines to help the user use - * the ptrace system call. - */ - -/* use ptrace (3 or 6, pid, PT_EXCL, data); to read or write - the processes registers. */ +#ifndef _I386_PTRACE_H +#define _I386_PTRACE_H #define EBX 0 #define ECX 1 @@ -53,9 +43,9 @@ struct pt_regs { unsigned short ss, __ssu; }; -/* - * This function computes the interrupt number from the stack frame - */ -#define pt_regs2irq(p) ((int) -(((struct pt_regs *)p)->orig_eax+2)) +#ifdef __KERNEL__ +#define user_mode(regs) ((VM_MASK & (regs)->eflags) || (3 & (regs)->cs)) +extern void show_regs(struct pt_regs *); +#endif -#endif /* _ASM_I386_PTRACE_H */ +#endif diff --git a/include/asm-i386/resource.h b/include/asm-i386/resource.h new file mode 100644 index 000000000..f5fa979cd --- /dev/null +++ b/include/asm-i386/resource.h @@ -0,0 +1,23 @@ +#ifndef _I386_RESOURCE_H +#define _I386_RESOURCE_H + +/* + * 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 */ +#define RLIMIT_NPROC 6 /* max number of processes */ +#define RLIMIT_NOFILE 7 /* max number of open files */ + +#ifdef notdef +#define RLIMIT_MEMLOCK 8 /* max locked-in-memory address space*/ +#endif + +#define RLIM_NLIMITS 8 + +#endif diff --git a/include/asm-i386/sched.h b/include/asm-i386/sched.h deleted file mode 100644 index 1371d0226..000000000 --- a/include/asm-i386/sched.h +++ /dev/null @@ -1,331 +0,0 @@ -#ifndef _ASM_I386_SCHED_H -#define _ASM_I386_SCHED_H - -/* - * System setup and hardware bug flags.. - */ -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 - -/* - * 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 - -#include <linux/vm86.h> - -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 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]; -}; - -/* - * 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__ - -/* - * 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 ) - -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; -} - -/* - * 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"); - -/* - * Does the process account for user or for system time? - */ -#define USES_USER_TIME(regs) ((VM_MASK & (regs)->eflags) || (3 & regs->cs)) - -#endif /* __KERNEL__ */ - -#endif diff --git a/include/asm-i386/segment.h b/include/asm-i386/segment.h index 86b77c887..bd9394cdb 100644 --- a/include/asm-i386/segment.h +++ b/include/asm-i386/segment.h @@ -9,53 +9,118 @@ #ifndef __ASSEMBLY__ -static inline unsigned char get_user_byte(const char * addr) +/* + * Uh, these should become the main single-value transfer routines.. + * They automatically use the right size if we just have the right + * pointer type.. + */ +#define put_user(x,ptr) __put_user((unsigned long)(x),(ptr),sizeof(*(ptr))) +#define get_user(ptr) __get_user((ptr),sizeof(*(ptr))) + +/* + * This is a silly but good way to make sure that + * the __put_user function is indeed always optimized, + * and that we use the correct sizes.. + */ +extern int bad_user_access_length(void); + +/* + * dummy pointer type structure.. gcc won't try to do something strange + * this way.. + */ +struct __segment_dummy { unsigned long a[100]; }; +#define __sd(x) ((struct __segment_dummy *) (x)) + +static inline void __put_user(unsigned long x, void * y, int size) { - register unsigned char _v; + switch (size) { + case 1: + __asm__ ("movb %b1,%%fs:%0" + :"=m" (*__sd(y)) + :"iq" ((unsigned char) x), "m" (*__sd(y))); + break; + case 2: + __asm__ ("movw %w1,%%fs:%0" + :"=m" (*__sd(y)) + :"iq" ((unsigned short) x), "m" (*__sd(y))); + break; + case 4: + __asm__ ("movl %1,%%fs:%0" + :"=m" (*__sd(y)) + :"ir" (x), "m" (*__sd(y))); + break; + default: + bad_user_access_length(); + } +} - __asm__ ("movb %%fs:%1,%0":"=q" (_v):"m" (*addr)); - return _v; +static inline unsigned long __get_user(const void * y, int size) +{ + unsigned long result; + + switch (size) { + case 1: + __asm__ ("movb %%fs:%1,%b0" + :"=q" (result) + :"m" (*__sd(y))); + return (unsigned char) result; + case 2: + __asm__ ("movw %%fs:%1,%w0" + :"=q" (result) + :"m" (*__sd(y))); + return (unsigned short) result; + case 4: + __asm__ ("movl %%fs:%1,%0" + :"=r" (result) + :"m" (*__sd(y))); + return result; + default: + return bad_user_access_length(); + } +} + +/* + * These are deprecated.. + */ + +static inline unsigned char get_user_byte(const char * addr) +{ + return __get_user(addr,1); } #define get_fs_byte(addr) get_user_byte((char *)(addr)) static inline unsigned short get_user_word(const short *addr) { - unsigned short _v; - - __asm__ ("movw %%fs:%1,%0":"=r" (_v):"m" (*addr)); - return _v; + return __get_user(addr, 2); } #define get_fs_word(addr) get_user_word((short *)(addr)) static inline unsigned long get_user_long(const int *addr) { - unsigned long _v; - - __asm__ ("movl %%fs:%1,%0":"=r" (_v):"m" (*addr)); \ - return _v; + return __get_user(addr, 4); } #define get_fs_long(addr) get_user_long((int *)(addr)) static inline void put_user_byte(char val,char *addr) { -__asm__ ("movb %0,%%fs:%1": /* no outputs */ :"iq" (val),"m" (*addr)); + __put_user(val, addr, 1); } #define put_fs_byte(x,addr) put_user_byte((x),(char *)(addr)) static inline void put_user_word(short val,short * addr) { -__asm__ ("movw %0,%%fs:%1": /* no outputs */ :"ir" (val),"m" (*addr)); + __put_user(val, addr, 2); } #define put_fs_word(x,addr) put_user_word((x),(short *)(addr)) static inline void put_user_long(unsigned long val,int * addr) { -__asm__ ("movl %0,%%fs:%1": /* no outputs */ :"ir" (val),"m" (*addr)); + __put_user(val, addr, 4); } #define put_fs_long(x,addr) put_user_long((x),(int *)(addr)) diff --git a/include/asm-i386/signal.h b/include/asm-i386/signal.h index 5982091a3..271193975 100644 --- a/include/asm-i386/signal.h +++ b/include/asm-i386/signal.h @@ -1,5 +1,80 @@ -#ifndef _ASM_I386_SIGNAL_H -#define _ASM_I386_SIGNAL_H +#ifndef _ASMi386_SIGNAL_H +#define _ASMi386_SIGNAL_H + +typedef unsigned long sigset_t; /* at least 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 SIGURG 23 +#define SIGXCPU 24 +#define SIGXFSZ 25 +#define SIGVTALRM 26 +#define SIGPROF 27 +#define SIGWINCH 28 +#define SIGIO 29 +#define SIGPOLL SIGIO +/* +#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; + unsigned long sa_flags; + void (*sa_restorer)(void); +}; #ifdef __KERNEL__ @@ -30,4 +105,4 @@ struct sigcontext_struct { #endif -#endif /* _ASM_I386_SIGNAL_H */ +#endif diff --git a/include/asm-i386/stat.h b/include/asm-i386/stat.h new file mode 100644 index 000000000..b4c648695 --- /dev/null +++ b/include/asm-i386/stat.h @@ -0,0 +1,41 @@ +#ifndef _I386_STAT_H +#define _I386_STAT_H + +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 diff --git a/include/asm-i386/statfs.h b/include/asm-i386/statfs.h new file mode 100644 index 000000000..6efb74113 --- /dev/null +++ b/include/asm-i386/statfs.h @@ -0,0 +1,21 @@ +#ifndef _I386_STATFS_H +#define _I386_STATFS_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/asm-i386/string.h b/include/asm-i386/string.h index 3c4c598c1..0f721576e 100644 --- a/include/asm-i386/string.h +++ b/include/asm-i386/string.h @@ -122,7 +122,7 @@ __asm__ __volatile__( return __res; } -extern inline char * strchr(const char * s,char c) +extern inline char * strchr(const char * s, int c) { register char * __res; __asm__ __volatile__( @@ -140,7 +140,7 @@ __asm__ __volatile__( return __res; } -extern inline char * strrchr(const char * s,char c) +extern inline char * strrchr(const char * s, int c) { register char * __res; __asm__ __volatile__( @@ -337,26 +337,69 @@ __asm__ __volatile__( return __res; } -extern inline void * memcpy(void * to, const void * from, size_t n) +extern inline void * __memcpy(void * to, const void * from, size_t n) { __asm__ __volatile__( "cld\n\t" - "movl %%edx, %%ecx\n\t" - "shrl $2,%%ecx\n\t" "rep ; movsl\n\t" - "testb $1,%%dl\n\t" + "testb $2,%%dl\n\t" "je 1f\n\t" - "movsb\n" - "1:\ttestb $2,%%dl\n\t" - "je 2f\n\t" "movsw\n" - "2:\n" + "1:\ttestb $1,%%dl\n\t" + "je 2f\n\t" + "movsb\n" + "2:" : /* no output */ - :"d" (n),"D" ((long) to),"S" ((long) from) + :"c" (n/4), "d" (n),"D" ((long) to),"S" ((long) from) : "cx","di","si","memory"); return (to); } +/* + * This looks horribly ugly, but the compiler can optimize it totally, + * as the count is constant. + */ +extern inline void * __constant_memcpy(void * to, const void * from, size_t n) +{ + switch (n) { + case 0: + return to; + case 1: + *(unsigned char *)to = *(unsigned char *)from; + return to; + case 2: + *(unsigned short *)to = *(unsigned short *)from; + return to; + case 3: + *(unsigned short *)to = *(unsigned short *)from; + *(2+(unsigned char *)to) = *(2+(unsigned char *)from); + return to; + case 4: + *(unsigned long *)to = *(unsigned long *)from; + return to; + } +#define COMMON(x) \ +__asm__("cld\n\t" \ + "rep ; movsl" \ + x \ + : /* no outputs */ \ + : "c" (n/4),"D" ((long) to),"S" ((long) from) \ + : "cx","di","si","memory"); + + switch (n % 4) { + case 0: COMMON(""); return to; + case 1: COMMON("\n\tmovsb"); return to; + case 2: COMMON("\n\tmovsw"); return to; + case 3: COMMON("\n\tmovsw\n\tmovsb"); return to; + } +#undef COMMON +} + +#define memcpy(t, f, n) \ +(__builtin_constant_p(n) ? \ + __constant_memcpy((t),(f),(n)) : \ + __memcpy((t),(f),(n))) + extern inline void * memmove(void * dest,const void * src, size_t n) { if (dest<src) @@ -397,7 +440,7 @@ __asm__ __volatile__( return __res; } -extern inline void * memchr(const void * cs,char c,size_t count) +extern inline void * memchr(const void * cs,int c,size_t count) { register void * __res; if (!count) @@ -414,7 +457,7 @@ __asm__ __volatile__( return __res; } -extern inline void * __memset_generic(void * s,char c,size_t count) +extern inline void * __memset_generic(void * s, char c,size_t count) { __asm__ __volatile__( "cld\n\t" @@ -427,10 +470,33 @@ return s; } /* we might want to write optimized versions of these later */ -#define __constant_c_memset(s,c,count) __memset_generic((s),(c),(count)) #define __constant_count_memset(s,c,count) __memset_generic((s),(c),(count)) /* + * memset(x,0,y) is a reasonably common thing to do, so we want to fill + * things 32 bits at a time even when we don't know the size of the + * area at compile-time.. + */ +extern inline void * __constant_c_memset(void * s, unsigned long c, size_t count) +{ +__asm__ __volatile__( + "cld\n\t" + "rep ; stosl\n\t" + "testb $2,%%dl\n\t" + "je 1f\n\t" + "stosw\n" + "1:\ttestb $1,%%dl\n\t" + "je 2f\n\t" + "stosb\n" + "2:" + : /* no output */ + :"a" (c), "d" (count), "c" (count/4), "D" ((long) s) + :"cx","di","memory"); +return (s); +} + + +/* * This looks horribly ugly, but the compiler can optimize it totally, * as we by now know that both pattern and count is constant.. */ @@ -488,7 +554,7 @@ __asm__("cld\n\t" \ /* * find the first occurrence of byte 'c', or 1 past the area if none */ -extern inline char * memscan(void * addr, unsigned char c, int size) +extern inline void * memscan(void * addr, int c, size_t size) { if (!size) return addr; diff --git a/include/asm-i386/system.h b/include/asm-i386/system.h index 23af2e513..b4108d511 100644 --- a/include/asm-i386/system.h +++ b/include/asm-i386/system.h @@ -3,23 +3,125 @@ #include <asm/segment.h> -#define move_to_user_mode() \ -__asm__ __volatile__ ("movl %%esp,%%eax\n\t" \ - "pushl %0\n\t" \ - "pushl %%eax\n\t" \ - "pushfl\n\t" \ - "pushl %1\n\t" \ - "pushl $1f\n\t" \ - "iret\n" \ - "1:\tmovl %0,%%eax\n\t" \ - "mov %%ax,%%ds\n\t" \ - "mov %%ax,%%es\n\t" \ - "mov %%ax,%%fs\n\t" \ - "mov %%ax,%%gs" \ - : /* no outputs */ :"i" (USER_DS), "i" (USER_CS):"ax") +/* + * 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)) + +/* 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"); + + +/* + * 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 + * the math co-processor latest. + * + * It also reloads the debug regs if necessary.. + */ +#define switch_to(tsk) do { \ +__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"); \ + /* Now maybe reload the debug registers */ \ + if(current->debugreg[7]){ \ + loaddebug(0); \ + loaddebug(1); \ + loaddebug(2); \ + loaddebug(3); \ + loaddebug(6); \ + } \ +} while (0) + +#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 ) + +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 sti() __asm__ __volatile__ ("sti": : :"memory") -#define cli() __asm__ __volatile__ ("cli": : :"memory") #define nop() __asm__ __volatile__ ("nop") /* @@ -36,23 +138,37 @@ __asm__ __volatile__ ( \ :"ax") +extern inline unsigned long xchg_u8(char * m, unsigned long val) +{ + __asm__("xchgb %b0,%1":"=q" (val),"=m" (*m):"0" (val):"memory"); + return val; +} + +extern inline unsigned long xchg_u16(short * m, unsigned long val) +{ + __asm__("xchgw %w0,%1":"=r" (val),"=m" (*m):"0" (val):"memory"); + return val; +} + +extern inline unsigned long xchg_u32(int * m, unsigned long val) +{ + __asm__("xchgl %0,%1":"=r" (val),"=m" (*m):"0" (val):"memory"); + return val; +} + extern inline int tas(char * m) { - char res; + return xchg_u8(m,1); +} - __asm__("xchgb %0,%1":"=q" (res),"=m" (*m):"0" (0x1)); - return res; +extern inline void * xchg_ptr(void * m, void * val) +{ + return (void *) xchg_u32(m, (unsigned long) val); } -/* - * atomic exchange - */ -#define atomic_exchange(m,r) \ - __asm__ __volatile__( \ - "xchgl %0,%2" \ - : "=r" ((r)) \ - : "0" ((r)), "m" (*(m)) \ - : "memory"); +#define mb() __asm__ __volatile__ ("" : : :"memory") +#define sti() __asm__ __volatile__ ("sti": : :"memory") +#define cli() __asm__ __volatile__ ("cli": : :"memory") #define save_flags(x) \ __asm__ __volatile__("pushfl ; popl %0":"=r" (x): /* no input */ :"memory") @@ -113,5 +229,17 @@ __asm__ __volatile__ ("movw $" #limit ",%1\n\t" \ #define set_ldt_desc(n,addr,size) \ _set_tssldt_desc(((char *) (n)),((int)(addr)),((size << 3) - 1),"0x82") +/* + * This is the ldt that every process will get unless we need + * something other than this. + */ +extern struct desc_struct default_ldt; + +/* + * disable hlt during certain critical i/o operations + */ +#define HAVE_DISABLE_HLT +void disable_hlt(void); +void enable_hlt(void); #endif diff --git a/include/asm-i386/termios.h b/include/asm-i386/termios.h new file mode 100644 index 000000000..ee89e14a1 --- /dev/null +++ b/include/asm-i386/termios.h @@ -0,0 +1,266 @@ +#ifndef _I386_TERMIOS_H +#define _I386_TERMIOS_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 TIOCTTYGSTRUCT 0x5426 /* For debugging only */ +#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 */ +#define TIOCSERGETMULTI 0x545A /* Get multiport config */ +#define TIOCSERSETMULTI 0x545B /* Set multiport config */ + +/* 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 + +#ifdef __KERNEL__ +/* 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" +#endif + +/* 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 B230400 0010003 +#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/asm-i386/types.h b/include/asm-i386/types.h index 129bd4918..359ea5ba8 100644 --- a/include/asm-i386/types.h +++ b/include/asm-i386/types.h @@ -1,6 +1,61 @@ #ifndef _I386_TYPES_H #define _I386_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 _PTRDIFF_T +#define _PTRDIFF_T +typedef int ptrdiff_t; +#endif + +#ifndef _TIME_T +#define _TIME_T +typedef long time_t; +#endif + +#ifndef _CLOCK_T +#define _CLOCK_T +typedef long clock_t; +#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; + +/* + * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the + * header files exported to user space + */ + +typedef __signed__ char __s8; +typedef unsigned char __u8; + +typedef __signed__ short __s16; +typedef unsigned short __u16; + +typedef __signed__ long __s32; +typedef unsigned long __u32; + +#if defined(__GNUC__) && !defined(__STRICT_ANSI__) +typedef __signed__ long long __s64; +typedef unsigned long long __u64; +#endif + /* * These aren't exported outside the kernel to avoid name space clashes */ diff --git a/include/asm-i386/unistd.h b/include/asm-i386/unistd.h index 81a5ff09c..84196ac9e 100644 --- a/include/asm-i386/unistd.h +++ b/include/asm-i386/unistd.h @@ -84,4 +84,40 @@ errno=-__res; \ return -1; \ } +#ifdef __KERNEL_SYSCALLS__ + +/* + * we need this inline - forking from kernel space will result + * in NO COPY ON WRITE (!!!), until an execve is executed. This + * is no problem, but for the stack. This is handled by not letting + * main() use the stack at all after fork(). Thus, no function + * calls - which means inline code for fork too, as otherwise we + * would use the stack upon exit from 'fork()'. + * + * Actually only pause and fork are needed inline, so that there + * won't be any messing with the stack from main(), but we define + * some others too. + */ +#define __NR__exit __NR_exit +static inline _syscall0(int,idle) +static inline _syscall0(int,fork) +static inline _syscall0(int,pause) +static inline _syscall0(int,setup) +static inline _syscall0(int,sync) +static inline _syscall0(pid_t,setsid) +static inline _syscall3(int,write,int,fd,const char *,buf,off_t,count) +static inline _syscall1(int,dup,int,fd) +static inline _syscall3(int,execve,const char *,file,char **,argv,char **,envp) +static inline _syscall3(int,open,const char *,file,int,flag,int,mode) +static inline _syscall1(int,close,int,fd) +static inline _syscall1(int,_exit,int,exitcode) +static inline _syscall3(pid_t,waitpid,pid_t,pid,int *,wait_stat,int,options) + +static inline pid_t wait(int * wait_stat) +{ + return waitpid(-1,wait_stat,0); +} + +#endif + #endif /* _ASM_I386_UNISTD_H_ */ diff --git a/include/asm-m68k/bitops.h b/include/asm-m68k/bitops.h new file mode 100644 index 000000000..901fa48a0 --- /dev/null +++ b/include/asm-m68k/bitops.h @@ -0,0 +1,120 @@ +#ifndef _M68K_BITOPS_H +#define _M68K_BITOPS_H +/* + * Copyright 1992, Linus Torvalds. + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file README.legal in the main directory of this archive + * for more details. + */ + +/* + * Require 68020 or better. + * + * They don't use the standard m680x0 bit ordering. + * Instead, the use the standard m680x0 bitfield ordering. + * + * Thus, bit 0 is the MSB of addr; bit 32 is the MSB of (addr+1). + */ + +extern __inline__ int set_bit(int nr,void * vaddr) +{ + char retval; + + __asm__ __volatile__ ("bfset %2@{%1:#1}; sne %0" + : "=d" (retval) : "d" (nr), "a" (vaddr)); + + return retval; +} + +extern __inline__ int clear_bit(int nr, void * vaddr) +{ + char retval; + + __asm__ __volatile__ ("bfclr %2@{%1:#1}; sne %0" + : "=d" (retval) : "d" (nr), "a" (vaddr)); + + return retval; +} + +extern __inline__ int change_bit(int nr, void * vaddr) +{ + char retval; + + __asm__ __volatile__ ("bfchg %2@{%1:#1}; sne %0" + : "=d" (retval) : "d" (nr), "a" (vaddr)); + + return retval; +} + +extern __inline__ int test_bit(int nr, const void * vaddr) +{ + char retval; + + __asm__ __volatile__ ("bftst %2@{%1:#1}; sne %0" + : "=d" (retval) : "d" (nr), "a" (vaddr)); + + return retval; +} + +extern inline int find_first_zero_bit(void * vaddr, unsigned size) +{ + unsigned long res; + unsigned long *p; + unsigned long *addr = vaddr; + + if (!size) + return 0; + __asm__ __volatile__ (" moveq #-1,d0\n\t" + "1:" + " cmpl %1@+,d0\n\t" + " bne 2f\n\t" + " subql #1,%0\n\t" + " bne 1b\n\t" + " bra 5f\n\t" + "2:" + " movel %1@-,d0\n\t" + " notl d0\n\t" + " bfffo d0{#0,#0},%0\n\t" + "5:" + : "=d" (res), "=a" (p) + : "0" ((size + 31) >> 5), "1" (addr) + : "d0"); + return ((p - addr) << 5) + res; +} + +static inline int find_next_zero_bit (void *vaddr, int size, + int offset) +{ + unsigned long *addr = vaddr; + unsigned long *p = addr + (offset >> 5); + int set = 0, bit = offset & 31, res; + + if (bit) { + /* Look for zero in first longword */ + __asm__("bfffo %1{#0,#0},%0" + : "=d" (set) + : "d" (~*p << bit)); + if (set < (32 - bit)) + return set + offset; + set = 32 - bit; + p++; + } + /* No zero yet, search remaining full bytes for a zero */ + res = find_first_zero_bit (p, size - 32 * (p - addr)); + return (offset + set + res); +} + +/* + * ffz = Find First Zero in word. Undefined if no zero exists, + * so code should check against ~0UL first.. + */ +extern inline unsigned long ffz(unsigned long word) +{ + __asm__ __volatile__ ("bfffo %1{#0,#0},%0" + : "=d" (word) + : "d" (~(word))); + return word; +} + +#endif /* _M68K_BITOPS_H */ diff --git a/include/asm-m68k/delay.h b/include/asm-m68k/delay.h new file mode 100644 index 000000000..804a654b7 --- /dev/null +++ b/include/asm-m68k/delay.h @@ -0,0 +1,40 @@ +#ifndef _M68K_DELAY_H +#define _M68K_DELAY_H + +/* + * Copyright (C) 1994 Hamish Macdonald + * + * Delay routines, using a pre-computed "loops_per_second" value. + */ + +extern __inline__ void __delay(int loops) +{ + __asm__("\n\tmovel %0,d0\n1:\tsubql #1,d0\n\tbpls 1b\n" + : /* no outputs */ + : "g" (loops) + : "d0"); +} + +/* + * division by multiplication: you don't have to worry about + * loss of precision. + * + * Use only for very small delays ( < 1 msec). Should probably use a + * lookup table, really, as the multiplications take much too long with + * short delays. This is a "reasonable" implementation, though (and the + * first constant multiplications gets optimized away if the delay is + * a constant) + */ +extern __inline__ void udelay(unsigned long usecs) +{ + asm ("mulul %1,d0,%0\n\t" + "divul %2,d0,%0" + : "=d" (usecs) + : "d" (usecs), + "i" (1000000), + "0" (loops_per_sec) + : "d0"); + __delay(usecs); +} + +#endif /* defined(_M68K_DELAY_H) */ diff --git a/include/asm-m68k/dma.h b/include/asm-m68k/dma.h new file mode 100644 index 000000000..2820f20a1 --- /dev/null +++ b/include/asm-m68k/dma.h @@ -0,0 +1,6 @@ +#ifndef _M68K_DMA_H +#define _M68K_DMA_H 1 + +/* dummy for m68k */ + +#endif /* _M68K_DMA_H */ diff --git a/include/asm-m68k/io.h b/include/asm-m68k/io.h new file mode 100644 index 000000000..0cde22fd3 --- /dev/null +++ b/include/asm-m68k/io.h @@ -0,0 +1,24 @@ +#ifndef _M68K_IO_H +#define _M68K_IO_H + +static inline unsigned char get_user_byte_io(const char * addr) +{ + register unsigned char _v; + + __asm__ __volatile__ ("moveb %1,%0":"=r" (_v):"m" (*addr)); + return _v; +} +#define inb_p(addr) get_user_byte_io((char *)(addr)) +#define inb(addr) get_user_byte_io((char *)(addr)) + +static inline void put_user_byte_io(char val,char *addr) +{ + __asm__ __volatile__ ("moveb %0,%1" + : /* no outputs */ + :"r" (val),"m" (*addr) + : "memory"); +} +#define outb_p(x,addr) put_user_byte_io((x),(char *)(addr)) +#define outb(x,addr) put_user_byte_io((x),(char *)(addr)) + +#endif /* _M68K_IO_H */ diff --git a/include/asm-m68k/irq.h b/include/asm-m68k/irq.h new file mode 100644 index 000000000..c8f300ca8 --- /dev/null +++ b/include/asm-m68k/irq.h @@ -0,0 +1,6 @@ +#ifndef _M68K_IRQ_H_ +#define _M68K_IRQ_H_ + +/* dummy for m68k */ + +#endif /* _M68K_IRQ_H_ */ diff --git a/include/asm-m68k/segment.h b/include/asm-m68k/segment.h new file mode 100644 index 000000000..89079be3f --- /dev/null +++ b/include/asm-m68k/segment.h @@ -0,0 +1,241 @@ +/* + * linux/include/asm-m68k/segment.h + * + * Copyright (C) 1991, 1992 Linus Torvalds + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file README.legal in the main directory of this archive + * for more details. + */ + +/* + * 680x0 support added by Hamish Macdonald + */ + +#ifndef _M68K_SEGMENT_H +#define _M68K_SEGMENT_H + +static inline unsigned char get_user_byte(const char * addr) +{ + register unsigned char _v; + + __asm__ __volatile__ ("movesb %1,%0":"=r" (_v):"m" (*addr)); + return _v; +} + +#define get_fs_byte(addr) get_user_byte((char *)(addr)) + +static inline unsigned short get_user_word(const short *addr) +{ + unsigned short _v; + + __asm__ __volatile__ ("movesw %1,%0":"=r" (_v):"m" (*addr)); + return _v; +} + +#define get_fs_word(addr) get_user_word((short *)(addr)) + +static inline unsigned long get_user_long(const int *addr) +{ + unsigned long _v; + + __asm__ __volatile__ ("movesl %1,%0":"=r" (_v):"m" (*addr)); \ + return _v; +} + +#define get_fs_long(addr) get_user_long((int *)(addr)) + +static inline void put_user_byte(char val,char *addr) +{ + __asm__ __volatile__ ("movesb %0,%1": /* no outputs */ :"r" (val),"m" (*addr) : "memory"); +} + +#define put_fs_byte(x,addr) put_user_byte((x),(char *)(addr)) + +static inline void put_user_word(short val,short * addr) +{ + __asm__ __volatile__ ("movesw %0,%1": /* no outputs */ :"r" (val),"m" (*addr) : "memory"); +} + +#define put_fs_word(x,addr) put_user_word((x),(short *)(addr)) + +static inline void put_user_long(unsigned long val,int * addr) +{ + __asm__ __volatile__ ("movesl %0,%1": /* no outputs */ :"r" (val),"m" (*addr) : "memory"); +} + +#define put_fs_long(x,addr) put_user_long((x),(int *)(addr)) + +static inline void __generic_memcpy_tofs(void * to, const void * from, unsigned long n) +{ + if (n == 0) return; + __asm__ __volatile__ ("1:\n\t" + "moveb %1@+,d0\n\t" + "movesb d0,%2@+\n\t" + "dbra %0,1b\n\t" + "clrw %0\n\t" + "subql #1,%0\n\t" + "bccs 1b" + : "=d" (n), "=a" (from), "=a" (to) + : "1" (from), "2" (to), "0" (n-1) + : "d0", "memory"); +} + +static inline void __constant_memcpy_tofs(void * to, const void * from, unsigned long n) +{ + if (n == 0) { + return; + } else if (n == 1) { + put_user_byte(*(const char *) from, (char *) to); + return; + } else if (n == 2) { + put_user_word(*(const short *) from, (short *) to); + return; + } else if (n == 3) { + put_user_word(*(const short *) from, (short *) to); + put_user_byte(*(2+(const char *) from), 2+(char *) to); + return; + } else if (n == 4) { + put_user_long(*(const int *) from, (int *) to); + return; + } +#if 0 +#define COMMON(x) \ +__asm__("cld\n\t" \ + "push %%es\n\t" \ + "push %%fs\n\t" \ + "pop %%es\n\t" \ + "rep ; movsl\n\t" \ + x \ + "pop %%es" \ + : /* no outputs */ \ + :"c" (n/4),"D" ((long) to),"S" ((long) from) \ + :"cx","di","si") + + switch (n % 4) { + case 0: + COMMON(""); + return; + case 1: + COMMON("movsb\n\t"); + return; + case 2: + COMMON("movsw\n\t"); + return; + case 3: + COMMON("movsw\n\tmovsb\n\t"); + return; + } +#undef COMMON +#else + __generic_memcpy_tofs(to,from,n); +#endif +} + +static inline void __generic_memcpy_fromfs(void * to, const void * from, unsigned long n) +{ + if (n == 0) return; + __asm__ __volatile__ ("1:\n\t" + "movesb %1@+,d0\n\t" + "moveb d0,%2@+\n\t" + "dbra %0,1b\n\t" + "clrw %0\n\t" + "subql #1,%0\n\t" + "bccs 1b" + : "=d" (n), "=a" (from), "=a" (to) + : "1" (from), "2" (to), "0" (n-1) + : "d0", "memory"); +} + +static inline void __constant_memcpy_fromfs(void * to, const void * from, unsigned long n) +{ + if (n == 0) { + return; + } else if (n == 1) { + *(char *)to = get_user_byte((const char *) from); + return; + } else if (n == 2) { + *(short *)to = get_user_word((const short *) from); + return; + } else if (n == 3) { + *(short *) to = get_user_word((const short *) from); + *(2+(char *) to) = get_user_byte(2+(const char *) from); + return; + } else if (n == 4) { + *(int *) to = get_user_long((const int *) from); + return; + } +#if 0 +#define COMMON(x) \ +__asm__("cld\n\t" \ + "rep ; fs ; movsl\n\t" \ + x \ + : /* no outputs */ \ + :"c" (n/4),"D" ((long) to),"S" ((long) from) \ + :"cx","di","si","memory") + + switch (n % 4) { + case 0: + COMMON(""); + return; + case 1: + COMMON("fs ; movsb"); + return; + case 2: + COMMON("fs ; movsw"); + return; + case 3: + COMMON("fs ; movsw\n\tfs ; movsb"); + return; + } +#undef COMMON +#else + __generic_memcpy_fromfs(to,from,n); +#endif +} + +#define memcpy_fromfs(to, from, n) \ +(__builtin_constant_p(n) ? \ + __constant_memcpy_fromfs((to),(from),(n)) : \ + __generic_memcpy_fromfs((to),(from),(n))) + +#define memcpy_tofs(to, from, n) \ +(__builtin_constant_p(n) ? \ + __constant_memcpy_tofs((to),(from),(n)) : \ + __generic_memcpy_tofs((to),(from),(n))) + +/* + * Get/set the SFC/DFC registers for MOVES instructions + */ + +static inline unsigned long get_fs(void) +{ + unsigned long _v; + __asm__ ("movec dfc,%0":"=r" (_v):); + + return _v; +} + +static inline unsigned long get_ds(void) +{ + /* return the supervisor data space code */ + return 0x5; +} + +static inline void set_fs(unsigned long val) +{ + __asm__ __volatile__ ("movec %0,sfc\n\t" + "movec %0,dfc\n\t" + : /* no outputs */ : "r" (val), "r" (val) : "memory"); +} + +/* define constants */ +/* Address spaces (FC0-FC2) */ +#ifndef USER_DS +#define USER_DS (1) +#endif +#ifndef KERNEL_DS +#define KERNEL_DS (5) +#endif + +#endif /* _M68K_SEGMENT_H */ diff --git a/include/asm-m68k/string.h b/include/asm-m68k/string.h new file mode 100644 index 000000000..70466ed5e --- /dev/null +++ b/include/asm-m68k/string.h @@ -0,0 +1,154 @@ +#ifndef _M68K_STRING_H_ +#define _M68K_STRING_H_ + +#define __USE_PORTABLE_STRINGS_H_ + +extern inline char * strcpy(char * dest,const char *src) +{ + char *xdest = dest; + + __asm__ __volatile__ + ("1:\tmoveb %1@+,%0@+\n\t" + "bne 1b" + : "=a" (dest), "=a" (src) + : "0" (dest), "1" (src) : "memory"); + return xdest; +} + +extern inline char * strncpy(char *dest, const char *src, size_t n) +{ + char *xdest = dest; + + if (n == 0) + return xdest; + + __asm__ __volatile__ + ("1:\tmoveb %1@+,%0@+\n\t" + "beq 2f\n\t" + "subql #1,%2\n\t" + "bne 1b\n\t" + "2:" + : "=a" (dest), "=a" (src), "=d" (n) + : "0" (dest), "1" (src), "2" (n) + : "memory"); + return xdest; +} + +#define __USE_PORTABLE_strcat + +#define __USE_PORTABLE_strncat + +extern inline int strcmp(const char * cs,const char * ct) +{ + char __res; + + __asm__ + ("1:\tmoveb %0@+,%2\n\t" /* get *cs */ + "cmpb %1@+,%2\n\t" /* compare a byte */ + "bne 2f\n\t" /* not equal, break out */ + "tstb %2\n\t" /* at end of cs? */ + "bne 1b\n\t" /* no, keep going */ + "bra 3f\n\t" /* strings are equal */ + "2:\tsubb %1@-,%2\n\t" /* *cs - *ct */ + "3:" + : "=a" (cs), "=a" (ct), "=d" (__res) + : "0" (cs), "1" (ct)); + return __res; +} + +extern inline int strncmp(const char * cs,const char * ct,size_t count) +{ + char __res; + + if (!count) + return 0; + __asm__ + ("1:\tmovb %0@+,%3\n\t" /* get *cs */ + "cmpb %1@+,%3\n\t" /* compare a byte */ + "bne 3f\n\t" /* not equal, break out */ + "tstb %3\n\t" /* at end of cs? */ + "beq 4f\n\t" /* yes, all done */ + "subql #1,%2\n\t" /* no, adjust count */ + "bne 1b\n\t" /* more to do, keep going */ + "2:\tmoveq #0,%3\n\t" /* strings are equal */ + "bra 4f\n\t" + "3:\tsubb %1@-,%3\n\t" /* *cs - *ct */ + "4:" + : "=a" (cs), "=a" (ct), "=d" (count), "=d" (__res) + : "0" (cs), "1" (ct), "2" (count)); + return __res; +} + +#define __USE_PORTABLE_strchr + +#define __USE_PORTABLE_strlen + +#define __USE_PORTABLE_strspn + +#define __USE_PORTABLE_strpbrk + +#define __USE_PORTABLE_strtok + +extern inline void * memset(void * s,char c,size_t count) +{ + void *xs = s; + + if (!count) + return xs; + __asm__ __volatile__ + ("1:\tmoveb %3,%0@+\n\t" + "subql #1,%1\n\t" + "bne 1b" + : "=a" (s), "=d" (count) + : "0" (s), "d" (c), "1" (count) + : "memory"); + return xs; +} + +extern inline void * memcpy(void * to, const void * from, size_t n) +{ + void *xto = to; + + if (!n) + return xto; + __asm__ __volatile__ + ("1:\tmoveb %1@+,%0@+\n\t" + "subql #1,%2\n\t" + "bne 1b" + : "=a" (to), "=a" (from), "=d" (n) + : "0" (to), "1" (from), "2" (n) + : "memory" ); + return xto; +} + +extern inline void * memmove(void * dest,const void * src, size_t n) +{ + void *xdest = dest; + + if (!n) + return xdest; + + if (dest < src) + __asm__ __volatile__ + ("1:\tmoveb %1@+,%0@+\n\t" + "subql #1,%2\n\t" + "bne 1b" + : "=a" (dest), "=a" (src), "=d" (n) + : "0" (dest), "1" (src), "2" (n) + : "memory" ); + else + __asm__ __volatile__ + ("1:\tmoveb %1@-,%0@-\n\t" + "subql #1,%2\n\t" + "bne 1b" + : "=a" (dest), "=a" (src), "=d" (n) + : "0" (dest+n), "1" (src+n), "2" (n) + : "memory" ); + return xdest; +} + +#define __USE_PORTABLE_memcmp + +#define __USE_PORTABLE_memscan + +#endif /* _M68K_STRING_H_ */ diff --git a/include/asm-m68k/system.h b/include/asm-m68k/system.h new file mode 100644 index 000000000..e987f1f46 --- /dev/null +++ b/include/asm-m68k/system.h @@ -0,0 +1,53 @@ +/* + * linux/include/asm-m68k/system.h + * + * Copyright (C) 1991, 1992 Linus Torvalds + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file README.legal in the main directory of this archive + * for more details. + */ + +/* + * 680x0 support added by Hamish Macdonald + */ + +#ifndef _M68K_SYSTEM_H +#define _M68K_SYSTEM_H + +#include <linux/config.h> /* get configuration macros */ + +#if defined(CONFIG_ATARI) && !defined(CONFIG_AMIGA) && !defined(CONFIG_MAC) +/* block out HSYNC on the atari */ +#define sti() __asm__ __volatile__ ("andiw #0xfbff,sr": : : "memory") +#else /* portable version */ +#define sti() __asm__ __volatile__ ("andiw #0xf8ff,sr": : : "memory") +#endif /* machine compilation types */ +#define cli() __asm__ __volatile__ ("oriw #0x0700,sr": : : "memory") +#define nop() __asm__ __volatile__ ("nop"::) + +#define save_flags(x) \ +__asm__ __volatile__("movew sr,%0":"=d" (x) : /* no input */ :"memory") + +#define restore_flags(x) \ +__asm__ __volatile__("movew %0,sr": /* no outputs */ :"d" (x) : "memory") + +#define iret() __asm__ __volatile__ ("rte": : :"memory", "sp", "cc") + +#define move_to_user_mode() \ + __asm__ __volatile__ ("movel sp,usp\n\t" /* setup user sp */ \ + "movec %0,msp\n\t" /* setup kernel sp */ \ + "andiw #0xdfff,sr" /* return to user mode */ \ + : /* no output */ \ + : "r" (current->kernel_stack_page + PAGE_SIZE) \ + : "memory", "sp") + +static inline void clear_fpu(void) { + unsigned long nilstate = 0; + __asm__ __volatile__ ("frestore %0@" : : "a" (&nilstate)); +} + +#define halt() \ + __asm__ __volatile__ ("halt") + +#endif /* _M68K_SYSTEM_H */ diff --git a/include/asm-m68k/unistd.h b/include/asm-m68k/unistd.h new file mode 100644 index 000000000..acad643bf --- /dev/null +++ b/include/asm-m68k/unistd.h @@ -0,0 +1,114 @@ +#ifndef _ASM_M68K_UNISTD_H_ +#define _ASM_M68K_UNISTD_H_ + +/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */ +#define _syscall0(type,name) \ +type name(void) \ +{ \ +register long __res __asm__ ("d0") = __NR_##name; \ +__asm__ __volatile__ ("trap #0" \ + : "=g" (__res) \ + : "0" (__NR_##name) \ + : "d0"); \ +if (__res >= 0) \ + return (type) __res; \ +errno = -__res; \ +return -1; \ +} + +#define _syscall1(type,name,atype,a) \ +type name(atype a) \ +{ \ +register long __res __asm__ ("d0") = __NR_##name; \ +__asm__ __volatile__ ("movel %2,d1\n\t" \ + "trap #0" \ + : "=g" (__res) \ + : "0" (__NR_##name), "g" ((long)(a)) \ + : "d0", "d1"); \ +if (__res >= 0) \ + return (type) __res; \ +errno = -__res; \ +return -1; \ +} + +#define _syscall2(type,name,atype,a,btype,b) \ +type name(atype a,btype b) \ +{ \ +register long __res __asm__ ("d0") = __NR_##name; \ +__asm__ __volatile__ ("movel %2,d1\n\t" \ + "movel %3,d2\n\t" \ + "trap #0" \ + : "=g" (__res) \ + : "0" (__NR_##name), "g" ((long)(a)), \ + "g" ((long)(b)) \ + : "d0", "d1", "d2"); \ +if (__res >= 0) \ + return (type) __res; \ +errno = -__res; \ +return -1; \ +} + +#define _syscall3(type,name,atype,a,btype,b,ctype,c) \ +type name(atype a,btype b,ctype c) \ +{ \ +register long __res __asm__ ("d0") = __NR_##name; \ +__asm__ __volatile__ ("movel %2,d1\n\t" \ + "movel %3,d2\n\t" \ + "movel %4,d3\n\t" \ + "trap #0" \ + : "=g" (__res) \ + : "0" (__NR_##name), "g" ((long)(a)), \ + "g" ((long)(b)), \ + "g" ((long)(c)) \ + : "d0", "d1", "d2", "d3"); \ +if (__res >= 0) \ + return (type) __res; \ +errno = -__res; \ +return -1; \ +} + +#define _syscall4(type,name,atype,a,btype,b,ctype,c,dtype,d) \ +type name (atype a, btype b, ctype c, dtype d) \ +{ \ +register long __res __asm__ ("d0") = __NR_##name; \ +__asm__ __volatile__ ("movel %2,d1\n\t" \ + "movel %3,d2\n\t" \ + "movel %4,d3\n\t" \ + "movel %5,d4\n\t" \ + "trap #0" \ + : "=g" (__res) \ + : "0" (__NR_##name), "g" ((long)(a)), \ + "g" ((long)(b)), \ + "g" ((long)(c)), \ + "g" ((long)(d)) \ + : "d0", "d1", "d2", "d3", "d4"); \ +if (__res >= 0) \ + return (type) __res; \ +errno = -__res; \ +return -1; \ +} + +#define _syscall5(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e) \ +type name (atype a,btype b,ctype c,dtype d,etype e) \ +{ \ +register long __res __asm__ ("d0") = __NR_##name; \ +__asm__ __volatile__ ("movel %2,d1\n\t" \ + "movel %3,d2\n\t" \ + "movel %4,d3\n\t" \ + "movel %5,d4\n\t" \ + "movel %6,d5\n\t" \ + "trap #0" \ + : "=g" (__res) \ + : "0" (__NR_##name), "g" ((long)(a)), \ + "g" ((long)(b)), \ + "g" ((long)(c)), \ + "g" ((long)(d)), \ + "g" ((long)(e)) \ + : "d0", "d1", "d2", "d3", "d4", "d5"); \ +if (__res >= 0) \ + return (type) __res; \ +errno = -__res; \ +return -1; \ +} + +#endif /* _ASM_M68K_UNISTD_H_ */ diff --git a/include/asm-mips/asm.h b/include/asm-mips/asm.h new file mode 100644 index 000000000..12c9785d8 --- /dev/null +++ b/include/asm-mips/asm.h @@ -0,0 +1,241 @@ +/* + * include/asm-mips/asm.h + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file "COPYING" in the main directory of this archive + * for more details. + * + * Copyright (C) 1995 by Ralf Baechle + * + * Some usefull macros for MIPS assembler code + * + * Some of the routines below contain useless nops that will be optimized + * away by gas in -O mode. These nops are however required to fill delay + * slots in noreorder mode. + */ +#ifndef __ASM_ASM_H +#define __ASM_ASM_H + +#include <linux/autoconf.h> +#include <asm/regdef.h> + +#ifndef CAT +#ifdef __STDC__ +#define __CAT(str1,str2) str1##str2 +#else +#define __CAT(str1,str2) str1/**/str2 +#endif +#define CAT(str1,str2) __CAT(str1,str2) +#endif + +/* + * Macros to handle different pointer sizes for 32/64-bit code + */ +#if __mips == 3 +#define PTR .quad +#define PTRSIZE 8 +#define PTRLOG 3 +#define lp ld +#else +#define PTR .word +#define PTRSIZE 4 +#define PTRLOG 2 +#define lp lw +#endif + +/* + * ELF specific declarations + */ +#ifdef __ELF__ +#define TYPE(symbol,_type) \ + .type symbol,@_type +#define SIZE(symbol,_size) \ + .size symbol,_size +#else +#define TYPE(symbol,type) +#define SIZE(symbol,size) +#endif + +/* + * PIC specific declarations + * Not used for the kernel but here seems to be the right place. + */ +#ifdef __PIC__ +#define CPRESTORE(register) \ + .cprestore register +#define CPADD(register) \ + .cpadd register +#define CPLOAD(register) \ + .cpload register +#else +#define CPRESTORE(register) +#define CPADD(register) +#define CPLOAD(register) +#endif + +/* + * LEAF - declare leaf routine + */ +#define LEAF(symbol) \ + .globl symbol; \ + .align 2; \ + TYPE(symbol,function); \ + .ent symbol,0; \ +symbol: .frame sp,0,ra + +/* + * NESTED - declare nested routine entry point + */ +#define NESTED(symbol, framesize, rpc) \ + .globl symbol; \ + .align 2; \ + TYPE(symbol,function); \ + .ent symbol,0; \ +symbol: .frame sp, framesize, rpc + +/* + * END - mark end of function + */ +#define END(function) \ + .end function; \ + SIZE(function,.-function) + +/* + * EXPORT - export definition of symbol + */ +#define EXPORT(symbol) \ + .globl symbol; \ +symbol: + +/* + * ABS - export absolute symbol + */ +#define ABS(symbol,value) \ + .globl symbol; \ +symbol = value + +#define PANIC(msg) \ + la a0,8f; \ + jal panic; \ + nop; \ +9: b 9b; \ + nop; \ + TEXT(msg) + +/* + * Print formated string + */ +#define PRINT(string) \ + la a0,8f; \ + jal printk; \ + nop; \ + TEXT(string) + +#define TEXT(msg) \ + .data; \ +8: .asciiz msg; \ + .text + +/* + * Build text tables + */ +#define TTABLE(string) \ + .text; \ + .word 1f; \ + .data; \ +1: .asciz string; \ + .text; + +/* + * Move to kernel mode and disable interrupts + * Set cp0 enable bit as sign that we're running on the kernel stack + * Use with .set noat! + */ +#define CLI \ + mfc0 AT,CP0_STATUS; \ + li t0,ST0_CU0|0x1f; \ + or AT,t0; \ + xori AT,0x1f; \ + mtc0 AT,CP0_STATUS; \ + +/* + * Move to kernel mode and enable interrupts + * Set cp0 enable bit as sign that we're running on the kernel stack + * Use with .set noat! + */ +#define STI \ + mfc0 AT,CP0_STATUS; \ + li t0,ST0_CU0|0x1f; \ + or AT,t0; \ + xori AT,0x1e; \ + mtc0 AT,CP0_STATUS; \ + +/* + * Special nop to fill load delay slots + */ +#ifndef __R4000__ +#define NOP nop +#else +#define NOP +#endif + +/* + * Return from exception + */ +#if defined (CONFIG_CPU_R3000) +#define ERET rfe +#elif defined (CONFIG_CPU_R4X00) || defined (CONFIG_CPU_R4600) +#define ERET \ + .set mips3; \ + eret; \ + .set mips0 +#else +#error "Implement ERET macro!" +#endif + +/* + * R8000/R10000 (MIPS ISA IV) pref instruction. + * Use with .set noreorder only! + */ +#if defined (CONFIG_CPU_R8000) || defined(CONFIG_CPU_R10000) +#define PREF(hint,addr) \ + pref hint,addr +#define PREFX(hint,addr) \ + prefx hint,addr +#else +#define PREF +#define PREFX +#endif + +/* + * R8000/R10000 (MIPS ISA IV) movn/movz instructions and + * equivalents for old CPUs. Use with .set noreorder only! + */ +#if defined (CONFIG_CPU_R8000) || defined (CONFIG_CPU_R10000) +#define MOVN(rd,rs,rt) \ + movn rd,rs,rt +#define MOVZ(rd,rs,rt) \ + movz rd,rs,rt +#elif defined (CONFIG_CPU_R4000) || defined (CONFIG_CPU_R6000) +#define MOVN(rd,rs,rt) \ + bnezl rt,9f \ + move rd,rs \ +9: +#define MOVZ(rd,rs,rt) \ + beqzl rt,9f \ + movz rd,rt \ +9: +#else /* R2000, R3000 */ +#define MOVN(rd,rs,rt) \ + beqz rt,9f \ + nop \ + move rd,rs \ +9: +#define MOVZ(rd,rs,rt) \ + bneqz rt,9f \ + nop \ + movz rd,rt \ +9: +#endif + +#endif /* __ASM_ASM_H */ diff --git a/include/asm-mips/bitops.h b/include/asm-mips/bitops.h index a2fd7972b..255ec9ee2 100644 --- a/include/asm-mips/bitops.h +++ b/include/asm-mips/bitops.h @@ -5,18 +5,23 @@ * License. See the file "COPYING" in the main directory of this archive * for more details. * - * Copyright (c) 1994 by Ralf Baechle + * Copyright (c) 1994, 1995 Ralf Baechle */ -#ifndef _ASM_MIPS_BITOPS_H -#define _ASM_MIPS_BITOPS_H +#ifndef __ASM_MIPS_BITOPS_H +#define __ASM_MIPS_BITOPS_H + +#ifdef __R4000__ #include <asm/mipsregs.h> -extern inline int set_bit(int nr, void *addr) +/* + * The following functions will only work for the R4000! + */ +extern __inline__ int set_bit(int nr, void *addr) { int mask, retval, mw; - addr += nr >> 5; + addr += ((nr >> 3) & ~3); mask = 1 << (nr & 0x1f); do { mw = load_linked(addr); @@ -27,11 +32,11 @@ extern inline int set_bit(int nr, void *addr) return retval; } -extern inline int clear_bit(int nr, void *addr) +extern __inline__ int clear_bit(int nr, void *addr) { int mask, retval, mw; - addr += nr >> 5; + addr += ((nr >> 3) & ~3); mask = 1 << (nr & 0x1f); do { mw = load_linked(addr); @@ -42,11 +47,11 @@ extern inline int clear_bit(int nr, void *addr) return retval; } -extern inline int change_bit(int nr, void *addr) +extern __inline__ int change_bit(int nr, void *addr) { int mask, retval, mw; - addr += nr >> 5; + addr += ((nr >> 3) & ~3); mask = 1 << (nr & 0x1f); do { mw = load_linked(addr); @@ -57,10 +62,83 @@ extern inline int change_bit(int nr, void *addr) return retval; } -extern inline int test_bit(int nr, void *addr) +#else /* !defined(__R4000__) */ + +#include <asm/system.h> + +#ifdef __KERNEL__ +/* + * Only disable interrupt for kernelmode stuff to keep some + * usermode stuff alive + */ +#define __flags unsigned long flags +#define __cli() cli() +#define __save_flags(x) save_flags(x) +#define __restore_flags(x) restore_flags(x) +#endif /* __KERNEL__ */ + +extern __inline__ int set_bit(int nr, void * addr) +{ + int mask, retval; + int *a = addr; + __flags; + + a += nr >> 5; + mask = 1 << (nr & 0x1f); + __save_flags(flags); + __cli(); + retval = (mask & *a) != 0; + *a |= mask; + __restore_flags(flags); + + return retval; +} + +extern __inline__ int clear_bit(int nr, void * addr) +{ + int mask, retval; + int *a = addr; + __flags; + + a += nr >> 5; + mask = 1 << (nr & 0x1f); + __save_flags(flags); + __cli(); + retval = (mask & *a) != 0; + *a &= ~mask; + __restore_flags(flags); + + return retval; +} + +extern __inline__ int change_bit(int nr, void * addr) +{ + int mask, retval; + int *a = addr; + __flags; + + a += nr >> 5; + mask = 1 << (nr & 0x1f); + __save_flags(flags); + __cli(); + retval = (mask & *a) != 0; + *a ^= mask; + __restore_flags(flags); + + return retval; +} + +#undef __flags +#undef __cli() +#undef __save_flags(x) +#undef __restore_flags(x) + +#endif /* !defined(__R4000__) */ + +extern __inline__ int test_bit(int nr, void *addr) { int mask; - int *a; + unsigned long *a; a = addr; addr += nr >> 5; @@ -68,11 +146,7 @@ extern inline int test_bit(int nr, void *addr) return ((mask & *a) != 0); } - -/* - * The above written is not true for the bitfield functions. - */ -static inline int find_first_zero_bit (void *addr, unsigned size) +extern __inline__ int find_first_zero_bit (void *addr, unsigned size) { int res; @@ -96,17 +170,17 @@ static inline int find_first_zero_bit (void *addr, unsigned size) ".set\tat\n\t" ".set\treorder\n" "2:" - : "=d" (res) - : "d" ((unsigned int) 0xffffffff), - "d" (size), + : "=r" (res) + : "r" ((unsigned int) 0xffffffff), + "r" (size), "0" ((signed int) 0), - "d" (addr) + "r" (addr) : "$1"); return res; } -static inline int find_next_zero_bit (void * addr, int size, int offset) +extern __inline__ int find_next_zero_bit (void * addr, int size, int offset) { unsigned long * p = ((unsigned long *) addr) + (offset >> 5); int set = 0, bit = offset & 31, res; @@ -127,7 +201,8 @@ static inline int find_next_zero_bit (void * addr, int size, int offset) : "=r" (set) : "r" (*p >> bit), "r" (1), - "0" (0)); + "0" (0) + : "$1"); if (set < (32 - bit)) return set + offset; set = 32 - bit; @@ -144,7 +219,7 @@ static inline int find_next_zero_bit (void * addr, int size, int offset) * ffz = Find First Zero in word. Undefined if no zero exists, * so code should check against ~0UL first.. */ -extern inline unsigned long ffz(unsigned long word) +extern __inline__ unsigned long ffz(unsigned long word) { unsigned int __res; unsigned int mask = 1; @@ -154,10 +229,10 @@ extern inline unsigned long ffz(unsigned long word) ".set\tnoat\n\t" "li\t%2,1\n" "1:\tand\t$1,%2,%1\n\t" - "beq\t$0,$1,2f\n\t" - "sll\t%2,%2,1\n\t" - "bne\t$0,%2,1b\n\t" - "add\t%0,%0,1\n\t" + "beqz\t$1,2f\n\t" + "sll\t%2,1\n\t" + "bnez\t%2,1b\n\t" + "addiu\t%0,1\n\t" ".set\tat\n\t" ".set\treorder\n" "2:\n\t" @@ -170,4 +245,4 @@ extern inline unsigned long ffz(unsigned long word) return __res; } -#endif /* _ASM_MIPS_BITOPS_H */ +#endif /* __ASM_MIPS_BITOPS_H */ diff --git a/include/asm-mips/bootinfo.h b/include/asm-mips/bootinfo.h index 4ff415bf1..594b45b5d 100644 --- a/include/asm-mips/bootinfo.h +++ b/include/asm-mips/bootinfo.h @@ -1,8 +1,8 @@ /* - * bootinfo.h -- Definition of the Linux/68K boot information structure + * bootinfo.h -- Definition of the Linux/MIPS boot information structure * - * Written by Ralf Baechle, - * Copyright (C) 1994 by Waldorf GMBH + * Copyright (C) 1994 by Waldorf Electronics + * Written by Ralf Baechle and Andreas Busse * * Based on Linux/68k linux/include/linux/bootstrap.h * Copyright (C) 1992 by Greg Harp @@ -11,53 +11,238 @@ * License. See the file README.legal in the main directory of this archive * for more details. */ - -#ifndef ASM_MIPS_BOOTINFO_H -#define ASM_MIPS_BOOTINFO_H +#ifndef __ASM_MIPS_BOOTINFO_H +#define __ASM_MIPS_BOOTINFO_H /* - * Valid values for machtype field + * Valid machtype values */ -#define MACH_DESKSTATION_TYNE 1 /* Deskstation Tyne */ +#define MACH_UNKNOWN 0 /* whatever... */ +#define MACH_DESKSTATION_RPC44 1 /* Deskstation rPC44 */ +#define MACH_DESKSTATION_TYNE 2 /* Deskstation Tyne */ +#define MACH_ACER_PICA_61 3 /* Acer PICA-61 (PICA1) */ +#define MACH_MIPS_MAGNUM_4000 4 /* Mips Magnum 4000 "RC4030" */ +#define MACH_OLIVETTI_M700 5 /* Olivetti M700 */ /* - * Type of CPU + * Valid cputype values */ -#define CPU_R4600 1 +#define CPU_UNKNOWN 0 +#define CPU_R2000 1 +#define CPU_R3000 2 +#define CPU_R3000A 3 +#define CPU_R3041 4 +#define CPU_R3051 5 +#define CPU_R3052 6 +#define CPU_R3081 7 +#define CPU_R3081E 8 +#define CPU_R4000PC 9 +#define CPU_R4000SC 10 +#define CPU_R4000MC 11 +#define CPU_R4200 12 +#define CPU_R4400PC 13 +#define CPU_R4400SC 14 +#define CPU_R4400MC 15 +#define CPU_R4600 16 +#define CPU_R6000 17 +#define CPU_R6000A 18 +#define CPU_R8000 19 +#define CPU_R10000 20 +#define CPU_LAST 20 + +#define CPU_NAMES { "UNKNOWN", "R2000", "R3000", "R3000A", "R3041", "R3051", \ + "R3052", "R3081", "R3081E", "R4000PC", "R4000SC", "R4000MC", \ + "R4200", "R4400PC", "R4400SC", "R4400MC", "R4600", "R6000", \ + "R6000A", "R8000", "R10000" } #define CL_SIZE (80) +#ifndef __LANGUAGE_ASSEMBLY__ + +/* + * Some machine parameters passed by MILO. Note that bootinfo + * *must* be in the data segment since the kernel clears the + * bss segment directly after startup. + */ + +struct drive_info_struct { + char dummy[32]; + }; + struct bootinfo { - unsigned long - machtype; /* machine type */ + /* + * machine type + */ + unsigned long machtype; + + /* + * system CPU & FPU + */ + unsigned long cputype; + + /* + * Installed RAM + */ + unsigned long memlower; + unsigned long memupper; + + /* + * Cache Sizes (0xffffffff = unknown) + */ + unsigned long icache_size; + unsigned long icache_linesize; + unsigned long dcache_size; + unsigned long dcache_linesize; + unsigned long scache_size; + unsigned long scache_linesize; + + /* + * TLB Info + */ + unsigned long tlb_entries; + + /* + * DMA buffer size (Deskstation only) + */ + unsigned long dma_cache_size; + unsigned long dma_cache_base; + + /* + * Ramdisk Info + */ + unsigned long ramdisk_size; /* ramdisk size in 1024 byte blocks */ + unsigned long ramdisk_base; /* address of the ram disk in mem */ + + /* + * Boot flags for the kernel + */ + unsigned long mount_root_rdonly; + struct drive_info_struct drive_info; + + /* + * Video ram info (not in tty.h) + */ + unsigned long vram_base; /* video ram base address */ + + char command_line[CL_SIZE]; /* kernel command line parameters */ + +}; - unsigned long - cputype; /* system CPU & FPU */ +#if 0 +/* + * New style bootinfo + * + * Add new tags only at the end of the enum; *never* remove any tags + * or you'll break compatibility! + */ +enum bi_tag { + /* + * not a real tag + */ + dummy, + + /* + * machine type + */ + machtype, - /* - * Installed RAM - */ - unsigned int memlower; - unsigned int memupper; + /* + * system CPU & FPU + */ + cputype, - /* - * Cache Information - */ - unsigned int sec_cache; - unsigned int dma_cache; + /* + * Installed RAM + */ + memlower, + memupper, - unsigned long - ramdisk_size; /* ramdisk size in 1024 byte blocks */ + /* + * Cache Sizes (0xffffffff = unknown) + */ + icache_size, + icache_linesize, + dcache_size, + dcache_linesize, + scache_size, + scache_linesize, - unsigned long - ramdisk_addr; /* address of the ram disk in mem */ + /* + * TLB Info + */ + tlb_entries, - char - command_line[CL_SIZE]; /* kernel command line parameters */ + /* + * DMA buffer size (Deskstation only) + */ + dma_cache_size, + dma_cache_base, + /* + * Ramdisk Info + */ + ramdisk_size, /* ramdisk size in 1024 byte blocks */ + ramdisk_base, /* address of the ram disk in mem */ + + /* + * Boot flags for the kernel + */ + mount_root_rdonly, + drive_info, + + /* + * Video ram info (not in tty.h) + */ + vram_base, /* video ram base address */ + + command_line /* kernel command line parameters */ + }; -extern struct bootinfo - boot_info; +typedef struct { + bi_tag tag; + unsigned long size; +} tag; +#endif + +extern struct bootinfo boot_info; + +/* + * Defaults, may be overwritten by milo. We initialize + * them to make sure that both boot_info and screen_info + * are in the .data segment since the .bss segment is + * cleared during startup. + */ +#define BOOT_INFO { 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, {{0,}}, 0, "" } +#define SCREEN_INFO {0, 0, {0, }, 52, 3, 80, 4626, 3, 9, 50} + +#else /* !__LANGUAGE_ASSEMBLY__ */ + +/* + * Same structure, but as offsets for usage within assembler source. + * Don't mess with struct bootinfo without changing offsets too! + */ + +#define OFFSET_BOOTINFO_MACHTYPE 0 +#define OFFSET_BOOTINFO_CPUTYPE 4 +#define OFFSET_BOOTINFO_MEMLOWER 8 +#define OFFSET_BOOTINFO_MEMUPPER 12 +#define OFFSET_BOOTINFO_ICACHE_SIZE 16 +#define OFFSET_BOOTINFO_ICACHE_LINESIZE 20 +#define OFFSET_BOOTINFO_DCACHE_SIZE 24 +#define OFFSET_BOOTINFO_DCACHE_LINESIZE 28 +#define OFFSET_BOOTINFO_SCACHE_SIZE 32 +#define OFFSET_BOOTINFO_SCACHE_LINESIZE 36 +#define OFFSET_BOOTINFO_TLB_ENTRIES 40 +#define OFFSET_BOOTINFO_DMA_CACHE_SIZE 44 +#define OFFSET_BOOTINFO_DMA_CACHE_BASE 48 +#define OFFSET_BOOTINFO_RAMDISK_SIZE 52 +#define OFFSET_BOOTINFO_RAMDISK_BASE 56 +#define OFFSET_BOOTINFO_MOUNT_RD_ONLY 60 +#define OFFSET_BOOTINFO_DRIVE_INFO 64 +#define OFFSET_BOOTINFO_VRAM_BASE 96 +#define OFFSET_BOOTINFO_COMMAND_LINE 100 + +#endif /* __LANGUAGE_ASSEMBLY__ */ -#endif /* ASM_MIPS_BOOTINFO_H */ +#endif /* __ASM_MIPS_BOOTINFO_H */ diff --git a/include/asm-mips/bugs.h b/include/asm-mips/bugs.h new file mode 100644 index 000000000..41ca73366 --- /dev/null +++ b/include/asm-mips/bugs.h @@ -0,0 +1,36 @@ +/* + * include/asm-mips/bugs.h + * + * Copyright (C) 1995 Waldorf Electronics + * written by Ralf Baechle + */ +#include <asm/bootinfo.h> + +/* + * This is included by init/main.c to check for architecture-dependent bugs. + * + * Needs: + * void check_bugs(void); + */ + +extern struct bootinfo boot_info; + +static void check_wait(void) +{ + printk("Checking for 'wait' instruction... "); + switch(boot_info.cputype) { + case CPU_R4200: + case CPU_R4600: + wait_available = 1; + printk(" available.\n"); + break; + default: + printk(" unavailable.\n"); + break; + } +} + +static void check_bugs(void) +{ + check_wait(); +} diff --git a/include/asm-mips/byteorder.h b/include/asm-mips/byteorder.h new file mode 100644 index 000000000..45abf2350 --- /dev/null +++ b/include/asm-mips/byteorder.h @@ -0,0 +1,94 @@ +#ifndef __ASM_MIPS_BYTEORDER_H +#define __ASM_MIPS_BYTEORDER_H + +/* + * FIXME: Add big endian support + */ +#undef ntohl +#undef ntohs +#undef htonl +#undef htons + +#ifdef __MIPSEL__ +#ifndef LITTLE_ENDIAN +#define LITTLE_ENDIAN 1234 +#endif + +#ifndef LITTLE_ENDIAN_BITFIELD +#define LITTLE_ENDIAN_BITFIELD +#endif +#elif __MIPSEB__ +#define BIG_ENDIAN 4321 +#define BIG_ENDIAN_BITFIELD +#else +#error "MIPS but neither __MIPSEL__ nor __MIPSEB__?" +#endif + +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); + +extern unsigned long int __ntohl(unsigned long int); +extern unsigned short int __ntohs(unsigned short int); +extern unsigned long int __constant_ntohl(unsigned long int); +extern unsigned short int __constant_ntohs(unsigned short int); + +/* + * The constant and non-constant versions here are the same. + * Maybe I'll come up with an mips-optimized routine for the + * non-constant ones (the constant ones don't need it: gcc + * will optimize it to the correct constant) + */ + +extern __inline__ unsigned long int +__ntohl(unsigned long int x) +{ + return (((x & 0x000000ffU) << 24) | + ((x & 0x0000ff00U) << 8) | + ((x & 0x00ff0000U) >> 8) | + ((x & 0xff000000U) >> 24)); +} + +#define __constant_ntohl(x) \ + ((unsigned long int)((((unsigned long int)(x) & 0x000000ffU) << 24) | \ + (((unsigned long int)(x) & 0x0000ff00U) << 8) | \ + (((unsigned long int)(x) & 0x00ff0000U) >> 8) | \ + (((unsigned long int)(x) & 0xff000000U) >> 24))) + +extern __inline__ unsigned short int +__ntohs(unsigned short int x) +{ + return (((x & 0x00ff) << 8) | + ((x & 0xff00) >> 8)); +} + +#define __constant_ntohs(x) \ + ((unsigned short int)((((unsigned short int)(x) & 0x00ff) << 8) | \ + (((unsigned short int)(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 /* __ASM_MIPS_BYTEORDER_H */ diff --git a/include/asm-mips/cachectl.h b/include/asm-mips/cachectl.h index 167727c97..68105fb69 100644 --- a/include/asm-mips/cachectl.h +++ b/include/asm-mips/cachectl.h @@ -3,11 +3,9 @@ * * Written by Ralf Baechle, * Copyright (C) 1994 by Waldorf GMBH - * - * Defines for Risc/OS compatible cacheflush systemcall */ -#ifndef _ASM_MIPS_CACHECTL -#define _ASM_MIPS_CACHECTL +#ifndef __ASM_MIPS_CACHECTL +#define __ASM_MIPS_CACHECTL /* * cachectl.h -- defines for MIPS cache control system calls @@ -20,13 +18,20 @@ #define DCACHE (1<<1) /* writeback and flush data cache */ #define BCACHE (ICACHE|DCACHE) /* flush both caches */ -#define CACHELINES 512 /* number of cachelines */ +#define CACHELINES 512 /* number of cachelines (kludgy) */ + +/* + * Cache Operations - for use by assembler code + */ +#define Index_Invalidate_I 0x00 +#define Index_Writeback_Inv_D 0x01 +#define Index_Load_Tag_D 0x05 #ifdef __KERNEL__ -#ifndef __ASSEMBLY__ +#ifndef __LANGUAGE_ASSEMBLY__ extern int sys_cacheflush(void *addr, int nbytes, int cache); #endif #endif -#endif /* _ASM_MIPS_CACHECTL */ +#endif /* __ASM_MIPS_CACHECTL */ diff --git a/include/asm-mips/delay.h b/include/asm-mips/delay.h index 5aa85e165..b35498dc1 100644 --- a/include/asm-mips/delay.h +++ b/include/asm-mips/delay.h @@ -1,5 +1,5 @@ -#ifndef _ASM_MIPS_DELAY_H -#define _ASM_MIPS_DELAY_H +#ifndef __ASM_MIPS_DELAY_H +#define __ASM_MIPS_DELAY_H extern __inline__ void __delay(int loops) { @@ -27,10 +27,20 @@ extern __inline__ void __delay(int loops) extern __inline__ void udelay(unsigned long usecs) { usecs *= 0x000010c6; /* 2**32 / 1000000 */ - __asm__("mul\t%0,%0,%1" + __asm__("multu\t%0,%1\n\t" + "mfhi\t%0" :"=r" (usecs) :"0" (usecs),"r" (loops_per_sec)); __delay(usecs); } -#endif /* defined (_ASM_MIPS_DELAY_H) */ +/* + * The different variants for 32/64 bit are pure paranoia. The typical + * range of numbers that apprears for MIPS machines avoids overflows. + */ +extern __inline__ unsigned long muldiv(unsigned long a, unsigned long b, unsigned long c) +{ + return (a*b)/c; +} + +#endif /* __ASM_MIPS_DELAY_H */ diff --git a/include/asm-mips/dma.h b/include/asm-mips/dma.h index 7540aedec..14f1f0dae 100644 --- a/include/asm-mips/dma.h +++ b/include/asm-mips/dma.h @@ -3,10 +3,14 @@ * Written by Hennus Bergman, 1992. * High DMA channel support & info by Hannu Savolainen * and John Boyd, Nov. 1992. + * + * NOTE: all this is true *only* for ISA/EISA expansions on Mips boards + * and can only be used for expansion cards. Onboard DMA controller, such + * as the R4030 on Jazz boards behave totally different! */ -#ifndef _ASM_MIPS_DMA_H -#define _ASM_MIPS_DMA_H +#ifndef __ASM_MIPS_DMA_H +#define __ASM_MIPS_DMA_H #include <asm/io.h> /* need byte IO */ @@ -70,7 +74,10 @@ #define MAX_DMA_CHANNELS 8 /* The maximum address that we can perform a DMA transfer to on this platform */ -#define MAX_DMA_ADDRESS 0xffffff +#define MAX_DMA_ADDRESS 0x1000000 + +/* The maximum address that we can perform a DMA transfer to on this platform */ +#define MAX_DMA_ADDRESS 0x1000000 /* 8237 DMA controllers */ #define IO_DMA1_BASE 0x00 /* 8 bit slave DMA, channels 0..3 */ @@ -264,8 +271,8 @@ static __inline__ int get_dma_residue(unsigned int dmanr) /* These are in kernel/dma.c: */ -extern int request_dma(unsigned int dmanr, char * deviceID); /* reserve a DMA channel */ +extern int request_dma(unsigned int dmanr, char * device_id); /* reserve a DMA channel */ extern void free_dma(unsigned int dmanr); /* release it again */ -#endif /* _ASM_MIPS_DMA_H */ +#endif /* __ASM_MIPS_DMA_H */ diff --git a/include/asm-mips/errno.h b/include/asm-mips/errno.h new file mode 100644 index 000000000..f31e2b19f --- /dev/null +++ b/include/asm-mips/errno.h @@ -0,0 +1,143 @@ +/* + * include/asm-mips/errno.h + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file "COPYING" in the main directory of this archive + * for more details. + * + * Copyright (C) 1995 by Ralf Baechle + */ +#ifndef __ASM_MIPS_ERRNO_H +#define __ASM_MIPS_ERRNO_H + +/* + * These error numbers are intended to be MIPS ABI compatible + */ +#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 ENOMSG 35 /* No message of desired type */ +#define EIDRM 36 /* Identifier removed */ +#define ECHRNG 37 /* Channel number out of range */ +#define EL2NSYNC 38 /* Level 2 not synchronized */ +#define EL3HLT 39 /* Level 3 halted */ +#define EL3RST 40 /* Level 3 reset */ +#define ELNRNG 41 /* Link number out of range */ +#define EUNATCH 42 /* Protocol driver not attached */ +#define ENOCSI 43 /* No CSI structure available */ +#define EL2HLT 44 /* Level 2 halted */ +#define EDEADLK 45 /* Resource deadlock would occur */ +#define ENOLCK 46 /* No record locks available */ +#define EBADE 50 /* Invalid exchange */ +#define EBADR 51 /* Invalid request descriptor */ +#define EXFULL 52 /* Exchange full */ +#define ENOANO 53 /* No anode */ +#define EBADRQC 54 /* Invalid request code */ +#define EBADSLT 55 /* Invalid slot */ +#define EDEADLOCK 56 /* 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 EDOTDOT 73 /* RFS specific error */ +#define EMULTIHOP 74 /* Multihop attempted */ +#define EBADMSG 77 /* Not a data message */ +#define ENAMETOOLONG 78 /* File name too long */ +#define EOVERFLOW 79 /* Value too large for defined data type */ +#define ENOTUNIQ 80 /* Name not unique on network */ +#define EBADFD 81 /* File descriptor in bad state */ +#define EREMCHG 82 /* Remote address changed */ +#define ELIBACC 83 /* Can not access a needed shared library */ +#define ELIBBAD 84 /* Accessing a corrupted shared library */ +#define ELIBSCN 85 /* .lib section in a.out corrupted */ +#define ELIBMAX 86 /* Attempting to link in too many shared libraries */ +#define ELIBEXEC 87 /* Cannot exec a shared library directly */ +#define EILSEQ 88 /* Illegal byte sequence */ +#define ENOSYS 89 /* Function not implemented */ +#define ELOOP 90 /* Too many symbolic links encountered */ +#define ERESTART 91 /* Interrupted system call should be restarted */ +#define ESTRPIPE 92 /* Streams pipe error */ +#define ENOTEMPTY 93 /* Directory not empty */ +#define EUSERS 94 /* Too many users */ +#define ENOTSOCK 95 /* Socket operation on non-socket */ +#define EDESTADDRREQ 96 /* Destination address required */ +#define EMSGSIZE 97 /* Message too long */ +#define EPROTOTYPE 98 /* Protocol wrong type for socket */ +#define ENOPROTOOPT 99 /* Protocol not available */ +#define EPROTONOSUPPORT 120 /* Protocol not supported */ +#define ESOCKTNOSUPPORT 121 /* Socket type not supported */ +#define EOPNOTSUPP 122 /* Operation not supported on transport endpoint */ +#define EPFNOSUPPORT 123 /* Protocol family not supported */ +#define EAFNOSUPPORT 124 /* Address family not supported by protocol */ +#define EADDRINUSE 125 /* Address already in use */ +#define EADDRNOTAVAIL 126 /* Cannot assign requested address */ +#define ENETDOWN 127 /* Network is down */ +#define ENETUNREACH 128 /* Network is unreachable */ +#define ENETRESET 129 /* Network dropped connection because of reset */ +#define ECONNABORTED 130 /* Software caused connection abort */ +#define ECONNRESET 131 /* Connection reset by peer */ +#define ENOBUFS 132 /* No buffer space available */ +#define EISCONN 133 /* Transport endpoint is already connected */ +#define ENOTCONN 134 /* Transport endpoint is not connected */ +#define EUCLEAN 135 /* Structure needs cleaning */ +#define ENOTNAM 137 /* Not a XENIX named type file */ +#define ENAVAIL 138 /* No XENIX semaphores available */ +#define EISNAM 139 /* Is a named type file */ +#define EREMOTEIO 140 /* Remote I/O error */ +#define EINIT 141 /* Reserved */ +#define EREMDEV 142 /* Error 142 */ +#define ESHUTDOWN 143 /* Cannot send after transport endpoint shutdown */ +#define ETOOMANYREFS 144 /* Too many references: cannot splice */ +#define ETIMEDOUT 145 /* Connection timed out */ +#define ECONNREFUSED 146 /* Connection refused */ +#define EHOSTDOWN 147 /* Host is down */ +#define EHOSTUNREACH 148 /* No route to host */ +#define EWOULDBLOCK EAGAIN /* Operation would block */ +#define EALREADY 149 /* Operation already in progress */ +#define EINPROGRESS 150 /* Operation now in progress */ +#define ESTALE 151 /* Stale NFS file handle */ +#define ECANCELED 158 /* AIO operation canceled */ +#define EDQUOT 1133 /* Quota exceeded */ +#define ENFSREMOTE 1134 /* ??? */ + +#endif /* __ASM_MIPS_ERRNO_H */ diff --git a/include/asm-mips/fcntl.h b/include/asm-mips/fcntl.h new file mode 100644 index 000000000..2a41e3da9 --- /dev/null +++ b/include/asm-mips/fcntl.h @@ -0,0 +1,67 @@ +#ifndef _I386_FCNTL_H +#define _I386_FCNTL_H + +/* open/fcntl - O_SYNC is only implemented on blocks devices and on files + located on an ext2 file system */ +#define O_ACCMODE 0x0003 +#define O_RDONLY 0x0000 +#define O_WRONLY 0x0001 +#define O_RDWR 0x0002 +#define O_APPEND 0x0008 +#define O_SYNC 0x0010 +#define O_NONBLOCK 0x0080 +#define O_CREAT 0x0100 /* not fcntl */ +#define O_TRUNC 0x0200 /* not fcntl */ +#define O_EXCL 0x0400 /* not fcntl */ +#define O_NOCTTY 0x0800 /* not fcntl */ +#define FASYNC 0x1000 /* fcntl, for BSD compatibility */ + +#define O_NDELAY O_NONBLOCK + +#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 14 +#define F_SETLK 6 +#define F_SETLKW 7 + +#define F_SETOWN 24 /* for sockets. */ +#define F_GETOWN 23 /* for sockets. */ + +/* for F_[GET|SET]FL */ +#define FD_CLOEXEC 1 /* actually anything with low bit set goes */ + +/* for posix fcntl() and lockf() */ +#define F_RDLCK 0 +#define F_WRLCK 1 +#define F_UNLCK 2 + +/* for old implementation of bsd flock () */ +#define F_EXLCK 4 /* or 3 */ +#define F_SHLCK 8 /* or 4 */ + +/* operations for bsd flock(), also used by the kernel implementation */ +#define LOCK_SH 1 /* shared lock */ +#define LOCK_EX 2 /* exclusive lock */ +#define LOCK_NB 4 /* or'd with one of the above to prevent XXXXXXXXXXXXXXXXXX + blocking */ +#define LOCK_UN 8 /* remove lock */ + +#ifdef __KERNEL__ +#define F_POSIX 1 +#define F_FLOCK 2 +#endif /* __KERNEL__ */ + +typedef struct flock { + short l_type; + short l_whence; + off_t l_start; + off_t l_len; + long l_sysid; /* XXXXXXXXXXXXXXXXXXXXXXXXX */ + pid_t l_pid; + long pad[4]; /* ZZZZZZZZZZZZZZZZZZZZZZZZZZ */ +} flock_t; + +#endif diff --git a/include/asm-mips/gdb-stub.h b/include/asm-mips/gdb-stub.h new file mode 100644 index 000000000..d85ce077f --- /dev/null +++ b/include/asm-mips/gdb-stub.h @@ -0,0 +1,211 @@ +/* + * include/asm-mips/gdb-stub.h + * + * Copyright (C) 1995 Andreas Busse + */ + +#ifndef __ASM_MIPS_GDB_STUB_H +#define __ASM_MIPS_GDB_STUB_H + + +/* + * important register numbers + */ + +#define REG_EPC 37 +#define REG_FP 72 +#define REG_SP 29 + +/* + * Stack layout for the GDB exception handler + * Derived from the stack layout described in asm-mips/stackframe.h + * + * The first PTRSIZE*5 bytes are argument save space for C subroutines. + */ +#define NUMREGS 90 + +#define GDB_FR_REG0 (PTRSIZE*5) /* 0 */ +#define GDB_FR_REG1 ((GDB_FR_REG0) + 4) /* 1 */ +#define GDB_FR_REG2 ((GDB_FR_REG1) + 4) /* 2 */ +#define GDB_FR_REG3 ((GDB_FR_REG2) + 4) /* 3 */ +#define GDB_FR_REG4 ((GDB_FR_REG3) + 4) /* 4 */ +#define GDB_FR_REG5 ((GDB_FR_REG4) + 4) /* 5 */ +#define GDB_FR_REG6 ((GDB_FR_REG5) + 4) /* 6 */ +#define GDB_FR_REG7 ((GDB_FR_REG6) + 4) /* 7 */ +#define GDB_FR_REG8 ((GDB_FR_REG7) + 4) /* 8 */ +#define GDB_FR_REG9 ((GDB_FR_REG8) + 4) /* 9 */ +#define GDB_FR_REG10 ((GDB_FR_REG9) + 4) /* 10 */ +#define GDB_FR_REG11 ((GDB_FR_REG10) + 4) /* 11 */ +#define GDB_FR_REG12 ((GDB_FR_REG11) + 4) /* 12 */ +#define GDB_FR_REG13 ((GDB_FR_REG12) + 4) /* 13 */ +#define GDB_FR_REG14 ((GDB_FR_REG13) + 4) /* 14 */ +#define GDB_FR_REG15 ((GDB_FR_REG14) + 4) /* 15 */ +#define GDB_FR_REG16 ((GDB_FR_REG15) + 4) /* 16 */ +#define GDB_FR_REG17 ((GDB_FR_REG16) + 4) /* 17 */ +#define GDB_FR_REG18 ((GDB_FR_REG17) + 4) /* 18 */ +#define GDB_FR_REG19 ((GDB_FR_REG18) + 4) /* 19 */ +#define GDB_FR_REG20 ((GDB_FR_REG19) + 4) /* 20 */ +#define GDB_FR_REG21 ((GDB_FR_REG20) + 4) /* 21 */ +#define GDB_FR_REG22 ((GDB_FR_REG21) + 4) /* 22 */ +#define GDB_FR_REG23 ((GDB_FR_REG22) + 4) /* 23 */ +#define GDB_FR_REG24 ((GDB_FR_REG23) + 4) /* 24 */ +#define GDB_FR_REG25 ((GDB_FR_REG24) + 4) /* 25 */ +#define GDB_FR_REG26 ((GDB_FR_REG25) + 4) /* 26 */ +#define GDB_FR_REG27 ((GDB_FR_REG26) + 4) /* 27 */ +#define GDB_FR_REG28 ((GDB_FR_REG27) + 4) /* 28 */ +#define GDB_FR_REG29 ((GDB_FR_REG28) + 4) /* 29 */ +#define GDB_FR_REG30 ((GDB_FR_REG29) + 4) /* 30 */ +#define GDB_FR_REG31 ((GDB_FR_REG30) + 4) /* 31 */ + +/* + * Saved special registers + */ +#define GDB_FR_STATUS ((GDB_FR_REG31) + 4) /* 32 */ +#define GDB_FR_LO ((GDB_FR_STATUS) + 4) /* 33 */ +#define GDB_FR_HI ((GDB_FR_LO) + 4) /* 34 */ +#define GDB_FR_BADVADDR ((GDB_FR_HI) + 4) /* 35 */ +#define GDB_FR_CAUSE ((GDB_FR_BADVADDR) + 4) /* 36 */ +#define GDB_FR_EPC ((GDB_FR_CAUSE) + 4) /* 37 */ + +/* + * Saved floating point registers + */ +#define GDB_FR_FPR0 ((GDB_FR_EPC) + 4) /* 38 */ +#define GDB_FR_FPR1 ((GDB_FR_FPR0) + 4) /* 39 */ +#define GDB_FR_FPR2 ((GDB_FR_FPR1) + 4) /* 40 */ +#define GDB_FR_FPR3 ((GDB_FR_FPR2) + 4) /* 41 */ +#define GDB_FR_FPR4 ((GDB_FR_FPR3) + 4) /* 42 */ +#define GDB_FR_FPR5 ((GDB_FR_FPR4) + 4) /* 43 */ +#define GDB_FR_FPR6 ((GDB_FR_FPR5) + 4) /* 44 */ +#define GDB_FR_FPR7 ((GDB_FR_FPR6) + 4) /* 45 */ +#define GDB_FR_FPR8 ((GDB_FR_FPR7) + 4) /* 46 */ +#define GDB_FR_FPR9 ((GDB_FR_FPR8) + 4) /* 47 */ +#define GDB_FR_FPR10 ((GDB_FR_FPR9) + 4) /* 48 */ +#define GDB_FR_FPR11 ((GDB_FR_FPR10) + 4) /* 49 */ +#define GDB_FR_FPR12 ((GDB_FR_FPR11) + 4) /* 50 */ +#define GDB_FR_FPR13 ((GDB_FR_FPR12) + 4) /* 51 */ +#define GDB_FR_FPR14 ((GDB_FR_FPR13) + 4) /* 52 */ +#define GDB_FR_FPR15 ((GDB_FR_FPR14) + 4) /* 53 */ +#define GDB_FR_FPR16 ((GDB_FR_FPR15) + 4) /* 54 */ +#define GDB_FR_FPR17 ((GDB_FR_FPR16) + 4) /* 55 */ +#define GDB_FR_FPR18 ((GDB_FR_FPR17) + 4) /* 56 */ +#define GDB_FR_FPR19 ((GDB_FR_FPR18) + 4) /* 57 */ +#define GDB_FR_FPR20 ((GDB_FR_FPR19) + 4) /* 58 */ +#define GDB_FR_FPR21 ((GDB_FR_FPR20) + 4) /* 59 */ +#define GDB_FR_FPR22 ((GDB_FR_FPR21) + 4) /* 60 */ +#define GDB_FR_FPR23 ((GDB_FR_FPR22) + 4) /* 61 */ +#define GDB_FR_FPR24 ((GDB_FR_FPR23) + 4) /* 62 */ +#define GDB_FR_FPR25 ((GDB_FR_FPR24) + 4) /* 63 */ +#define GDB_FR_FPR26 ((GDB_FR_FPR25) + 4) /* 64 */ +#define GDB_FR_FPR27 ((GDB_FR_FPR26) + 4) /* 65 */ +#define GDB_FR_FPR28 ((GDB_FR_FPR27) + 4) /* 66 */ +#define GDB_FR_FPR29 ((GDB_FR_FPR28) + 4) /* 67 */ +#define GDB_FR_FPR30 ((GDB_FR_FPR29) + 4) /* 68 */ +#define GDB_FR_FPR31 ((GDB_FR_FPR30) + 4) /* 69 */ + +#define GDB_FR_FSR ((GDB_FR_FPR31) + 4) /* 70 */ +#define GDB_FR_FIR ((GDB_FR_FSR) + 4) /* 71 */ +#define GDB_FR_FRP ((GDB_FR_FIR) + 4) /* 72 */ + +#define GDB_FR_DUMMY ((GDB_FR_FRP) + 4) /* 73, unused ??? */ + +/* + * Again, CP0 registers + */ +#define GDB_FR_CP0_INDEX ((GDB_FR_DUMMY) + 4) /* 74 */ +#define GDB_FR_CP0_RANDOM ((GDB_FR_CP0_INDEX) + 4) /* 75 */ +#define GDB_FR_CP0_ENTRYLO0 ((GDB_FR_CP0_RANDOM) + 4) /* 76 */ +#define GDB_FR_CP0_ENTRYLO1 ((GDB_FR_CP0_ENTRYLO0) + 4) /* 77 */ +#define GDB_FR_CP0_REG4 ((GDB_FR_CP0_ENTRYLO1) + 4) /* 78 */ +#define GDB_FR_CP0_PAGEMASK ((GDB_FR_CP0_REG4) + 4) /* 79 */ +#define GDB_FR_CP0_WIRED ((GDB_FR_CP0_PAGEMASK) + 4) /* 80 */ +#define GDB_FR_CP0_REG7 ((GDB_FR_CP0_WIRED) + 4) /* 81 */ +#define GDB_FR_CP0_REG8 ((GDB_FR_CP0_REG7) + 4) /* 82 */ +#define GDB_FR_CP0_REG9 ((GDB_FR_CP0_REG8) + 4) /* 83 */ +#define GDB_FR_CP0_ENTRYHI ((GDB_FR_CP0_REG9) + 4) /* 84 */ +#define GDB_FR_CP0_REG11 ((GDB_FR_CP0_ENTRYHI) + 4) /* 85 */ +#define GDB_FR_CP0_REG12 ((GDB_FR_CP0_REG11) + 4) /* 86 */ +#define GDB_FR_CP0_REG13 ((GDB_FR_CP0_REG12) + 4) /* 87 */ +#define GDB_FR_CP0_REG14 ((GDB_FR_CP0_REG13) + 4) /* 88 */ +#define GDB_FR_CP0_PRID ((GDB_FR_CP0_REG14) + 4) /* 89 */ + +#define GDB_FR_SIZE ((((GDB_FR_CP0_PRID) + 4) + (PTRSIZE-1)) & ~(PTRSIZE-1)) + +#ifndef __LANGUAGE_ASSEMBLY__ + +/* + * This is the same as above, but for the high-level + * part of the GDB stub. + */ + +struct gdb_regs { + /* + * Pad bytes for argument save space on the stack + * 20/40 Bytes for 32/64 bit code + */ + unsigned long pad0[5]; + + /* + * saved main processor registers + */ + long reg0, reg1, reg2, reg3, reg4, reg5, reg6, reg7; + long reg8, reg9, reg10, reg11, reg12, reg13, reg14, reg15; + long reg16, reg17, reg18, reg19, reg20, reg21, reg22, reg23; + long reg24, reg25, reg26, reg27, reg28, reg29, reg30, reg31; + + /* + * Saved special registers + */ + long cp0_status; + long lo; + long hi; + long cp0_badvaddr; + long cp0_cause; + long cp0_epc; + + /* + * Saved floating point registers + */ + long fpr0, fpr1, fpr2, fpr3, fpr4, fpr5, fpr6, fpr7; + long fpr8, fpr9, fpr10, fpr11, fpr12, fpr13, fpr14, fpr15; + long fpr16, fpr17, fpr18, fpr19, fpr20, fpr21, fpr22, fpr23; + long fpr24, fpr25, fpr26, fpr27, fpr28, fpr29, fpr30, fpr31; + + long cp1_fsr; + long cp1_fir; + + /* + * Frame pointer + */ + long frame_ptr; + long dummy; /* unused */ + + /* + * saved cp0 registers + */ + long cp0_index; + long cp0_random; + long cp0_entrylo0; + long cp0_entrylo1; + long cp0_reg4; + long cp0_pagemask; + long cp0_wired; + long cp0_reg7; + long cp0_reg8; + long cp0_reg9; + long cp0_entryhi; + long cp0_reg11; + long cp0_reg12; + long cp0_reg13; + long cp0_reg14; + long cp0_prid; +}; + +/* + * Prototypes + */ + +void set_debug_traps(void); + +#endif /* __LANGUAGE_ASSEMBLY */ +#endif /* __ASM_MIPS_GDB_STUB_H */ diff --git a/include/asm-mips/head.h b/include/asm-mips/head.h deleted file mode 100644 index e0e01ec52..000000000 --- a/include/asm-mips/head.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef _ASM_MIPS_HEAD_H -#define _ASM_MIPS_HEAD_H - -#include <linux/types.h> - -extern unsigned long swapper_pg_dir[1024]; -extern ulong IRQ_vectors[]; - -#endif diff --git a/include/asm-mips/in.h b/include/asm-mips/in.h deleted file mode 100644 index 18074abb9..000000000 --- a/include/asm-mips/in.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef _ASM_I386_IN_H -#define _ASM_I386_IN_H - -static __inline__ unsigned long int -__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) -{ - return (((x & 0x00ff) << 8) | - ((x & 0xff00) >> 8)); -} - -#define __htonl(x) __ntohl(x) -#define __htons(x) __ntohs(x) - -#ifdef __OPTIMIZE__ -# define ntohl(x) \ -(__ntohl((x))) -# define ntohs(x) \ -(__ntohs((x))) -# define htonl(x) \ -(__htonl((x))) -# define htons(x) \ -(__htons((x))) -#endif - -#endif /* _ASM_I386_IN_H */ diff --git a/include/asm-mips/interrupt.h b/include/asm-mips/interrupt.h deleted file mode 100644 index 6450b1698..000000000 --- a/include/asm-mips/interrupt.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef _ASM_MIPS_INTERRUPT_H -#define _ASM_MIPS_INTERRUPT_H - -extern inline void mark_bh(int nr) -{ - __asm__ __volatile__( - "1:\tll\t$8,(%0)\n\t" - "or\t$8,$8,%1\n\t" - "sc\t$8,(%0)\n\t" - "beq\t$0,$8,1b\n\t" - : "=m" (bh_active) - : "r" (1<<nr) - : "$8","memory"); -} - -extern inline void disable_bh(int nr) -{ - __asm__ __volatile__( - "1:\tll\t$8,(%0)\n\t" - "and\t$8,$8,%1\n\t" - "sc\t$8,(%0)\n\t" - "beq\t$0,$8,1b\n\t" - : "=m" (bh_mask) - : "r" (1<<nr) - : "$8","memory"); -} - -extern inline void enable_bh(int nr) -{ - __asm__ __volatile__( - "1:\tll\t$8,(%0)\n\t" - "or\t$8,$8,%1\n\t" - "sc\t$8,(%0)\n\t" - "beq\t$0,$8,1b\n\t" - : "=m" (bh_mask) - : "r" (1<<nr) - : "$8","memory"); -} - -#endif /* _ASM_MIPS_INTERRUPT_H */ diff --git a/include/asm-mips/io.h b/include/asm-mips/io.h index 16dbd1b46..94f099066 100644 --- a/include/asm-mips/io.h +++ b/include/asm-mips/io.h @@ -1,13 +1,13 @@ -#ifndef _ASM_IO_H -#define _ASM_IO_H +#ifndef __ASM_MIPS_IO_H +#define __ASM_MIPS_IO_H -#include <asm/mipsregs.h> #include <asm/mipsconfig.h> /* * This file contains the definitions for the MIPS counterpart of the * x86 in/out instructions. This heap of macros and C results in much - * better code than the approach of doing it in plain C. + * better code than the approach of doing it in plain C, though that's + * probably not needed. * * Ralf * @@ -37,7 +37,7 @@ #define __SLOW_DOWN_IO \ __asm__ __volatile__( \ "sb\t$0,0x80(%0)" \ - : : "d" (PORT_BASE)); + : : "r" (PORT_BASE)); #ifdef REALLY_SLOW_IO #define SLOW_DOWN_IO { __SLOW_DOWN_IO; __SLOW_DOWN_IO; __SLOW_DOWN_IO; __SLOW_DOWN_IO; } @@ -56,24 +56,27 @@ extern inline void __out##s(unsigned int value, unsigned int port) { __asm__ __volatile__ ("s" #m "\t%0,%1(%2)" #define __OUT(m,s) \ -__OUT1(s) __OUT2(m) : : "d" (value), "i" (0), "d" (PORT_BASE+port)); } \ -__OUT1(s##c) __OUT2(m) : : "d" (value), "i" (port), "d" (PORT_BASE)); } \ -__OUT1(s##_p) __OUT2(m) : : "d" (value), "i" (0), "d" (PORT_BASE+port)); \ +__OUT1(s) __OUT2(m) : : "r" (value), "i" (0), "r" (PORT_BASE+port)); } \ +__OUT1(s##c) __OUT2(m) : : "r" (value), "i" (port), "r" (PORT_BASE)); } \ +__OUT1(s##_p) __OUT2(m) : : "r" (value), "i" (0), "r" (PORT_BASE+port)); \ SLOW_DOWN_IO; } \ -__OUT1(s##c_p) __OUT2(m) : : "d" (value), "i" (port), "d" (PORT_BASE)); \ +__OUT1(s##c_p) __OUT2(m) : : "r" (value), "i" (port), "r" (PORT_BASE)); \ SLOW_DOWN_IO; } #define __IN1(s) \ extern inline unsigned int __in##s(unsigned int port) { unsigned int _v; +/* + * Useless nops will be removed by the assembler + */ #define __IN2(m) \ -__asm__ __volatile__ ("l" #m "u\t%0,%1(%2)\n\t" +__asm__ __volatile__ ("l" #m "u\t%0,%1(%2)\n\tnop" #define __IN(m,s) \ -__IN1(s) __IN2(m) STR(FILL_LDS) : "=d" (_v) : "i" (0), "d" (PORT_BASE+port)); return _v; } \ -__IN1(s##c) __IN2(m) STR(FILL_LDS) : "=d" (_v) : "i" (port), "d" (PORT_BASE)); return _v; } \ -__IN1(s##_p) __IN2(m) : "=d" (_v) : "i" (0), "d" (PORT_BASE+port)); SLOW_DOWN_IO; return _v; } \ -__IN1(s##c_p) __IN2(m) : "=d" (_v) : "i" (port), "d" (PORT_BASE)); SLOW_DOWN_IO; return _v; } +__IN1(s) __IN2(m) : "=r" (_v) : "i" (0), "r" (PORT_BASE+port)); return _v; } \ +__IN1(s##c) __IN2(m) : "=r" (_v) : "i" (port), "r" (PORT_BASE)); return _v; } \ +__IN1(s##_p) __IN2(m) : "=r" (_v) : "i" (0), "r" (PORT_BASE+port)); SLOW_DOWN_IO; return _v; } \ +__IN1(s##c_p) __IN2(m) : "=r" (_v) : "i" (port), "r" (PORT_BASE)); SLOW_DOWN_IO; return _v; } #define __INS1(s) \ extern inline void __ins##s(unsigned int port, void * addr, unsigned long count) { @@ -83,21 +86,21 @@ __asm__ __volatile__ ( \ ".set\tnoreorder\n\t" \ ".set\tnoat\n" \ "1:\tl" #m "u\t$1,%4(%5)\n\t" \ - "subu\t%1,%1,1\n\t" \ + "subu\t%1,1\n\t" \ "s" #m "\t$1,(%0)\n\t" \ "bne\t$0,%1,1b\n\t" \ - "addiu\t%0,%0,%6\n\t" \ + "addiu\t%0,%6\n\t" \ ".set\tat\n\t" \ ".set\treorder" #define __INS(m,s,i) \ __INS1(s) __INS2(m) \ - : "=d" (addr), "=d" (count) \ - : "0" (addr), "1" (count), "i" (0), "d" (PORT_BASE+port), "I" (i) \ + : "=r" (addr), "=r" (count) \ + : "0" (addr), "1" (count), "i" (0), "r" (PORT_BASE+port), "I" (i) \ : "$1");} \ __INS1(s##c) __INS2(m) \ - : "=d" (addr), "=d" (count) \ - : "0" (addr), "1" (count), "i" (port), "d" (PORT_BASE), "I" (i) \ + : "=r" (addr), "=r" (count) \ + : "0" (addr), "1" (count), "i" (port), "r" (PORT_BASE), "I" (i) \ : "$1");} #define __OUTS1(s) \ @@ -117,12 +120,12 @@ __asm__ __volatile__ ( \ #define __OUTS(m,s,i) \ __OUTS1(s) __OUTS2(m) \ - : "=d" (addr), "=d" (count) \ - : "0" (addr), "1" (count), "i" (0), "d" (PORT_BASE+port), "I" (i) \ + : "=r" (addr), "=r" (count) \ + : "0" (addr), "1" (count), "i" (0), "r" (PORT_BASE+port), "I" (i) \ : "$1");} \ __OUTS1(s##c) __OUTS2(m) \ - : "=d" (addr), "=d" (count) \ - : "0" (addr), "1" (count), "i" (port), "d" (PORT_BASE), "I" (i) \ + : "=r" (addr), "=r" (count) \ + : "0" (addr), "1" (count), "i" (port), "r" (PORT_BASE), "I" (i) \ : "$1");} __IN(b,b) @@ -237,4 +240,4 @@ __OUTS(w,l,4) __inslc((port),(addr),(count)) : \ __insl((port),(addr),(count))) -#endif +#endif /* __ASM_MIPS_IO_H */ diff --git a/include/asm-mips/irq.h b/include/asm-mips/irq.h index a6d10c29e..4c5191fef 100644 --- a/include/asm-mips/irq.h +++ b/include/asm-mips/irq.h @@ -9,10 +9,10 @@ * written by Ralf Baechle * */ -#ifndef _ASM_MIPS_IRQ_H -#define _ASM_MIPS_IRQ_H +#ifndef __ASM_MIPS_IRQ_H +#define __ASM_MIPS_IRQ_H extern void disable_irq(unsigned int); extern void enable_irq(unsigned int); -#endif /* _ASM_MIPS_IRQ_H */ +#endif /* __ASM_MIPS_IRQ_H */ diff --git a/include/asm-mips/jazz.h b/include/asm-mips/jazz.h new file mode 100644 index 000000000..2e6a3cc2d --- /dev/null +++ b/include/asm-mips/jazz.h @@ -0,0 +1,314 @@ +/* + * Hardware info about Mips JAZZ and similar systems + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file "COPYING" in the main directory of this archive + * for more details. + * + * Copyright (C) 1995 by Andreas Busse and Ralf Baechle + * + * This file is a mess. It really needs some reorganisation! + */ + +#ifndef __ASM_MIPS_JAZZ_H +#define __ASM_MIPS_JAZZ_H + +/* + * The addresses below are virtual address. The mappings are + * created on startup via wired entries in the tlb. The Mips + * Magnum R3000 and R4000 machines are similar in many aspects, + * but many hardware register are accessible at 0xb9000000 in + * instead of 0xe0000000. + */ + +#define JAZZ_LOCAL_IO_SPACE 0xe0000000 + +/* + * Revision numbers in PICA_ASIC_REVISION + * + * 0xf0000000 - Rev1 + * 0xf0000001 - Rev2 + * 0xf0000002 - Rev3 + */ +#define PICA_ASIC_REVISION 0xe0000008 + +/* + * The segments of the seven segment LED are mapped + * to the control bits as follows: + * + * (7) + * --------- + * | | + * (2) | | (6) + * | (1) | + * --------- + * | | + * (3) | | (5) + * | (4) | + * --------- . (0) + */ +#define PICA_LED 0xe000f000 + +/* + * Some characters for the LED control registers + * The original Mips machines seem to have a LED display + * with integrated decoder while the Acer machines can + * control each of the seven segments and the dot independend. + * It's only a toy, anyway... + */ +#define LED_DOT 0x01 +#define LED_SPACE 0x00 +#define LED_0 0xfc +#define LED_1 0x60 +#define LED_2 0xda +#define LED_3 0xf2 +#define LED_4 0x66 +#define LED_5 0xb6 +#define LED_6 0xbe +#define LED_7 0xe0 +#define LED_8 0xfe +#define LED_9 0xf6 +#define LED_A 0xee +#define LED_b 0x3e +#define LED_C 0x9c +#define LED_d 0x7a +#define LED_E 0x9e +#define LED_F 0x8e + +#ifndef __LANGUAGE_ASSEMBLY__ + +extern __inline__ void pica_set_led(unsigned int bits) +{ + volatile unsigned int *led_register = (unsigned int *) PICA_LED; + + *led_register = bits; +} + +#endif + +/* + * i8042 keyboard controller for JAZZ and PICA chipsets. + * This address is just a guess and seems to differ from + * other mips machines such as RC3xxx... + */ +#define JAZZ_KEYBOARD_ADDRESS 0xe0005000 +#define JAZZ_KEYBOARD_DATA 0xe0005000 +#define JAZZ_KEYBOARD_COMMAND 0xe0005001 + +#ifndef __LANGUAGE_ASSEMBLY__ + +typedef struct { + unsigned char data; + unsigned char command; +} jazz_keyboard_hardware; + +typedef struct { + unsigned char pad0[3]; + unsigned char data; + unsigned char pad1[3]; + unsigned char command; +} mips_keyboard_hardware; + +/* + * For now. Needs to be changed for RC3xxx support. See below. + */ +#define keyboard_hardware jazz_keyboard_hardware + +#endif + +/* + * i8042 keyboard controller for most other Mips machines. + */ +#define MIPS_KEYBOARD_ADDRESS 0xb9005000 +#define MIPS_KEYBOARD_DATA 0xb9005003 +#define MIPS_KEYBOARD_COMMAND 0xb9005007 + +/* + * Serial and parallel ports (WD 16C552) on the Mips JAZZ + */ + +#define JAZZ_SERIAL1_BASE (unsigned int)0xe0006000 +#define JAZZ_SERIAL2_BASE (unsigned int)0xe0007000 +#define JAZZ_PARALLEL_BASE (unsigned int)0xe0008000 + +/* + * Dummy Device Address. Used in jazzdma.c + */ + +#define JAZZ_DUMMY_DEVICE 0xe000d000 + +/* + * JAZZ timer registers and interrupt no. + * Note that the hardware timer interrupt is actually on + * cpu level 6, but to keep compatibility with PC stuff + * it is remapped to vector 0. See arch/mips/kernel/entry.S. + */ +#define JAZZ_TIMER_INTERVAL 0xe0000228 +#define JAZZ_TIMER_REGISTER 0xe0000230 + +/* + * DRAM configuration register + */ +#ifndef __LANGUAGE_ASSEMBLY__ +#ifdef __MIPSEL__ +typedef struct { + unsigned int bank2 : 3; + unsigned int bank1 : 3; + unsigned int mem_bus_width : 1; + unsigned int reserved2 : 1; + unsigned int page_mode : 1; + unsigned int reserved1 : 23; +} dram_configuration; +#else /* defined (__MIPSEB__) */ +typedef struct { + unsigned int reserved1 : 23; + unsigned int page_mode : 1; + unsigned int reserved2 : 1; + unsigned int mem_bus_width : 1; + unsigned int bank1 : 3; + unsigned int bank2 : 3; +} dram_configuration; +#endif +#endif /* __LANGUAGE_ASSEMBLY__ */ + +#define PICA_DRAM_CONFIG 0xe00fffe0 + +/* + * JAZZ interrupt control registers + */ +#define JAZZ_IO_IRQ_SOURCE 0xe0100000 +#define JAZZ_IO_IRQ_ENABLE 0xe0100002 + +/* + * JAZZ interrupt enable bits + */ +#define JAZZ_IE_PARALLEL (1 << 0) +#define JAZZ_IE_FLOPPY (1 << 1) +#define JAZZ_IE_SOUND (1 << 2) +#define JAZZ_IE_VIDEO (1 << 3) +#define JAZZ_IE_ETHERNET (1 << 4) +#define JAZZ_IE_SCSI (1 << 5) +#define JAZZ_IE_KEYBOARD (1 << 6) +#define JAZZ_IE_MOUSE (1 << 7) +#define JAZZ_IE_SERIAL1 (1 << 8) +#define JAZZ_IE_SERIAL2 (1 << 9) + +/* + * JAZZ Interrupt Level definitions + */ + +#define JAZZ_TIMER_IRQ 0 +#define JAZZ_KEYBOARD_IRQ 1 +#define JAZZ_ETHERNET_IRQ 2 /* 15 */ +#define JAZZ_SERIAL1_IRQ 3 +#define JAZZ_SERIAL2_IRQ 4 +#define JAZZ_PARALLEL_IRQ 5 +#define JAZZ_FLOPPY_IRQ 6 /* needs to be consistent with floppy driver! */ + + +/* + * JAZZ DMA Channels + * Note: Channels 4...7 are not used with respect to the Acer PICA-61 + * chipset which does not provide these DMA channels. + */ + +#define JAZZ_SCSI_DMA 0 /* SCSI */ +#define JAZZ_FLOPPY_DMA 1 /* FLOPPY */ +#define JAZZ_AUDIOL_DMA 2 /* AUDIO L */ +#define JAZZ_AUDIOR_DMA 3 /* AUDIO R */ + +/* + * JAZZ R4030 MCT_ADR chip (DMA controller) + * Note: Virtual Addresses ! + */ + +#define JAZZ_R4030_CONFIG 0xE0000000 /* R4030 config register */ +#define JAZZ_R4030_REVISION 0xE0000008 /* same as PICA_ASIC_REVISION */ +#define JAZZ_R4030_INV_ADDR 0xE0000010 /* Invalid Address register */ + +#define JAZZ_R4030_TRSTBL_BASE 0xE0000018 /* Translation Table Base */ +#define JAZZ_R4030_TRSTBL_LIM 0xE0000020 /* Translation Table Limit */ +#define JAZZ_R4030_TRSTBL_INV 0xE0000028 /* Translation Table Invalidate */ + +#define JAZZ_R4030_CACHE_MTNC 0xE0000030 /* Cache Maintenance */ +#define JAZZ_R4030_R_FAIL_ADDR 0xE0000038 /* Remote Failed Address */ +#define JAZZ_R4030_M_FAIL_ADDR 0xE0000040 /* Memory Failed Adresss */ + +#define JAZZ_R4030_CACHE_PTAG 0xE0000048 /* I/O Cache Physical Tag */ +#define JAZZ_R4030_CACHE_LTAG 0xE0000050 /* I/O Cache Logical Tag */ +#define JAZZ_R4030_CACHE_BMASK 0xE0000058 /* I/O Cache Byte Mask */ +#define JAZZ_R4030_CACHE_BWIN 0xE0000060 /* I/O Cache Buffer Window */ + +/* + * Remote Speed Registers. + * + * 0: free, 1: Ethernet, 2: SCSI, 3: Floppy, + * 4: RTC, 5: Kb./Mouse 6: serial 1, 7: serial 2, + * 8: parallel, 9: NVRAM, 10: CPU, 11: PROM, + * 12: reserved, 13: free, 14: 7seg LED, 15: ??? + */ + +#define JAZZ_R4030_REM_SPEED 0xE0000070 /* 16 Remote Speed Registers */ + /* 0xE0000070,78,80... 0xE00000E8 */ +#define JAZZ_R4030_IRQ_ENABLE 0xE00000E8 /* Internal Interrupt Enable */ + +#define JAZZ_R4030_IRQ_SOURCE 0xE0000200 /* Interrupt Source Reg */ +#define JAZZ_R4030_I386_ERROR 0xE0000208 /* i386/EISA Bus Error */ + + +/* + * Access the R4030 DMA and I/O Controller + */ + +#ifndef __LANGUAGE_ASSEMBLY__ + +extern inline unsigned short r4030_read_reg16(unsigned addr) { + unsigned short ret = *((volatile unsigned short *)addr); + __asm__ __volatile__( + ".set\tnoreorder\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + ".set\treorder"); + return ret; +} + +extern inline unsigned int r4030_read_reg32(unsigned addr) { + unsigned int ret = *((volatile unsigned int *)addr); + __asm__ __volatile__( + ".set\tnoreorder\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + ".set\treorder"); + return ret; +} + +extern inline void r4030_write_reg16(unsigned addr, unsigned val) { + *((volatile unsigned short *)addr) = val; + __asm__ __volatile__( + ".set\tnoreorder\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + ".set\treorder"); +} + +extern inline unsigned int r4030_write_reg32(unsigned addr, unsigned val) { + *((volatile unsigned int *)addr) = val; + __asm__ __volatile__( + ".set\tnoreorder\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + ".set\treorder"); +} + +#endif /* !LANGUAGE_ASSEMBLY__ */ + + +#endif /* __ASM_MIPS_JAZZ_H */ diff --git a/include/asm-mips/jazzdma.h b/include/asm-mips/jazzdma.h new file mode 100644 index 000000000..292a16177 --- /dev/null +++ b/include/asm-mips/jazzdma.h @@ -0,0 +1,100 @@ +/* + * Helpfile for jazzdma.c -- Mips Jazz R4030 DMA controller support + */ + +#ifndef __ASM_JAZZDMA_H +#define __ASM_JAZZDMA_H + +/* + * Prototypes and macros + */ + +unsigned long vdma_init(unsigned long memory_start, unsigned long memory_end); +unsigned long vdma_alloc(unsigned long paddr, unsigned long size); +int vdma_free(unsigned long laddr); +int vdma_remap(unsigned long laddr, unsigned long paddr, unsigned long size); +unsigned long vdma_phys2log(unsigned long paddr); +unsigned long vdma_log2phys(unsigned long laddr); +void vdma_stats(void); /* for debugging only */ + +void vdma_enable(int channel); +void vdma_disable(int channel); +void vdma_set_mode(int channel, int mode); +void vdma_set_addr(int channel, long addr); +void vdma_set_count(int channel, int count); +int vdma_get_residue(int channel); + +/* + * some definitions used by the driver functions + */ + +#define VDMA_PAGESIZE 4096 +#define VDMA_PGTBL_ENTRIES 4096 +#define VDMA_PGTBL_SIZE (sizeof(VDMA_PGTBL_ENTRY) * VDMA_PGTBL_ENTRIES) +#define VDMA_PAGE_EMPTY 0 + +/* + * Macros to get page no. and offset of a given address + * Note that VDMA_PAGE() works for physical addresses only + */ +#define VDMA_PAGE(a) ((unsigned int)(a) >> 12) +#define VDMA_OFFSET(a) ((unsigned int)(a) & (VDMA_PAGESIZE-1)) + +/* + * error code returned by vdma_alloc() + * (See also arch/mips/kernel/jazzdma.c) + */ + +#define VDMA_ERROR 0xffffffff + +/* + * VDMA pagetable entry description + */ + +typedef volatile struct VDMA_PGTBL_ENTRY +{ + unsigned int frame; /* physical frame no. */ + unsigned int owner; /* owner of this entry (0=free) */ +} VDMA_PGTBL_ENTRY; + + +/* + * DMA channel control registers + * in the R4030 MCT_ADR chip + */ + +#define JAZZ_R4030_CHNL_MODE 0xE0000100 /* 8 DMA Channel Mode Registers, */ + /* 0xE0000100,120,140... */ +#define JAZZ_R4030_CHNL_ENABLE 0xE0000108 /* 8 DMA Channel Enable Regs, */ + /* 0xE0000108,128,148... */ +#define JAZZ_R4030_CHNL_COUNT 0xE0000110 /* 8 DMA Channel Byte Cnt Regs, */ + /* 0xE0000110,130,150... */ +#define JAZZ_R4030_CHNL_ADDR 0xE0000118 /* 8 DMA Channel Address Regs, */ + /* 0xE0000118,138,158... */ + +/* channel enable register bits */ + +#define R4030_CHNL_ENABLE (1<<0) +#define R4030_CHNL_WRITE (1<<1) +#define R4030_TC_INTR (1<<8) +#define R4030_MEM_INTR (1<<9) +#define R4030_ADDR_INTR (1<<10) + +/* channel mode register bits */ + +#define R4030_MODE_ATIME_40 (0) /* device access time on remote bus */ +#define R4030_MODE_ATIME_80 (1) +#define R4030_MODE_ATIME_120 (2) +#define R4030_MODE_ATIME_160 (3) +#define R4030_MODE_ATIME_200 (4) +#define R4030_MODE_ATIME_240 (5) +#define R4030_MODE_ATIME_280 (6) +#define R4030_MODE_ATIME_320 (7) +#define R4030_MODE_WIDTH_8 (1<<3) /* device data bus width */ +#define R4030_MODE_WIDTH_16 (2<<3) +#define R4030_MODE_WIDTH_32 (3<<3) +#define R4030_MODE_INTR_EN (1<<5) +#define R4030_MODE_BURST (1<<6) /* Rev. 2 only */ +#define R4030_MODE_FAST_ACK (1<<7) /* Rev. 2 only */ + +#endif /* __ASM_JAZZDMA_H */ diff --git a/include/asm-mips/mipsconfig.h b/include/asm-mips/mipsconfig.h index 4194df998..1648f7c7e 100644 --- a/include/asm-mips/mipsconfig.h +++ b/include/asm-mips/mipsconfig.h @@ -1,29 +1,49 @@ /* - * linux/include/asm-mips/mipsconfig.h + * include/asm-mips/mipsconfig.h * * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. * - * Copyright (C) 1994 by Waldorf GMBH + * Copyright (C) 1994, 1995 by Waldorf Electronics * written by Ralf Baechle - * */ -#ifndef _ASM_MIPS_MIPS_CONFIG_H -#define _ASM_MIPS_MIPS_CONFIG_H +#ifndef __ASM_MIPS_MIPSCONFIG_H +#define __ASM_MIPS_MIPSCONFIG_H /* - * This is the virtual adress to which all ports are being mapped. + * This is the virtual address to which all ports are being mapped. + * Must be a value that can be load with a lui instruction. */ -#define PORT_BASE 0xe0000000 -#define PORT_BASE_HIGH 0xe000 +#ifndef PORT_BASE +#define PORT_BASE 0xe2000000 +#endif -#define NUMBER_OF_TLB_ENTRIES 48 +/* + * Pagetables are 4MB mapped at 0xe4000000 + * Must be a value that can be loaded with a single instruction. + */ +#define TLBMAP 0xe4000000 + +/* + * The virtual address where we'll map the pagetables + * For a base address of 0xe3000000 this is 0xe338c000 + * For a base address of 0xe4000000 this is 0xe4390000 + * FIXME: Gas computes the following expression with signed + * shift and therefore false +#define TLB_ROOT (TLBMAP + (TLBMAP >> (12-2))) + */ +#define TLB_ROOT 0xe4390000 + +/* + * Use this to activate extra TLB error checking + */ +#define CONFIG_DEBUG_TLB /* - * Absolute address of the kernelstack is 0x80000280 + * Use this to activate extra TLB profiling code + * (currently not implemented) */ -#define KERNEL_SP_HIGH 0x8000 -#define KERNEL_SP_LOW 0x0280 +#undef CONFIG_PROFILE_TLB -#endif /* _ASM_MIPS_MIPS_CONFIG_H */ +#endif /* __ASM_MIPS_MIPSCONFIG_H */ diff --git a/include/asm-mips/mipsregs.h b/include/asm-mips/mipsregs.h index b9b96e73d..466c8b12b 100644 --- a/include/asm-mips/mipsregs.h +++ b/include/asm-mips/mipsregs.h @@ -5,11 +5,11 @@ * License. See the file "COPYING" in the main directory of this archive * for more details. * - * Copyright (C) 1994 by Ralf Baechle + * Copyright (C) 1994, 1995 by Ralf Baechle */ -#ifndef _ASM_MIPS_MIPSREGS_H_ -#define _ASM_MIPS_MIPSREGS_H_ +#ifndef __ASM_MIPS_MIPSREGS_H +#define __ASM_MIPS_MIPSREGS_H /* * The following macros are especially useful for __asm__ @@ -25,10 +25,8 @@ /* * On the R2000/3000 load instructions are not interlocked - - * we therefore sometimes need to fill load delay slots with nop - * which are not needed for >=R4000. - * - * FIXME: Don't know about R6000 + * we therefore sometimes need to fill load delay slots with a nop + * which would be useless for ISA >= 2. */ #if !defined (__R4000__) #define FILL_LDS nop @@ -59,6 +57,9 @@ #define CP0_WATCHLO $18 #define CP0_WATCHHI $19 #define CP0_XCONTEXT $20 +#define CP0_FRAMEMASK $21 +#define CP0_DIAGNOSTIC $22 +#define CP0_PERFORMANCE $25 #define CP0_ECC $26 #define CP0_CACHEERR $27 #define CP0_TAGLO $28 @@ -66,6 +67,13 @@ #define CP0_ERROREPC $30 /* + * Coprocessor 1 (FPU) register names + */ + +#define CP1_REVISION $0 +#define CP1_STATUS $31 + +/* * Values for PageMask register */ #define PM_4K 0x00000000 @@ -88,91 +96,173 @@ #define PL_16M 24 /* - * Compute a vpn/pfn entry for EntryHi register + * Macros to access the system control coprocessor */ -#define VPN(addr,pagesizeshift) ((addr) & ~((1 << (pagesizeshift))-1)) -#define PFN(addr,pagesizeshift) (((addr) & ((1 << (pagesizeshift))-1)) << 6) +#define read_32bit_cp0_register(source) \ +({ int __res; \ + __asm__ __volatile__( \ + "mfc0\t%0,"STR(source) \ + : "=r" (__res)); \ + __res;}) +#define read_64bit_cp0_register(source) \ +({ int __res; \ + __asm__ __volatile__( \ + ".set\tmips3\n\t" \ + "dmfc0\t%0,"STR(source)"\n\t" \ + ".set\tmips0" \ + : "=r" (__res)); \ + __res;}) + +#define write_32bit_cp0_register(register,value) \ + __asm__ __volatile__( \ + "mtc0\t%0,"STR(register) \ + : : "r" (value)); + +#define write_64bit_cp0_register(register,value) \ + __asm__ __volatile__( \ + ".set\tmips3\n\t" \ + "dmtc0\t%0,"STR(register)"\n\t" \ + ".set\tmips0" \ + : : "r" (value)) /* - * Macros to access the system control copprocessor + * R4x00 interrupt enable / cause bits */ -#define read_32bit_cp0_register(source) \ -({ int __res; \ - __asm__ __volatile__( \ - "mfc0\t%0,"STR(source) \ - : "=r" (__res)); \ - __res;}) +#define IE_SW0 (1<< 8) +#define IE_SW1 (1<< 9) +#define IE_IRQ0 (1<<10) +#define IE_IRQ1 (1<<11) +#define IE_IRQ2 (1<<12) +#define IE_IRQ3 (1<<13) +#define IE_IRQ4 (1<<14) +#define IE_IRQ5 (1<<15) -#define read_64bit_cp0_register(target,source) \ - __asm__ __volatile__( \ - ".set\tnoat\n\t" \ - "dmfc0\t$1,"STR(source)"\n\t" \ - "sd\t$1,(%0)\n\t" \ - ".set\tat" \ - : \ - : "r" (target) \ - : "$1","memory"); +/* + * R4x00 interrupt cause bits + */ +#define C_SW0 (1<< 8) +#define C_SW1 (1<< 9) +#define C_IRQ0 (1<<10) +#define C_IRQ1 (1<<11) +#define C_IRQ2 (1<<12) +#define C_IRQ3 (1<<13) +#define C_IRQ4 (1<<14) +#define C_IRQ5 (1<<15) + +#ifndef __LANGUAGE_ASSEMBLY__ +/* + * Manipulate the status register. + * Mostly used to access the interrupt bits. + */ +#define BUILD_SET_CP0(name,register) \ +extern __inline__ unsigned int \ +set_cp0_##name(unsigned int change, unsigned int new) \ +{ \ + unsigned int res; \ + \ + res = read_32bit_cp0_register(register); \ + res &= ~change; \ + res |= (new & change); \ + if(change) \ + write_32bit_cp0_register(register, res); \ + \ + return res; \ +} +BUILD_SET_CP0(status,CP0_STATUS) +BUILD_SET_CP0(cause,CP0_CAUSE) -#define write_32bit_cp0_register(register,value) \ - __asm__ __volatile__( \ - "mtc0\t%0,"STR(register) \ - : : "r" (value)); +#endif /* defined (__LANGUAGE_ASSEMBLY__) */ /* * Inline code for use of the ll and sc instructions * - * FIXME: This code code will break on R[23]00 CPUs + * FIXME: This instruction is only available on MIPS ISA >=3. * Since these operations are only being used for atomic operations * the easiest workaround for the R[23]00 is to disable interrupts. */ -#define load_linked(addr) \ -({ \ - unsigned int __res; \ - \ - __asm__ __volatile__( \ - "ll\t%0,(%1)" \ - : "=r" (__res) \ - : "r" ((unsigned int) (addr))); \ - \ - __res; \ +#define load_linked(addr) \ +({ \ + unsigned int __res; \ + \ + __asm__ __volatile__( \ + "ll\t%0,(%1)" \ + : "=r" (__res) \ + : "r" ((unsigned int) (addr))); \ + \ + __res; \ }) -#define store_conditional(value,addr) \ -({ \ - int __res; \ - \ - __asm__ __volatile__( \ - "sc\t%0,(%2)" \ - : "=r" (__res) \ - : "0" (value), "r" (addr)); \ - \ - __res; \ +#define store_conditional(addr,value) \ +({ \ + int __res; \ + \ + __asm__ __volatile__( \ + "sc\t%0,(%2)" \ + : "=r" (__res) \ + : "0" (value), "r" (addr)); \ + \ + __res; \ }) /* * Bitfields in the cp0 status register * - * Refer to MIPS R4600 manual, page 5-4 for explanation + * Refer to the MIPS R4xx0 manuals, chapter 5 for explanation. + * FIXME: This doesn't cover all R4xx0 processors. */ -#define ST0_IE (1 << 1) -#define ST0_EXL (1 << 2) -#define ST0_ERL (3 << 3) -#define ST0_UX (1 << 5) -#define ST0_SX (1 << 6) -#define ST0_KX (1 << 7) -#define ST0_IM (255 << 8) -#define ST0_DE (1 << 16) -#define ST0_CE (1 << 17) -#define ST0_CH (1 << 18) -#define ST0_SR (1 << 20) -#define ST0_BEV (1 << 22) -#define ST0_RE (1 << 25) -#define ST0_FR (1 << 26) -#define ST0_CU (15 << 28) -#define ST0_CU0 (1 << 28) -#define ST0_CU1 (1 << 29) -#define ST0_CU2 (1 << 30) -#define ST0_CU3 (1 << 31) - -#endif /* _ASM_MIPS_MIPSREGS_H_ */ +#define ST0_IE (1 << 0) +#define ST0_EXL (1 << 1) +#define ST0_ERL (1 << 2) +#define ST0_KSU (3 << 3) +# define KSU_USER (2 << 3) +# define KSU_SUPERVISOR (1 << 3) +# define KSU_KERNEL (0 << 3) +#define ST0_UX (1 << 5) +#define ST0_SX (1 << 6) +#define ST0_KX (1 << 7) +#define ST0_IM (255 << 8) +#define ST0_DE (1 << 16) +#define ST0_CE (1 << 17) +#define ST0_CH (1 << 18) +#define ST0_SR (1 << 20) +#define ST0_BEV (1 << 22) +#define ST0_RE (1 << 25) +#define ST0_FR (1 << 26) +#define ST0_CU (15 << 28) +#define ST0_CU0 (1 << 28) +#define ST0_CU1 (1 << 29) +#define ST0_CU2 (1 << 30) +#define ST0_CU3 (1 << 31) + +/* + * Bitfields and bit numbers in the coprocessor 0 cause register. + * + * Refer to to your MIPS R4xx0 manual, chapter 5 for explanation. + */ +#define CAUSEB_EXCCODE 2 +#define CAUSEF_EXCCODE (31 << 2) +#define CAUSEB_IP 8 +#define CAUSEF_IP (255 << 8) +#define CAUSEB_IP0 8 +#define CAUSEF_IP0 (1 << 8) +#define CAUSEB_IP1 9 +#define CAUSEF_IP1 (1 << 9) +#define CAUSEB_IP2 10 +#define CAUSEF_IP2 (1 << 10) +#define CAUSEB_IP3 11 +#define CAUSEF_IP3 (1 << 11) +#define CAUSEB_IP4 12 +#define CAUSEF_IP4 (1 << 12) +#define CAUSEB_IP5 13 +#define CAUSEF_IP5 (1 << 13) +#define CAUSEB_IP6 14 +#define CAUSEF_IP6 (1 << 14) +#define CAUSEB_IP7 15 +#define CAUSEF_IP7 (1 << 15) +#define CAUSEB_CE 28 +#define CAUSEF_CE (3 << 28) +#define CAUSEB_BD 31 +#define CAUSEF_BD (1 << 31) + +#endif /* __ASM_MIPS_MIPSREGS_H */ diff --git a/include/asm-mips/mm.h b/include/asm-mips/mm.h deleted file mode 100644 index 84a09e1c8..000000000 --- a/include/asm-mips/mm.h +++ /dev/null @@ -1,94 +0,0 @@ -#ifndef _ASM_MIPS_MM_H_ -#define _ASM_MIPS_MM_H_ - -#if defined (__KERNEL__) - -/* - * Note that we shift the lower 32bits of each EntryLo[01] entry - * 6 bit to the left. That way we can convert the PFN into the - * physical address by a single and operation and gain 6 aditional - * bits for storing information which isn't present in a normal - * MIPS page table. - * I've also changed the naming of some bits so that they conform - * the i386 naming as much as possible. - */ -#define PAGE_COW (1<<0) /* implemented in software */ -#define PAGE_ACCESSED (1<<1) /* implemented in software */ -#define PAGE_DIRTY (1<<2) /* implemented in software */ -#define PAGE_USER (1<<3) /* implemented in software */ -#define PAGE_UNUSED2 (1<<4) /* for use by software */ -#define PAGE_UNUSED3 (1<<5) /* for use by software */ -#define PAGE_GLOBAL (1<<6) -#define PAGE_VALID (1<<7) -/* - * In the hardware the PAGE_WP bit is represented by the dirty bit - */ -#define PAGE_RW (1<<8) -#define CACHE_CACHABLE_NO_WA (0<<9) -#define CACHE_CACHABLE_WA (1<<9) -#define CACHE_UNCACHED (2<<9) -#define CACHE_CACHABLE_NONCOHERENT (3<<9) -#define CACHE_CACHABLE_CE (4<<9) -#define CACHE_CACHABLE_COW (5<<9) -#define CACHE_CACHABLE_CUW (6<<9) -#define CACHE_MASK (7<<9) - -#define PAGE_PRIVATE (PAGE_VALID | PAGE_ACCESSED | PAGE_DIRTY | \ - PAGE_RW | PAGE_COW) -#define PAGE_SHARED (PAGE_VALID | PAGE_ACCESSED | PAGE_DIRTY | PAGE_RW) -#define PAGE_COPY (PAGE_VALID | PAGE_ACCESSED | PAGE_COW) -#define PAGE_READONLY (PAGE_VALID | PAGE_ACCESSED) -#define PAGE_TABLE (PAGE_VALID | PAGE_ACCESSED | PAGE_DIRTY | PAGE_RW) - -/* - * Predicate for testing - */ -#define IS_PAGE_USER(p) (((unsigned long)(p)) & PAGE_USER) - -extern inline long find_in_swap_cache (unsigned long addr) -{ - unsigned long entry; - -#ifdef SWAP_CACHE_INFO - swap_cache_find_total++; -#endif - cli(); - entry = swap_cache[addr >> PAGE_SHIFT]; - swap_cache[addr >> PAGE_SHIFT] = 0; - sti(); -#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 - cli(); - entry = swap_cache[addr >> PAGE_SHIFT]; - swap_cache[addr >> PAGE_SHIFT] = 0; - sti(); - if (entry) { -#ifdef SWAP_CACHE_INFO - swap_cache_del_success++; -#endif - swap_free(entry); - return 1; - } - return 0; -} - -/* - * memory.c & swap.c - */ -extern void mem_init(unsigned long start_mem, unsigned long end_mem); - -#endif /* defined (__KERNEL__) */ - -#endif /* _ASM_MIPS_MM_H_ */ diff --git a/include/asm-mips/page.h b/include/asm-mips/page.h index 0176c0251..4ea742d84 100644 --- a/include/asm-mips/page.h +++ b/include/asm-mips/page.h @@ -1,90 +1,126 @@ -#ifndef _ASM_MIPS_LINUX_PAGE_H -#define _ASM_MIPS_LINUX_PAGE_H +#ifndef __ASM_MIPS_PAGE_H +#define __ASM_MIPS_PAGE_H +/* PAGE_SHIFT determines the page size */ +#define PAGE_SHIFT 12 +#define PAGE_SIZE (1UL << PAGE_SHIFT) +#define PAGE_MASK (~(PAGE_SIZE-1)) + +#ifdef __KERNEL__ + +#define CONFIG_STRICT_MM_TYPECHECKS + +#ifndef __LANGUAGE_ASSEMBLY__ + +#include <asm/cachectl.h> + +#ifdef CONFIG_STRICT_MM_TYPECHECKS /* - * For now... + * These are used to make use of C type-checking.. */ -#define invalidate() +typedef struct { unsigned long pte; } pte_t; +typedef struct { unsigned long pmd; } pmd_t; +typedef struct { unsigned long pgd; } pgd_t; +typedef struct { unsigned long pgprot; } pgprot_t; - /* PAGE_SHIFT determines the page size */ -#define PAGE_SHIFT 12 -#define PGDIR_SHIFT 22 -#define PAGE_SIZE (1UL << PAGE_SHIFT) -#define PGDIR_SIZE (1UL << PGDIR_SHIFT) +#define pte_val(x) ((x).pte) +#define pmd_val(x) ((x).pmd) +#define pgd_val(x) ((x).pgd) +#define pgprot_val(x) ((x).pgprot) -#ifdef __KERNEL__ +#define __pte(x) ((pte_t) { (x) } ) +#define __pme(x) ((pme_t) { (x) } ) +#define __pgd(x) ((pgd_t) { (x) } ) +#define __pgprot(x) ((pgprot_t) { (x) } ) - /* number of bits that fit into a memory pointer */ -#define BITS_PER_PTR (8*sizeof(unsigned long)) - /* to mask away the intra-page address bits */ -#define PAGE_MASK (~(PAGE_SIZE-1)) - /* to mask away the intra-page address bits */ -#define PGDIR_MASK (~(PGDIR_SIZE-1)) - /* to align the pointer to the (next) page boundary */ -#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK) - /* to align the pointer to a pointer address */ -#define PTR_MASK (~(sizeof(void*)-1)) - - /* sizeof(void*)==1<<SIZEOF_PTR_LOG2 */ - /* 64-bit machines, beware! SRB. */ -#define SIZEOF_PTR_LOG2 2 - - /* to find an entry in a page-table-directory */ -#define PAGE_DIR_OFFSET(base,address) ((unsigned long*)((base)+\ - ((unsigned long)(address)>>(PAGE_SHIFT-SIZEOF_PTR_LOG2)*2&PTR_MASK&~PAGE_MASK))) - /* to find an entry in a page-table */ -#define PAGE_PTR(address) \ - ((unsigned long)(address)>>(PAGE_SHIFT-SIZEOF_PTR_LOG2)&PTR_MASK&~PAGE_MASK) - /* the no. of pointers that fit on a page */ -#define PTRS_PER_PAGE (PAGE_SIZE/sizeof(void*)) - -#define copy_page(from,to) \ - __copy_page((void *)(from),(void *)(to), PAGE_SIZE) - -#if defined (__R4000__) +#else /* !defined (CONFIG_STRICT_MM_TYPECHECKS) */ /* - * Do it the 64bit way... + * .. while these make it easier on the compiler */ -extern __inline__ void __copy_page(void *from, void *to, int bytes) -{ - __asm__ __volatile__( - ".set\tnoreorder\n\t" - ".set\tnoat\n" - "1:\tld\t$1,(%0)\n\t" - "addiu\t%0,%0,8\n\t" - "sd\t$1,(%1)\n\t" - "subu\t%2,%2,8\n\t" - "bne\t$0,%2,1b\n\t" - "addiu\t%1,%1,8\n\t" - ".set\tat\n\t" - ".set\treorder\n\t" - : "=r" (from), "=r" (to), "=r" (bytes) - : "r" (from), "r" (to), "r" (bytes) - : "$1"); -} +typedef unsigned long pte_t; +typedef unsigned long pmd_t; +typedef unsigned long pgd_t; +typedef unsigned long pgprot_t; + +#define pte_val(x) (x) +#define pmd_val(x) (x) +#define pgd_val(x) (x) +#define pgprot_val(x) (x) + +#define __pte(x) (x) +#define __pmd(x) (x) +#define __pgd(x) (x) +#define __pgprot(x) (x) + +#endif /* !defined (CONFIG_STRICT_MM_TYPECHECKS) */ + +#include <linux/linkage.h> + +extern asmlinkage void tlbflush(void); +#define invalidate() ({sys_cacheflush(0, ~0, BCACHE);tlbflush();}) + +#if __mips == 3 +typedef unsigned int mem_map_t; +#else +typedef unsigned short mem_map_t; +#endif + +#endif /* __LANGUAGE_ASSEMBLY__ */ + +/* to align the pointer to the (next) page boundary */ +#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK) + +/* This handles the memory map */ +#if __mips == 3 +/* + * We handle pages at XKPHYS + 0x1800000000000000 (cachable, noncoherent) + * Pagetables are at XKPHYS + 0x1000000000000000 (uncached) + */ +#define PAGE_OFFSET 0x9800000000000000UL +#define PT_OFFSET 0x9000000000000000UL +#define MAP_MASK 0x07ffffffffffffffUL +#define MAP_PAGE_RESERVED (1<<31) #else /* - * Use 32 bit Diesel fuel... + * We handle pages at KSEG0 (cachable, noncoherent) + * Pagetables are at KSEG1 (uncached) */ -extern __inline__ void __copy_page(void *from, void *to, int bytes) +#define PAGE_OFFSET 0x80000000 +#define PT_OFFSET 0xa0000000 +#define MAP_MASK 0x1fffffff +#define MAP_PAGE_RESERVED (1<<15) +#endif + +#define MAP_NR(addr) ((((unsigned long)(addr)) & MAP_MASK) >> PAGE_SHIFT) + +#ifndef __LANGUAGE_ASSEMBLY__ + +#define copy_page(from,to) __copy_page((unsigned long)from, (unsigned long)to) + +extern unsigned long page_colour_mask; + +extern inline unsigned long +page_colour(unsigned long page) { - __asm__ __volatile__( - ".set\tnoreorder\n\t" - ".set\tnoat\n" - "1:\tlw\t$1,(%0)\n\t" - "addiu\t%0,%0,4\n\t" - "sw\t$1,(%1)\n\t" - "subu\t%2,%2,4\n\t" - "bne\t$0,%2,1b\n\t" - "addiu\t%1,%1,4\n\t" - ".set\tat\n\t" - ".set\treorder\n\t" - : "=r" (from), "=r" (to), "=r" (bytes) - : "r" (from), "r" (to), "r" (bytes) - : "$1"); + return page & page_colour_mask; } + +#if 0 +extern inline void __copy_page(unsigned long from, unsigned long to) +{ +printk("__copy_page(%08lx, %08lx)\n", from, to); + sys_cacheflush(0, ~0, DCACHE); + sync_mem(); + from += (PT_OFFSET - PAGE_OFFSET); + to += (PT_OFFSET - PAGE_OFFSET); + memcpy((void *) to, (void *) from, PAGE_SIZE); + sys_cacheflush(0, ~0, ICACHE); +} +#else +extern void __copy_page(unsigned long from, unsigned long to); #endif -#endif /* __KERNEL__ */ +#endif /* defined (__LANGUAGE_ASSEMBLY__) */ +#endif /* defined (__KERNEL__) */ -#endif /* _ASM_MIPS_LINUX_PAGE_H */ +#endif /* __ASM_MIPS_PAGE_H */ diff --git a/include/asm-mips/param.h b/include/asm-mips/param.h new file mode 100644 index 000000000..09000b46a --- /dev/null +++ b/include/asm-mips/param.h @@ -0,0 +1,20 @@ +#ifndef __ASM_MIPS_PARAM_H +#define __ASM_MIPS_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 /* __ASM_MIPS_PARAM_H */ diff --git a/include/asm-mips/pgtable.h b/include/asm-mips/pgtable.h new file mode 100644 index 000000000..e2fb67cbe --- /dev/null +++ b/include/asm-mips/pgtable.h @@ -0,0 +1,524 @@ +#ifndef __ASM_MIPS_PGTABLE_H +#define __ASM_MIPS_PGTABLE_H + +#include <asm/cachectl.h> + +/* + * The Linux memory management assumes a three-level page table setup. In + * 32 bit mode we use that, but "fold" the mid level into the top-level page + * table, so that we physically have the same two-level page table as the + * i386 mmu expects. The 64 bit version uses a three level setup. + * + * This file contains the functions and defines necessary to modify and use + * the MIPS page table tree. + */ + +/* PMD_SHIFT determines the size of the area a second-level page table can map */ +#define PMD_SHIFT 22 +#define PMD_SIZE (1UL << PMD_SHIFT) +#define PMD_MASK (~(PMD_SIZE-1)) + +/* PGDIR_SHIFT determines what a third-level page table entry can map */ +#define PGDIR_SHIFT 22 +#define PGDIR_SIZE (1UL << PGDIR_SHIFT) +#define PGDIR_MASK (~(PGDIR_SIZE-1)) + +/* + * entries per page directory level: we use two-level, so + * we don't really have any PMD directory physically. + */ +#define PTRS_PER_PTE 1024 +#define PTRS_PER_PMD 1 +#define PTRS_PER_PGD 1024 + +#define VMALLOC_START KSEG2 +#define VMALLOC_VMADDR(x) ((unsigned long)(x)) + +/* + * Note that we shift the lower 32bits of each EntryLo[01] entry + * 6 bits to the left. That way we can convert the PFN into the + * physical address by a single 'and' operation and gain 6 additional + * bits for storing information which isn't present in a normal + * MIPS page table. + * Since the Mips has choosen some quite missleading names for the + * valid and dirty bits they're defined here but only their synonyms + * will be used. + */ +#define _PAGE_PRESENT (1<<0) /* implemented in software */ +#define _PAGE_COW (1<<1) /* implemented in software */ +#define _PAGE_READ (1<<2) /* implemented in software */ +#define _PAGE_WRITE (1<<3) /* implemented in software */ +#define _PAGE_ACCESSED (1<<4) /* implemented in software */ +#define _PAGE_MODIFIED (1<<5) /* implemented in software */ +#define _PAGE_GLOBAL (1<<6) +#define _PAGE_VALID (1<<7) +#define _PAGE_SILENT_READ (1<<7) /* synonym */ +#define _PAGE_DIRTY (1<<8) /* The MIPS dirty bit */ +#define _PAGE_SILENT_WRITE (1<<8) +#define _CACHE_CACHABLE_NO_WA (0<<9) /* R4600 only */ +#define _CACHE_CACHABLE_WA (1<<9) /* R4600 only */ +#define _CACHE_UNCACHED (2<<9) /* R4[0246]00 */ +#define _CACHE_CACHABLE_NONCOHERENT (3<<9) /* R4[0246]00 */ +#define _CACHE_CACHABLE_CE (4<<9) /* R4[04]00 only */ +#define _CACHE_CACHABLE_COW (5<<9) /* R4[04]00 only */ +#define _CACHE_CACHABLE_CUW (6<<9) /* R4[04]00 only */ +#define _CACHE_CACHABLE_ACCELERATED (7<<9) /* R10000 only */ +#define _CACHE_MASK (7<<9) + +#define __READABLE (_PAGE_READ|_PAGE_SILENT_READ|_PAGE_ACCESSED) +#define __WRITEABLE (_PAGE_WRITE|_PAGE_SILENT_WRITE|_PAGE_MODIFIED) + +#define _PAGE_TABLE (_PAGE_PRESENT | __READABLE | __WRITEABLE | \ + _PAGE_DIRTY | _CACHE_UNCACHED) +#define _PAGE_CHG_MASK (PAGE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY | _CACHE_MASK) + +#define PAGE_NONE __pgprot(_PAGE_PRESENT | __READABLE | _CACHE_UNCACHED) +#define PAGE_SHARED __pgprot(_PAGE_PRESENT | __READABLE | _PAGE_WRITE | \ + _PAGE_ACCESSED | _CACHE_CACHABLE_NONCOHERENT) +#define PAGE_COPY __pgprot(_PAGE_PRESENT | __READABLE | _PAGE_COW | \ + _CACHE_CACHABLE_NONCOHERENT) +#define PAGE_READONLY __pgprot(_PAGE_PRESENT | __READABLE | \ + _CACHE_CACHABLE_NONCOHERENT) +#define PAGE_KERNEL __pgprot(_PAGE_PRESENT | __READABLE | __WRITEABLE | \ + _CACHE_CACHABLE_NONCOHERENT) + +/* + * MIPS can't do page protection for execute, and considers that the same like + * read. Also, write permissions imply read permissions. This is the closest + * we can get by reasonable means.. + */ +#define __P000 PAGE_NONE +#define __P001 PAGE_READONLY +#define __P010 PAGE_COPY +#define __P011 PAGE_COPY +#define __P100 PAGE_READONLY +#define __P101 PAGE_READONLY +#define __P110 PAGE_COPY +#define __P111 PAGE_COPY + +#define __S000 PAGE_NONE +#define __S001 PAGE_READONLY +#define __S010 PAGE_SHARED +#define __S011 PAGE_SHARED +#define __S100 PAGE_READONLY +#define __S101 PAGE_READONLY +#define __S110 PAGE_SHARED +#define __S111 PAGE_SHARED + +#if !defined (__LANGUAGE_ASSEMBLY__) + +/* page table for 0-4MB for everybody */ +extern unsigned long pg0[1024]; + +/* + * BAD_PAGETABLE is used when we need a bogus page-table, while + * BAD_PAGE is used for a bogus page. + * + * ZERO_PAGE is a global shared page that is always zero: used + * for zero-mapped memory areas etc.. + */ +extern pte_t __bad_page(void); +extern pte_t * __bad_pagetable(void); + +extern unsigned long __zero_page(void); + +#define BAD_PAGETABLE __bad_pagetable() +#define BAD_PAGE __bad_page() +#define ZERO_PAGE __zero_page() + +/* number of bits that fit into a memory pointer */ +#define BITS_PER_PTR (8*sizeof(unsigned long)) + +/* to align the pointer to a pointer address */ +#define PTR_MASK (~(sizeof(void*)-1)) + +/* + * sizeof(void*)==1<<SIZEOF_PTR_LOG2 + */ +#if __mips == 3 +#define SIZEOF_PTR_LOG2 3 +#else +#define SIZEOF_PTR_LOG2 2 +#endif + +/* to find an entry in a page-table */ +#define PAGE_PTR(address) \ +((unsigned long)(address)>>(PAGE_SHIFT-SIZEOF_PTR_LOG2)&PTR_MASK&~PAGE_MASK) + +/* to set the page-dir */ +#define SET_PAGE_DIR(tsk,pgdir) \ +do { \ + (tsk)->tss.pg_dir = ((unsigned long) (pgdir)) - PT_OFFSET; \ + if ((tsk) == current) \ + invalidate(); \ +} while (0) + +extern unsigned long high_memory; +extern pmd_t invalid_pte_table[PAGE_SIZE/sizeof(pmd_t)]; + +/* + * Conversion functions: convert a page and protection to a page entry, + * and a page entry and page directory to the page they refer to. + */ +extern inline unsigned long pte_page(pte_t pte) +{ return PAGE_OFFSET + (pte_val(pte) & PAGE_MASK); } + +extern inline unsigned long pmd_page(pmd_t pmd) +{ return PAGE_OFFSET + (pmd_val(pmd) & PAGE_MASK); } + +extern inline void pmd_set(pmd_t * pmdp, pte_t * ptep) +{ pmd_val(*pmdp) = _PAGE_TABLE | ((unsigned long) ptep - PT_OFFSET); } + +extern inline int pte_none(pte_t pte) { return !pte_val(pte); } +extern inline int pte_present(pte_t pte) { return pte_val(pte) & _PAGE_PRESENT; } +extern inline int pte_inuse(pte_t *ptep) { return mem_map[MAP_NR(ptep)] != 1; } +extern inline void pte_clear(pte_t *ptep) { pte_val(*ptep) = 0; } +extern inline void pte_reuse(pte_t * ptep) +{ + if (!(mem_map[MAP_NR(ptep)] & MAP_PAGE_RESERVED)) + mem_map[MAP_NR(ptep)]++; +} + +/* + * Empty pgd/pmd entries point to the invalid_pte_table. + */ +extern inline int pmd_none(pmd_t pmd) { return (pmd_val(pmd) & PAGE_MASK) == ((unsigned long) invalid_pte_table - PAGE_OFFSET); } + +extern inline int pmd_bad(pmd_t pmd) +{ + return (pmd_val(pmd) & ~PAGE_MASK) != _PAGE_TABLE || + pmd_page(pmd) > high_memory || + pmd_page(pmd) < PAGE_OFFSET; +} +extern inline int pmd_present(pmd_t pmd) { return pmd_val(pmd) & _PAGE_PRESENT; } +extern inline int pmd_inuse(pmd_t *pmdp) { return 0; } +extern inline void pmd_clear(pmd_t * pmdp) { pmd_val(*pmdp) = ((unsigned long) invalid_pte_table - PAGE_OFFSET); } +extern inline void pmd_reuse(pmd_t * pmdp) { } + +/* + * The "pgd_xxx()" functions here are trivial for a folded two-level + * setup: the pgd is never bad, and a pmd always exists (as it's folded + * into the pgd entry) + */ +extern inline int pgd_none(pgd_t pgd) { return 0; } +extern inline int pgd_bad(pgd_t pgd) { return 0; } +extern inline int pgd_present(pgd_t pgd) { return 1; } +extern inline int pgd_inuse(pgd_t * pgdp) { return mem_map[MAP_NR(pgdp)] != 1; } +extern inline void pgd_clear(pgd_t * pgdp) { } +extern inline void pgd_reuse(pgd_t * pgdp) +{ + if (!(mem_map[MAP_NR(pgdp)] & MAP_PAGE_RESERVED)) + mem_map[MAP_NR(pgdp)]++; +} + +/* + * The following only work if pte_present() is true. + * Undefined behaviour if not.. + */ +extern inline int pte_read(pte_t pte) { return pte_val(pte) & _PAGE_READ; } +extern inline int pte_write(pte_t pte) { return pte_val(pte) & _PAGE_WRITE; } +extern inline int pte_exec(pte_t pte) { return pte_val(pte) & _PAGE_READ; } +extern inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_MODIFIED; } +extern inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED; } +extern inline int pte_cow(pte_t pte) { return pte_val(pte) & _PAGE_COW; } + +extern inline pte_t pte_wrprotect(pte_t pte) +{ + pte_val(pte) &= ~(_PAGE_WRITE | _PAGE_SILENT_WRITE); + return pte; +} +extern inline pte_t pte_rdprotect(pte_t pte) +{ + pte_val(pte) &= ~(_PAGE_READ | _PAGE_SILENT_READ); return pte; +} +extern inline pte_t pte_exprotect(pte_t pte) +{ + pte_val(pte) &= ~(_PAGE_READ | _PAGE_SILENT_READ); return pte; +} +extern inline pte_t pte_mkclean(pte_t pte) { pte_val(pte) &= ~(_PAGE_MODIFIED|_PAGE_SILENT_WRITE); return pte; } +extern inline pte_t pte_mkold(pte_t pte) { pte_val(pte) &= ~(_PAGE_ACCESSED|_PAGE_SILENT_READ|_PAGE_SILENT_WRITE); return pte; } +extern inline pte_t pte_uncow(pte_t pte) { pte_val(pte) &= ~_PAGE_COW; return pte; } +extern inline pte_t pte_mkwrite(pte_t pte) +{ + pte_val(pte) |= _PAGE_WRITE; + if (pte_val(pte) & _PAGE_MODIFIED) + pte_val(pte) |= _PAGE_SILENT_WRITE; + return pte; +} +extern inline pte_t pte_mkread(pte_t pte) +{ + pte_val(pte) |= _PAGE_READ; + if (pte_val(pte) & _PAGE_ACCESSED) + pte_val(pte) |= _PAGE_SILENT_READ; + return pte; +} +extern inline pte_t pte_mkexec(pte_t pte) +{ + pte_val(pte) |= _PAGE_READ; + if (pte_val(pte) & _PAGE_ACCESSED) + pte_val(pte) |= _PAGE_SILENT_READ; + return pte; +} +extern inline pte_t pte_mkdirty(pte_t pte) +{ + pte_val(pte) |= _PAGE_MODIFIED; + if (pte_val(pte) & _PAGE_WRITE) + pte_val(pte) |= _PAGE_SILENT_WRITE; + return pte; +} +extern inline pte_t pte_mkyoung(pte_t pte) +{ + pte_val(pte) |= _PAGE_ACCESSED; + if (pte_val(pte) & _PAGE_READ) + { + pte_val(pte) |= _PAGE_SILENT_READ; + if ((pte_val(pte) & (_PAGE_WRITE|_PAGE_MODIFIED)) == (_PAGE_WRITE|_PAGE_MODIFIED)) + pte_val(pte) |= _PAGE_SILENT_WRITE; + } + return pte; +} +extern inline pte_t pte_mkcow(pte_t pte) +{ + pte_val(pte) |= _PAGE_COW; + return pte; +} + +/* + * Conversion functions: convert a page and protection to a page entry, + * and a page entry and page directory to the page they refer to. + */ +extern inline pte_t mk_pte(unsigned long page, pgprot_t pgprot) +{ pte_t pte; pte_val(pte) = (page - PAGE_OFFSET) | pgprot_val(pgprot); return pte; } + +extern inline pte_t pte_modify(pte_t pte, pgprot_t newprot) +{ pte_val(pte) = (pte_val(pte) & _PAGE_CHG_MASK) | pgprot_val(newprot); return pte; } + +/* to find an entry in a page-table-directory */ +extern inline pgd_t * pgd_offset(struct task_struct * tsk, unsigned long address) +{ + return (pgd_t *) (tsk->tss.pg_dir + PT_OFFSET) + + (address >> PGDIR_SHIFT); +} + +/* Find an entry in the second-level page table.. */ +extern inline pmd_t * pmd_offset(pgd_t * dir, unsigned long address) +{ + return (pmd_t *) dir; +} + +/* Find an entry in the third-level page table.. */ +extern inline pte_t * pte_offset(pmd_t * dir, unsigned long address) +{ + return (pte_t *) (pmd_page(*dir) + (PT_OFFSET - PAGE_OFFSET)) + + ((address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)); +} + +/* + * Allocate and free page tables. The xxx_kernel() versions are + * used to allocate a kernel page table - this turns on ASN bits + * if any, and marks the page tables reserved. + */ +extern inline void pte_free_kernel(pte_t * pte) +{ + unsigned long page = (unsigned long) pte; + + mem_map[MAP_NR(pte)] = 1; + if(!page) + return; + page -= (PT_OFFSET - PAGE_OFFSET); + free_page(page); +} + +extern inline pte_t * pte_alloc_kernel(pmd_t *pmd, unsigned long address) +{ + address = (address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1); + if (pmd_none(*pmd)) { + unsigned long page = __get_free_page(GFP_KERNEL); + if (pmd_none(*pmd)) { + if (page) { + mem_map[MAP_NR(page)] = MAP_PAGE_RESERVED; + sys_cacheflush((void *)page, PAGE_SIZE, DCACHE); + sync_mem(); + page += (PT_OFFSET - PAGE_OFFSET); + memset((void *) page, 0, PAGE_SIZE); + pmd_set(pmd, (pte_t *)page); + return ((pte_t *)page) + address; + } + pmd_set(pmd, (pte_t *) BAD_PAGETABLE); + return NULL; + } + free_page(page); + } + if (pmd_bad(*pmd)) { + printk("Bad pmd in pte_alloc_kernel: %08lx\n", pmd_val(*pmd)); + pmd_set(pmd, (pte_t *) BAD_PAGETABLE); + return NULL; + } + return (pte_t *) (pmd_page(*pmd) + (PT_OFFSET - PAGE_OFFSET)) + address; +} + +/* + * allocating and freeing a pmd is trivial: the 1-entry pmd is + * inside the pgd, so has no extra memory associated with it. + */ +extern inline void pmd_free_kernel(pmd_t * pmd) +{ +} + +extern inline pmd_t * pmd_alloc_kernel(pgd_t * pgd, unsigned long address) +{ + return (pmd_t *) pgd; +} + +extern inline void pte_free(pte_t * pte) +{ + unsigned long page = (unsigned long) pte; + + if(!page) + return; + page -= (PT_OFFSET - PAGE_OFFSET); + free_page(page); +} + +extern inline pte_t * pte_alloc(pmd_t * pmd, unsigned long address) +{ + address = (address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1); + if (pmd_none(*pmd)) { + unsigned long page = __get_free_page(GFP_KERNEL); + if (pmd_none(*pmd)) { + if (page) { + sys_cacheflush((void *)page, PAGE_SIZE, DCACHE); + sync_mem(); + page += (PT_OFFSET - PAGE_OFFSET); + memset((void *) page, 0, PAGE_SIZE); + pmd_set(pmd, (pte_t *)page); + return ((pte_t *)page) + address; + } + pmd_set(pmd, (pte_t *) BAD_PAGETABLE); + return NULL; + } + free_page(page); + } + if (pmd_bad(*pmd)) { + printk("Bad pmd in pte_alloc: %08lx\n", pmd_val(*pmd)); + pmd_set(pmd, (pte_t *) BAD_PAGETABLE); + return NULL; + } + return (pte_t *) (pmd_page(*pmd) + (PT_OFFSET - PAGE_OFFSET)) + address; +} + +/* + * allocating and freeing a pmd is trivial: the 1-entry pmd is + * inside the pgd, so has no extra memory associated with it. + */ +extern inline void pmd_free(pmd_t * pmd) +{ +} + +extern inline pmd_t * pmd_alloc(pgd_t * pgd, unsigned long address) +{ + return (pmd_t *) pgd; +} + +extern inline void pgd_free(pgd_t * pgd) +{ + unsigned long page = (unsigned long) pgd; + + if(!page) + return; + page -= (PT_OFFSET - PAGE_OFFSET); + free_page(page); +} + +/* + * Initialize new page directory with pointers to invalid ptes + */ +extern inline void pgd_init(unsigned long page) +{ + unsigned long dummy1, dummy2; + + page += (PT_OFFSET - PAGE_OFFSET); +#ifdef __R4000__ + /* + * Ich will Spass - ich geb Gas ich geb Gas... + */ + __asm__ __volatile__( + ".set\tnoreorder\n\t" + ".set\tnoat\n\t" + ".set\tmips3\n\t" + "dsll32\t$1,%2,0\n\t" + "dsrl32\t%2,$1,0\n\t" + "or\t%2,$1\n" + "1:\tsd\t%2,(%0)\n\t" + "subu\t%1,1\n\t" + "bnez\t%1,1b\n\t" + "addiu\t%0,8\n\t" + ".set\tmips0\n\t" + ".set\tat\n\t" + ".set\treorder" + :"=r" (dummy1), + "=r" (dummy2) + :"r" (((unsigned long) invalid_pte_table - PAGE_OFFSET) | + _PAGE_TABLE), + "0" (page), + "1" (PAGE_SIZE/(sizeof(pmd_t)*2)) + :"$1"); +#else + __asm__ __volatile__( + ".set\tnoreorder\n" + "1:\tsw\t%2,(%0)\n\t" + "subu\t%1,1\n\t" + "bnez\t%1,1b\n\t" + "addiu\t%0,4\n\t" + ".set\treorder" + :"=r" (dummy1), + "=r" (dummy2) + :"r" (((unsigned long) invalid_pte_table - PAGE_OFFSET) | + _PAGE_TABLE), + "0" (page), + "1" (PAGE_SIZE/sizeof(pmd_t))); +#endif +} + +extern inline pgd_t * pgd_alloc(void) +{ + unsigned long page; + + if(!(page = __get_free_page(GFP_KERNEL))) + return NULL; + + sys_cacheflush((void *)page, PAGE_SIZE, DCACHE); + sync_mem(); + pgd_init(page); + + return (pgd_t *) (page + (PT_OFFSET - PAGE_OFFSET)); +} + +extern pgd_t swapper_pg_dir[1024]; + +/* + * MIPS doesn't need any external MMU info: the kernel page + * tables contain all the necessary information. + */ +extern inline void update_mmu_cache(struct vm_area_struct * vma, + unsigned long address, pte_t pte) +{ +} + +#if __mips >= 3 + +#define SWP_TYPE(entry) (((entry) >> 32) & 0xff) +#define SWP_OFFSET(entry) ((entry) >> 40) +#define SWP_ENTRY(type,offset) pte_val(mk_swap_pte((type),(offset))) + +#else + +#define SWP_TYPE(entry) (((entry) >> 1) & 0x7f) +#define SWP_OFFSET(entry) ((entry) >> 8) +#define SWP_ENTRY(type,offset) (((type) << 1) | ((offset) << 8)) + +#endif + +#endif /* !defined (__LANGUAGE_ASSEMBLY__) */ + +#endif /* __ASM_MIPS_PGTABLE_H */ diff --git a/include/asm-mips/pica.h b/include/asm-mips/pica.h new file mode 100644 index 000000000..799dcf4a0 --- /dev/null +++ b/include/asm-mips/pica.h @@ -0,0 +1,181 @@ +/* + * Hardware info about Acer PICA 61 and similar + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file "COPYING" in the main directory of this archive + * for more details. + * + * Copyright (C) 1995 by Andreas Busse and Ralf Baechle + */ +#ifndef __ASM_MIPS_PICA_H +#define __ASM_MIPS_PICA_H + +/* + * The addresses below are virtual address. The mappings are + * created on startup via wired entries in the tlb. The Mips + * Magnum R3000 and R4000 machines are similar in many aspects, + * but many hardware register are accessible at 0xb9000000 in + * instead of 0xe0000000. + */ + +/* + * Revision numbers in PICA_ASIC_REVISION + * + * 0xf0000000 - Rev1 + * 0xf0000001 - Rev2 + * 0xf0000002 - Rev3 + */ +#define PICA_ASIC_REVISION 0xe0000008 + +/* + * The segments of the seven segment LED are mapped + * to the control bits as follows: + * + * (7) + * --------- + * | | + * (2) | | (6) + * | (1) | + * --------- + * | | + * (3) | | (5) + * | (4) | + * --------- . (0) + */ +#define PICA_LED 0xe000f000 + +/* + * Some characters for the LED control registers + * The original Mips machines seem to have a LED display + * with integrated decoder while the Acer machines can + * control each of the seven segments and the dot independend. + * It only a toy, anyway... + */ +#define LED_DOT 0x01 +#define LED_SPACE 0x00 +#define LED_0 0xfc +#define LED_1 0x60 +#define LED_2 0xda +#define LED_3 0xf2 +#define LED_4 0x66 +#define LED_5 0xb6 +#define LED_6 0xbe +#define LED_7 0xe0 +#define LED_8 0xfe +#define LED_9 0xf6 +#define LED_A 0xee +#define LED_b 0x3e +#define LED_C 0x9c +#define LED_d 0x7a +#define LED_E 0x9e +#define LED_F 0x8e + +#ifndef __LANGUAGE_ASSEMBLY__ + +extern __inline__ void pica_set_led(unsigned int bits) +{ + volatile unsigned int *led_register = (unsigned int *) PICA_LED; + + *led_register = bits; +} + +#endif + +/* + * i8042 keyboard controller for PICA chipset. + * This address is just a guess and seems to differ + * from the other mips machines... + */ +#define PICA_KEYBOARD_ADDRESS 0xe0005000 +#define PICA_KEYBOARD_DATA 0xe0005000 +#define PICA_KEYBOARD_COMMAND 0xe0005001 + +#ifndef __LANGUAGE_ASSEMBLY__ + +typedef struct { + unsigned char data; + unsigned char command; +} pica_keyboard_hardware; + +typedef struct { + unsigned char pad0[3]; + unsigned char data; + unsigned char pad1[3]; + unsigned char command; +} mips_keyboard_hardware; + +/* + * For now + */ +#define keyboard_hardware pica_keyboard_hardware + +#endif + +/* + * i8042 keyboard controller for most other Mips machines. + */ +#define MIPS_KEYBOARD_ADDRESS 0xb9005000 +#define MIPS_KEYBOARD_DATA 0xb9005003 +#define MIPS_KEYBOARD_COMMAND 0xb9005007 + +#ifndef __LANGUAGE_ASSEMBLY__ + +#endif + +/* + * PICA timer registers and interrupt no. + * Note that the hardware timer interrupt is actually on + * cpu level 6, but to keep compatibility with PC stuff + * it is remapped to vector 0. See arch/mips/kernel/entry.S. + */ +#define PICA_TIMER_INTERVAL 0xe0000228 +#define PICA_TIMER_REGISTER 0xe0000230 + +/* + * DRAM configuration register + */ +#ifndef __LANGUAGE_ASSEMBLY__ +#ifdef __MIPSEL__ +typedef struct { + unsigned int bank2 : 3; + unsigned int bank1 : 3; + unsigned int mem_bus_width : 1; + unsigned int reserved2 : 1; + unsigned int page_mode : 1; + unsigned int reserved1 : 23; +} dram_configuration; +#else /* defined (__MIPSEB__) */ +typedef struct { + unsigned int reserved1 : 23; + unsigned int page_mode : 1; + unsigned int reserved2 : 1; + unsigned int mem_bus_width : 1; + unsigned int bank1 : 3; + unsigned int bank2 : 3; +} dram_configuration; +#endif +#endif /* __LANGUAGE_ASSEMBLY__ */ + +#define PICA_DRAM_CONFIG 0xe00fffe0 + +/* + * PICA interrupt control registers + */ +#define PICA_IO_IRQ_SOURCE 0xe0100000 +#define PICA_IO_IRQ_ENABLE 0xe0100002 + +/* + * Pica interrupt enable bits + */ +#define PIE_PARALLEL (1<<0) +#define PIE_FLOPPY (1<<1) +#define PIE_SOUND (1<<2) +#define PIE_VIDEO (1<<3) +#define PIE_ETHERNET (1<<4) +#define PIE_SCSI (1<<5) +#define PIE_KEYBOARD (1<<6) +#define PIE_MOUSE (1<<7) +#define PIE_SERIAL1 (1<<8) +#define PIE_SERIAL2 (1<<9) + +#endif /* __ASM_MIPS_PICA_H */ diff --git a/include/asm-mips/processor.h b/include/asm-mips/processor.h new file mode 100644 index 000000000..8e3e00267 --- /dev/null +++ b/include/asm-mips/processor.h @@ -0,0 +1,198 @@ +/* + * include/asm-mips/processor.h + * + * Copyright (C) 1994 Waldorf Electronics + * written by Ralf Baechle + */ + +#ifndef __ASM_MIPS_PROCESSOR_H +#define __ASM_MIPS_PROCESSOR_H + +#if !defined (__LANGUAGE_ASSEMBLY__) +#include <asm/cachectl.h> +#include <asm/system.h> + +/* + * System setup and hardware bug flags.. + */ +extern char wait_available; /* only available on R4[26]00 */ + +extern unsigned long intr_count; +extern unsigned long event; + +/* + * Bus types (default is ISA, but people can check others with these..) + * MCA_bus hardcoded to 0 for now. + * + * This needs to be extended since MIPS systems are being delivered with + * numerous different types of bus systems. + */ +extern int EISA_bus; +#define MCA_bus 0 +#define MCA_bus__is_a_macro /* for versions in ksyms.c */ + +/* + * MIPS has no problems with write protection + */ +#define wp_works_ok 1 +#define wp_works_ok__is_a_macro /* for versions in ksyms.c */ + +/* + * User space process size: 2GB. This is hardcoded into a few places, + * so don't change it unless you know what you are doing. + */ +#define TASK_SIZE (0x80000000UL) + +/* + * Size of io_bitmap in longwords: 32 is ports 0-0x3ff. + */ +#define IO_BITMAP_SIZE 32 + +#define NUM_FPU_REGS 32 + +struct mips_fpu_hard_struct { + double fp_regs[NUM_FPU_REGS]; + unsigned int control; +}; + +/* + * FIXME: no fpu emulator yet (but who cares anyway?) + */ +struct mips_fpu_soft_struct { + long dummy; + }; + +union mips_fpu_union { + struct mips_fpu_hard_struct hard; + struct mips_fpu_soft_struct soft; +}; + +#define INIT_FPU { \ + {{0,},} \ +} + +/* + * If you change thread_struct remember to change the #defines below too! + */ +struct thread_struct { + /* + * saved main processor registers + */ + unsigned long reg16, reg17, reg18, reg19, reg20, reg21, reg22, reg23; + unsigned long reg28, reg29, reg30, reg31; + /* + * saved cp0 stuff + */ + unsigned long cp0_status; + /* + * saved fpu/fpu emulator stuff + */ + union mips_fpu_union fpu; + /* + * Other stuff associated with the process + */ + unsigned long cp0_badvaddr; + unsigned long error_code; + unsigned long trap_no; + unsigned long ksp; /* Top of kernel stack */ + unsigned long pg_dir; /* L1 page table pointer */ +}; + +#endif /* !defined (__LANGUAGE_ASSEMBLY__) */ + +/* + * If you change the #defines remember to change thread_struct above too! + */ +#define TOFF_REG16 0 +#define TOFF_REG17 (TOFF_REG16+4) +#define TOFF_REG18 (TOFF_REG17+4) +#define TOFF_REG19 (TOFF_REG18+4) +#define TOFF_REG20 (TOFF_REG19+4) +#define TOFF_REG21 (TOFF_REG20+4) +#define TOFF_REG22 (TOFF_REG21+4) +#define TOFF_REG23 (TOFF_REG22+4) +#define TOFF_REG28 (TOFF_REG23+4) +#define TOFF_REG29 (TOFF_REG28+4) +#define TOFF_REG30 (TOFF_REG29+4) +#define TOFF_REG31 (TOFF_REG30+4) +#define TOFF_CP0_STATUS (TOFF_REG31+4) +/* + * Pad for 8 byte boundary! + */ +#define TOFF_FPU (((TOFF_CP0_STATUS+4)+(8-1))&~(8-1)) +#define TOFF_CP0_BADVADDR (TOFF_FPU+264) +#define TOFF_ERROR_CODE (TOFF_CP0_BADVADDR+4) +#define TOFF_TRAP_NO (TOFF_ERROR_CODE+4) +#define TOFF_KSP (TOFF_TRAP_NO+4) +#define TOFF_PG_DIR (TOFF_KSP+4) + +#if !defined (__LANGUAGE_ASSEMBLY__) + +#define INIT_MMAP { &init_task, 0, 0x40000000, PAGE_SHARED, VM_READ | VM_WRITE | VM_EXEC } + +#define INIT_TSS { \ + /* \ + * saved main processor registers \ + */ \ + 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, \ + /* \ + * saved cp0 stuff \ + */ \ + 0, \ + /* \ + * saved fpu/fpu emulator stuff \ + */ \ + INIT_FPU, \ + /* \ + * Other stuff associated with the process\ + */ \ + 0, 0, 0, sizeof(init_kernel_stack) + (unsigned long)init_kernel_stack - 8, \ + (unsigned long) swapper_pg_dir - PT_OFFSET \ +} + +/* + * Do necessary setup to start up a newly executed thread. + */ +static __inline__ +void start_thread(struct pt_regs * regs, unsigned long pc, unsigned long sp) +{ + sys_cacheflush(0, ~0, BCACHE); + sync_mem(); + regs->cp0_epc = pc; + /* + * New thread looses kernel priviledges + */ + regs->cp0_status = (regs->cp0_status & ~ST0_KSU) | KSU_USER; + regs->reg29 = sp; +} + +#ifdef __KERNEL__ + +/* + * 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. + */ +asmlinkage void resume(struct task_struct *tsk, int offset); + +#define switch_to(n) \ + resume(n, ((int)(&((struct task_struct *)0)->tss))) + +/* + * Does the process account for user or for system time? + */ +#if defined (__R4000__) + +#define USES_USER_TIME(regs) (!((regs)->cp0_status & 0x18)) + +#else /* !defined (__R4000__) */ + +#define USES_USER_TIME(regs) (!((regs)->cp0_status & 0x4)) + +#endif /* !defined (__R4000__) */ + +#endif /* __KERNEL__ */ + +#endif /* !defined (__LANGUAGE_ASSEMBLY__) */ + +#endif /* __ASM_MIPS_PROCESSOR_H */ diff --git a/include/asm-mips/ptrace.h b/include/asm-mips/ptrace.h index 97b08ce74..18cdb8387 100644 --- a/include/asm-mips/ptrace.h +++ b/include/asm-mips/ptrace.h @@ -1,110 +1,132 @@ /* * linux/include/asm-mips/ptrace.h * - * machine dependend structs and defines to help the user use + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file "COPYING" in the main directory of this archive + * for more details. + * + * Copyright (C) 1994, 1995 by Waldorf GMBH + * written by Ralf Baechle + * + * Machine dependent structs and defines to help the user use * the ptrace system call. */ -#ifndef _ASM_MIPS_PTRACE_H -#define _ASM_MIPS_PTRACE_H +#ifndef __ASM_MIPS_PTRACE_H +#define __ASM_MIPS_PTRACE_H /* - * use ptrace (3 or 6, pid, PT_EXCL, data); to read or write - * the processes registers. - * - * This defines/structures corrospond to the register layout on stack - + * This defines/structures correspond to the register layout on stack - * if the order here is changed, it needs to be updated in - * arch/mips/fork.c:copy_process, asm/mips/signal.c:do_signal, - * asm-mips/ptrace.c, include/asm-mips/ptrace.h. + * include/asm-mips/stackframe.h */ - -#define IN_REG1 0 -#define IN_REG2 1 -#define IN_REG3 2 -#define IN_REG4 3 -#define IN_REG5 4 -#define IN_REG6 5 -#define IN_REG7 6 -#define IN_REG8 7 -#define IN_REG9 8 -#define IN_REG10 9 -#define IN_REG11 10 -#define IN_REG12 11 -#define IN_REG13 12 -#define IN_REG14 13 -#define IN_REG15 14 -#define IN_REG16 15 -#define IN_REG17 16 -#define IN_REG18 17 -#define IN_REG19 18 -#define IN_REG20 19 -#define IN_REG21 20 -#define IN_REG22 21 -#define IN_REG23 22 -#define IN_REG24 23 -#define IN_REG25 24 - +#define IN_REG1 5 +#define IN_REG2 6 +#define IN_REG3 7 +#define IN_REG4 8 +#define IN_REG5 9 +#define IN_REG6 10 +#define IN_REG7 11 +#define IN_REG8 12 +#define IN_REG9 13 +#define IN_REG10 14 +#define IN_REG11 15 +#define IN_REG12 16 +#define IN_REG13 17 +#define IN_REG14 18 +#define IN_REG15 19 +#define IN_REG16 20 +#define IN_REG17 21 +#define IN_REG18 22 +#define IN_REG19 23 +#define IN_REG20 24 +#define IN_REG21 25 +#define IN_REG22 26 +#define IN_REG23 27 +#define IN_REG24 28 +#define IN_REG25 29 /* - * k0 and k1 not saved + * k0/k1 unsaved */ -#define IN_REG28 25 -#define IN_REG29 26 -#define IN_REG30 27 -#define IN_REG31 28 +#define IN_REG28 30 +#define IN_REG29 31 +#define IN_REG30 32 +#define IN_REG31 33 /* * Saved special registers */ -#define FR_LO ((IN_REG31) + 1) -#define FR_HI ((IN_LO) + 1) +#define IN_LO 34 +#define IN_HI 35 /* - * Saved cp0 registers + * saved cp0 registers */ -#define IN_CP0_STATUS ((IN_LO) + 1) -#define IN_CP0_EPC ((IN_CP0_STATUS) + 1) -#define IN_CP0_ERROREPC ((IN_CP0_EPC) + 1) +#define IN_CP0_STATUS 36 +#define IN_CP0_EPC 37 +#define IN_CP0_CAUSE 38 /* - * Some goodies... + * Some goodies */ -#define IN_INTERRUPT ((IN_CP0_ERROREPC) + 1) -#define IN_ORIG_REG2 ((IN_INTERRUPT) + 1) +#define IN_INTERRUPT 39 +#define IN_ORIG_REG2 40 /* - * this struct defines the way the registers are stored on the - * stack during a system call/exception. As usual the registers - * k0/k1 aren't being saved. + * This struct defines the way the registers are stored on the stack during a + * system call/exception. As usual the registers k0/k1 aren't being saved. */ - struct pt_regs { /* + * Pad bytes for argument save space on the stack + * 20/40 Bytes for 32/64 bit code + */ + unsigned long pad0[5]; + + /* * saved main processor registers */ long reg1, reg2, reg3, reg4, reg5, reg6, reg7; long reg8, reg9, reg10, reg11, reg12, reg13, reg14, reg15; long reg16, reg17, reg18, reg19, reg20, reg21, reg22, reg23; long reg24, reg25, reg28, reg29, reg30, reg31; + /* * Saved special registers */ long lo; long hi; + /* * saved cp0 registers */ unsigned long cp0_status; unsigned long cp0_epc; - unsigned long cp0_errorepc; + unsigned long cp0_cause; + /* * Some goodies... */ unsigned long interrupt; long orig_reg2; + long pad1; }; +#ifdef __KERNEL__ + /* - * This function computes the interrupt number from the stack frame + * Does the process account for user or for system time? */ -#define pt_regs2irq(p) ((int) ((struct pt_regs *)p)->interrupt) +#if defined (__R4000__) + +#define user_mode(regs) ((regs)->cp0_status & 0x10) + +#else /* !defined (__R4000__) */ + +#define user_mode(regs) (!((regs)->cp0_status & 0x8)) + +#endif /* !defined (__R4000__) */ + +extern void show_regs(struct pt_regs *); +#endif -#endif /* _ASM_MIPS_PTRACE_H */ +#endif /* __ASM_MIPS_PTRACE_H */ diff --git a/include/asm-mips/regdef.h b/include/asm-mips/regdef.h index 1fbe8f19f..ec455790e 100644 --- a/include/asm-mips/regdef.h +++ b/include/asm-mips/regdef.h @@ -5,17 +5,17 @@ * License. See the file "COPYING" in the main directory of this archive * for more details. * - * Copyright (C) 1994 by Ralf Baechle + * Copyright (C) 1994, 1995 by Ralf Baechle */ -#ifndef _ASM_MIPS_REGSDEFS_H_ -#define _ASM_MIPS_REGSDEFS_H_ +#ifndef __ASM_MIPS_REGDEF_H +#define __ASM_MIPS_REGDEF_H /* * Symbolic register names */ #define zero $0 /* wired zero */ -#define AT $1 /* assembler temp (uprcase, because ".set at") */ +#define AT $1 /* assembler temp - uppercase because of ".set at" */ #define v0 $2 /* return value */ #define v1 $3 #define a0 $4 /* argument registers */ @@ -47,4 +47,4 @@ #define fp $30 /* frame pointer */ #define ra $31 /* return address */ -#endif /* _ASM_MIPS_REGSDEFS_H_ */ +#endif /* __ASM_MIPS_REGDEF_H */ diff --git a/include/asm-mips/resource.h b/include/asm-mips/resource.h new file mode 100644 index 000000000..001f92435 --- /dev/null +++ b/include/asm-mips/resource.h @@ -0,0 +1,25 @@ +#ifndef __ASM_MIPS_RESOURCE_H +#define __ASM_MIPS_RESOURCE_H + +/* + * 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_NOFILE 5 /* max number of open files */ +#define RLIMIT_VMEM 6 /* mapped memory */ +#define RLIMIT_AS RLIMIT_VMEM +#define RLIMIT_RSS 7 /* max resident set size */ +#define RLIMIT_NPROC 8 /* max number of processes */ + +#ifdef notdef +#define RLIMIT_MEMLOCK 8 /* max locked-in-memory address space*/ +#endif + +#define RLIM_NLIMITS 9 + +#endif /* __ASM_MIPS_RESOURCE_H */ diff --git a/include/asm-mips/sched.h b/include/asm-mips/sched.h deleted file mode 100644 index 661675a37..000000000 --- a/include/asm-mips/sched.h +++ /dev/null @@ -1,240 +0,0 @@ -#ifndef _ASM_MIPS_SCHED_H -#define _ASM_MIPS_SCHED_H - -#include <asm/system.h> - -/* - * System setup and hardware bug flags.. - */ -extern int hard_math; -extern int wp_works_ok; /* doesn't work on a 386 */ - -extern unsigned long intr_count; -extern unsigned long event; - -#define start_bh_atomic() \ -{int flags; save_flags(flags); cli(); intr_count++; restore_flags(flags)} - -#define end_bh_atomic() \ -{int flags; save_flags(flags); cli(); intr_count--; restore_flags(flags)} - -/* - * 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 - -/* - * User space process size: 2GB. This is hardcoded into a few places, - * so don't change it unless you know what you are doing. - */ -#define TASK_SIZE 0x80000000 - -#define NUM_FPA_REGS 32 - -struct mips_fpa_hard_struct { - float fp_regs[NUM_FPA_REGS]; - unsigned int control; -}; - -struct mips_fpa_soft_struct { - /* - * FIXME: no fpa emulator yet, but who cares? - */ - long dummy; - }; - -union mips_fpa_union { - struct mips_fpa_hard_struct hard; - struct mips_fpa_soft_struct soft; -}; - -#define INIT_FPA { \ - 0, \ -} - -struct tss_struct { - /* - * saved main processor registers - */ - unsigned long reg1, reg2, reg3, reg4, reg5, reg6, reg7; - unsigned long reg8, reg9, reg10, reg11, reg12, reg13, reg14, reg15; - unsigned long reg16, reg17, reg18, reg19, reg20, reg21, reg22, reg23; - unsigned long reg24, reg25, reg26, reg29, reg30, reg31; - /* - * saved cp0 registers - */ - unsigned int cp0_status; - unsigned long cp0_epc; - unsigned long cp0_errorepc; - unsigned long cp0_context; - /* - * saved fpa/fpa emulator stuff - */ - union mips_fpa_union fpa; - /* - * Other stuff associated with the process - */ - unsigned long cp0_badvaddr; - unsigned long errorcode; - unsigned long trap_no; - unsigned long fs; /* "Segment" pointer */ - unsigned long ksp; /* Kernel stack pointer */ - unsigned long pg_dir; /* L1 page table pointer */ -}; - -#define INIT_TSS { \ - /* \ - * saved main processor registers \ - */ \ - 0, 0, 0, 0, 0, 0, 0, \ - 0, 0, 0, 0, 0, 0, 0, 0, \ - 0, 0, 0, 0, 0, 0, 0, 0, \ - 0, 0, 0, 0, 0, 0, \ - /* \ - * saved cp0 registers \ - */ \ - 0, 0, 0, 0, \ - /* \ - * saved fpa/fpa emulator stuff \ - */ \ - INIT_FPA, \ - /* \ - * Other stuff associated with the process\ - */ \ - 0, 0, 0, KERNEL_DS, 0, 0 \ -} - -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]; -}; - -/* - * 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__ - -/* - * 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__(""::); /* fix me */ - -/* - * Does the process account for user or for system time? - */ -#define USES_USER_TIME(regs) (!((regs)->cp0_status & 0x18)) - -#endif /* __KERNEL__ */ - -#endif /* _ASM_MIPS_SCHED_H */ diff --git a/include/asm-mips/segment.h b/include/asm-mips/segment.h index 511c499c8..73c0de45f 100644 --- a/include/asm-mips/segment.h +++ b/include/asm-mips/segment.h @@ -5,223 +5,193 @@ * License. See the file "COPYING" in the main directory of this archive * for more details. * - * Copyright (C) 1994 by Ralf Baechle + * Copyright (C) 1994, 1995 by Ralf Baechle * */ +#ifndef __ASM_MIPS_SEGMENT_H +#define __ASM_MIPS_SEGMENT_H -#ifndef _ASM_MIPS_SEGMENT_H_ -#define _ASM_MIPS_SEGMENT_H_ - -#define KERNEL_CS 0x80000000 -#define KERNEL_DS KERNEL_CS +#ifndef __LANGUAGE_ASSEMBLY__ +/* + * Uh, these should become the main single-value transfer routines.. + * They automatically use the right size if we just have the right + * pointer type.. + */ +#define put_user(x,ptr) __put_user((unsigned long)(x),(ptr),sizeof(*(ptr))) +#define get_user(ptr) __get_user((ptr),sizeof(*(ptr))) -#define USER_CS 0x00000000 -#define USER_DS USER_CS +/* + * This is a silly but good way to make sure that + * the __put_user function is indeed always optimized, + * and that we use the correct sizes.. + */ +extern int bad_user_access_length(void); -#ifndef __ASSEMBLY__ +/* I should make this use unaligned transfers etc.. */ +static inline void __put_user(unsigned long x, void * y, int size) +{ + switch (size) { + case 1: + *(char *) y = x; + break; + case 2: + *(short *) y = x; + break; + case 4: + *(int *) y = x; + break; + case 8: + *(long *) y = x; + break; + default: + bad_user_access_length(); + } +} -static inline unsigned char get_user_byte(const char * addr) +/* I should make this use unaligned transfers etc.. */ +static inline unsigned long __get_user(void * y, int size) { - unsigned char _v; + switch (size) { + case 1: + return *(unsigned char *) y; + case 2: + return *(unsigned short *) y; + case 4: + return *(unsigned int *) y; + case 8: + return *(unsigned long *) y; + default: + return bad_user_access_length(); + } +} +#endif /* __LANGUAGE_ASSEMBLY__ */ - __asm__ ("lbu\t%0,(%1)":"=r" (_v):"r" (*addr)); +/* + * Memory segments (32bit kernel mode addresses) + */ +#define KUSEG 0x00000000 +#define KSEG0 0x80000000 +#define KSEG1 0xa0000000 +#define KSEG2 0xc0000000 +#define KSEG3 0xe0000000 - return _v; -} +/* + * Returns the kernel segment base of a given address + */ +#define KSEGX(a) (a & 0xe0000000) -#define get_fs_byte(addr) get_user_byte((char *)(addr)) +/* + * Returns the physical address of a KSEG0/KSEG1 address + */ -static inline unsigned short get_user_word(const short *addr) -{ - unsigned short _v; +#define PHYSADDR(a) ((unsigned long)a & 0x1fffffff) - __asm__ ("lhu\t%0,(%1)":"=r" (_v):"r" (*addr)); +/* + * Map an address to a certain kernel segment + */ - return _v; -} +#define KSEG0ADDR(a) (((unsigned long)a & 0x1fffffff) | KSEG0) +#define KSEG1ADDR(a) (((unsigned long)a & 0x1fffffff) | KSEG1) +#define KSEG2ADDR(a) (((unsigned long)a & 0x1fffffff) | KSEG2) +#define KSEG3ADDR(a) (((unsigned long)a & 0x1fffffff) | KSEG3) -#define get_fs_word(addr) get_user_word((short *)(addr)) -static inline unsigned long get_user_long(const int *addr) +/* + * Memory segments (64bit kernel mode addresses) + */ +#define XKUSEG 0x0000 0000 0000 0000 +#define XKSSEG 0x4000 0000 0000 0000 +#define XKPHYS 0x8000 0000 0000 0000 +#define XKSEG 0xc000 0000 0000 0000 +#define CKSEG0 0xffff ffff 8000 0000 +#define CKSEG1 0xffff ffff a000 0000 +#define CKSSEG 0xffff ffff c000 0000 +#define CKSEG3 0xffff ffff e000 0000 + +#ifndef __LANGUAGE_ASSEMBLY__ +/* + * These are deprecated + */ + +#define get_fs_byte(addr) get_user_byte((char *)(addr)) +static inline unsigned char get_user_byte(const char *addr) { - unsigned long _v; + return *addr; +} - __asm__ ("lwu\t%0,(%1)":"=r" (_v):"r" (*addr)); \ - return _v; +/* + * Beware: the xxx_fs_word functions work on 16bit words! + */ +#define get_fs_word(addr) get_user_word((short *)(addr)) +static inline unsigned short get_user_word(const short *addr) +{ + return *addr; } #define get_fs_long(addr) get_user_long((int *)(addr)) - -static inline unsigned long get_user_dlong(const int *addr) +static inline unsigned long get_user_long(const int *addr) { - unsigned long _v; - - __asm__ ("ld\t%0,(%1)":"=r" (_v):"r" (*addr)); \ - return _v; + return *addr; } -#define get_fs_dlong(addr) get_user_dlong((int *)(addr)) - -static inline void put_user_byte(char val,char *addr) +#define get_fs_dlong(addr) get_user_dlong((long long *)(addr)) +static inline unsigned long get_user_dlong(const long long *addr) { -__asm__ ("sb\t%0,(%1)": /* no outputs */ :"r" (val),"r" (*addr)); + return *addr; } #define put_fs_byte(x,addr) put_user_byte((x),(char *)(addr)) - -static inline void put_user_word(short val,short * addr) +static inline void put_user_byte(char val,char *addr) { -__asm__ ("sh\t%0,(%1)": /* no outputs */ :"r" (val),"r" (*addr)); + *addr = val; } #define put_fs_word(x,addr) put_user_word((x),(short *)(addr)) - -static inline void put_user_long(unsigned long val,int * addr) +static inline void put_user_word(short val,short * addr) { -__asm__ ("sw\t%0,(%1)": /* no outputs */ :"r" (val),"r" (*addr)); + *addr = val; } #define put_fs_long(x,addr) put_user_long((x),(int *)(addr)) - -static inline void put_user_dlong(unsigned long val,int * addr) +static inline void put_user_long(unsigned long val,int * addr) { -__asm__ ("sd\t%0,(%1)": /* no outputs */ :"r" (val),"r" (*addr)); + *addr = val; } #define put_fs_dlong(x,addr) put_user_dlong((x),(int *)(addr)) - -/* - * These following two variables are defined in mips/head.S. - */ -extern unsigned long segment_fs; - -static inline void __generic_memcpy_tofs(void * to, const void * from, unsigned long n) -{ - __asm__( - ".set\tnoreorder\n\t" - ".set\tnoat\n" - "1:\tlbu\t$1,(%2)\n\t" - "addiu\t%2,%2,1\n\t" - "sb\t$1,(%1)\n\t" - "addiu\t%0,%0,-1\n\t" - "bne\t$0,%0,1b\n\t" - "addiu\t%1,%1,1\n\t" - ".set\tat\n\t" - ".set\treorder" - : /* no outputs */ - :"d" (n),"d" (((long) to)| segment_fs),"d" ((long) from) - :"$1"); -} - -static inline void __constant_memcpy_tofs(void * to, const void * from, unsigned long n) -{ - /* - * Use put_user_byte to avoid trouble with alignment. - */ - switch (n) { - case 0: - return; - case 1: - put_user_byte(*(const char *) from, (char *) to); - return; - case 2: - put_user_byte(*(const char *) from, (char *) to); - put_user_byte(*(1+(const char *) from), 1+(char *) to); - return; - case 3: - put_user_byte(*((const char *) from), (char *) to); - put_user_byte(*(1+(const char *) from), 1+(char *) to); - put_user_byte(*(2+(const char *) from), 2+(char *) to); - return; - case 4: - put_user_byte(*((const char *) from), (char *) to); - put_user_byte(*(1+(const char *) from), 1+(char *) to); - put_user_byte(*(2+(const char *) from), 2+(char *) to); - put_user_byte(*(3+(const char *) from), 3+(char *) to); - return; - } - - __generic_memcpy_tofs(to, from, n); - - return; -} - -static inline void __generic_memcpy_fromfs(void * to, const void * from, unsigned long n) +static inline void put_user_dlong(unsigned long val,long long * addr) { - __asm__( - ".set\tnoreorder\n\t" - ".set\tnoat\n" - "1:\tlbu\t$1,(%2)\n\t" - "addiu\t%2,%2,1\n\t" - "sb\t$1,(%1)\n\t" - "addiu\t%0,%0,-1\n\t" - "bne\t$0,%0,1b\n\t" - "addiu\t%1,%1,1\n\t" - ".set\tat\n\t" - ".set\treorder" - : /* no outputs */ - :"d" (n),"d" ((long) to),"d" (((long) from | segment_fs)) - :"$1","memory"); + *addr = val; } -static inline void __constant_memcpy_fromfs(void * to, const void * from, unsigned long n) -{ - /* - * Use put_user_byte to avoid trouble with alignment. - */ - switch (n) { - case 0: - return; - case 1: - *(char *)to = get_user_byte((const char *) from); - return; - case 2: - *(char *) to = get_user_byte((const char *) from); - *(char *) to = get_user_byte(1+(const char *) from); - return; - case 3: - *(char *) to = get_user_byte((const char *) from); - *(char *) to = get_user_byte(1+(const char *) from); - *(char *) to = get_user_byte(2+(const char *) from); - return; - case 4: - *(char *) to = get_user_byte((const char *) from); - *(char *) to = get_user_byte(1+(const char *) from); - *(char *) to = get_user_byte(2+(const char *) from); - *(char *) to = get_user_byte(3+(const char *) from); - return; - } +#define memcpy_fromfs(to, from, n) memcpy((to),(from),(n)) - - __generic_memcpy_fromfs(to, from, n); - return; -} +#define memcpy_tofs(to, from, n) memcpy((to),(from),(n)) -#define memcpy_fromfs(to, from, n) \ -(__builtin_constant_p(n) ? \ - __constant_memcpy_fromfs((to),(from),(n)) : \ - __generic_memcpy_fromfs((to),(from),(n))) +/* + * For segmented architectures, these are used to specify which segment + * to use for the above functions. + * + * MIPS is not segmented, so these are just dummies. + */ -#define memcpy_tofs(to, from, n) \ -(__builtin_constant_p(n) ? \ - __constant_memcpy_tofs((to),(from),(n)) : \ - __generic_memcpy_tofs((to),(from),(n))) +#define KERNEL_DS 0 +#define USER_DS 1 static inline unsigned long get_fs(void) { - return segment_fs; + return 0; } static inline unsigned long get_ds(void) { - return KERNEL_DS; + return 0; } static inline void set_fs(unsigned long val) { - segment_fs = val; } -#endif +#endif /* !__LANGUAGE_ASSEMBLY__ */ -#endif /* _ASM_MIPS_SEGMENT_H_ */ +#endif /* __ASM_MIPS_SEGMENT_H */ diff --git a/include/asm-mips/signal.h b/include/asm-mips/signal.h index 6c66d6271..998d95c14 100644 --- a/include/asm-mips/signal.h +++ b/include/asm-mips/signal.h @@ -1,28 +1,124 @@ -#ifndef _ASM_MIPS_SIGNAL_H -#define _ASM_MIPS_SIGNAL_H +#ifndef __ASM_MIPS_SIGNAL_H +#define __ASM_MIPS_SIGNAL_H -#ifdef __KERNEL__ +#if 0 +/* The Linux/i386 definition */ +typedef unsigned long sigset_t; /* at least 32 bits */ +#endif -struct sigcontext_struct { - /* - * In opposite to the SVr4 implentation in Risc/OS the - * sc_ra points to an address suitable to "jr ra" to. - * Registers that are callee saved by convention aren't - * being saved on entry of a signal handler. - */ - unsigned long sc_at; - unsigned long sc_v0, sc_v1; - unsigned long sc_a0, sc_a1, sc_a2, sc_a3; - unsigned long sc_t0, sc_t1, sc_t2, sc_t3, sc_t4; - unsigned long sc_t5, sc_t6, sc_t7, sc_t8, sc_t9; +#if 1 +/* For now ... */ +#include <asm/types.h> +typedef __u64 sigset_t; +#else +/* This is what we should really use ... */ +typedef struct { + unsigned int sigbits[4]; +} sigset_t; +#endif + +#define _NSIG 65 +#define NSIG _NSIG + +/* + * For 1.3.0 Linux/MIPS changed the signal numbers to be compatible the ABI. + */ +#define SIGHUP 1 +#define SIGINT 2 +#define SIGQUIT 3 +#define SIGILL 4 +#define SIGTRAP 5 +#define SIGIOT 6 +#define SIGABRT SIGIOT +#define SIGEMT 7 +#define SIGFPE 8 +#define SIGKILL 9 +#define SIGBUS 10 +#define SIGSEGV 11 +#define SIGSYS 12 +#define SIGPIPE 13 +#define SIGALRM 14 +#define SIGTERM 15 +#define SIGUSR1 16 +#define SIGUSR2 17 +#define SIGCHLD 18 +#define SIGCLD SIGCHLD +#define SIGPWR 19 +#define SIGWINCH 20 +#define SIGURG 21 +#define SIGIO 22 +#define SIGPOLL SIGIO +#define SIGSTOP 23 +#define SIGTSTP 24 +#define SIGCONT 25 +#define SIGTTIN 26 +#define SIGTTOU 27 +#define SIGVTALRM 28 +#define SIGPROF 29 +#define SIGXCPU 30 +#define SIGXFSZ 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_STACK 0x1 +#define SA_ONSTACK SA_STACK +#define SA_RESTART 0x4 +#define SA_NOCLDSTOP 0x20000 +/* Non ABI signals */ +#define SA_INTERRUPT 0x01000000 +#define SA_NOMASK 0x02000000 +#define SA_ONESHOT 0x04000000 + +#define SIG_BLOCK 1 /* for blocking signals */ +#define SIG_UNBLOCK 2 /* for unblocking signals */ +#define SIG_SETMASK 3 /* 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 { + unsigned int sa_flags; + __sighandler_t sa_handler; + sigset_t sa_mask; + void (*sa_restorer)(void); +#if __mips <= 3 /* - * Old userstack pointer ($29) + * For 32 bit code we have to pad struct sigaction to get + * constant size for the ABI */ - unsigned long sc_sp; + int pad0[2]; /* reserved */ +#endif +}; + +#ifdef __KERNEL__ + +/* + * This struct isn't in the ABI, so we continue to use the old + * pre 1.3 definition. Needs to be changed for 64 bit kernels, + * but it's 4am ... + */ +struct sigcontext_struct { + unsigned long sc_at, sc_v0, sc_v1, sc_a0, sc_a1, sc_a2, sc_a3; + unsigned long sc_t0, sc_t1, sc_t2, sc_t3, sc_t4, sc_t5, sc_t6, sc_t7; + unsigned long sc_s0, sc_s1, sc_s2, sc_s3, sc_s4, sc_s5, sc_s6, sc_s7; + unsigned long sc_t8, sc_t9, sc_gp, sc_sp, sc_fp, sc_ra; + + unsigned long sc_epc; + unsigned long sc_cause; unsigned long oldmask; }; #endif -#endif /* _ASM_MIPS_SIGNAL_H */ +#endif /* __ASM_MIPS_SIGNAL_H */ diff --git a/include/asm-mips/slots.h b/include/asm-mips/slots.h index fa5ae9fcb..4b9eb358c 100644 --- a/include/asm-mips/slots.h +++ b/include/asm-mips/slots.h @@ -1,11 +1,11 @@ /* * include/asm-mips/slots.h * + * Copyright (C) 1994 by Waldorf Electronics * Written by Ralf Baechle - * Copyright (C) 1994 by Waldorf GMBH */ -#ifndef _ASM_MIPS_SLOTS_H -#define _ASM_MIPS_SLOTS_H +#ifndef __ASM_MIPS_SLOTS_H +#define __ASM_MIPS_SLOTS_H /* * SLOTSPACE is the address to which the physical address 0 @@ -14,4 +14,4 @@ */ #define SLOTSPACE 0xe1000000 -#endif /* _ASM_MIPS_SLOTS_H */ +#endif /* __ASM_MIPS_SLOTS_H */ diff --git a/include/asm-mips/stackframe.h b/include/asm-mips/stackframe.h index 0c3c4699c..b3b69f3c6 100644 --- a/include/asm-mips/stackframe.h +++ b/include/asm-mips/stackframe.h @@ -1,59 +1,54 @@ /* * include/asm-mips/stackframe.h * - * Copyright (C) 1994 Waldorf GMBH + * Copyright (C) 1994, 1995 Waldorf Electronics * written by Ralf Baechle */ -#ifndef _ASM_MIPS_STACKFRAME_H_ -#define _ASM_MIPS_STACKFRAME_H_ +#ifndef __ASM_MIPS_STACKFRAME_H +#define __ASM_MIPS_STACKFRAME_H /* * Stack layout for all exceptions: * - * ptrace needs to have all regs on the stack. - * if the order here is changed, it needs to be - * updated in asm/mips/fork.c:copy_process, asm/mips/signal.c:do_signal, - * asm-mips/ptrace.c, include/asm-mips/ptrace.h - * and asm-mips/ptrace - */ - -/* - * Offsets into the Interrupt stackframe. + * ptrace needs to have all regs on the stack. If the order here is changed, + * it needs to be updated in include/asm-mips/ptrace.h + * + * The first PTRSIZE*5 bytes are argument save space for C subroutines. */ -#define FR_REG1 0 -#define FR_REG2 4 -#define FR_REG3 8 -#define FR_REG4 12 -#define FR_REG5 16 -#define FR_REG6 20 -#define FR_REG7 24 -#define FR_REG8 28 -#define FR_REG9 32 -#define FR_REG10 36 -#define FR_REG11 40 -#define FR_REG12 44 -#define FR_REG13 48 -#define FR_REG14 52 -#define FR_REG15 56 -#define FR_REG16 60 -#define FR_REG17 64 -#define FR_REG18 68 -#define FR_REG19 72 -#define FR_REG20 76 -#define FR_REG21 80 -#define FR_REG22 84 -#define FR_REG23 88 -#define FR_REG24 92 -#define FR_REG25 96 +#define FR_REG1 (PTRSIZE*5) +#define FR_REG2 ((FR_REG1) + 4) +#define FR_REG3 ((FR_REG2) + 4) +#define FR_REG4 ((FR_REG3) + 4) +#define FR_REG5 ((FR_REG4) + 4) +#define FR_REG6 ((FR_REG5) + 4) +#define FR_REG7 ((FR_REG6) + 4) +#define FR_REG8 ((FR_REG7) + 4) +#define FR_REG9 ((FR_REG8) + 4) +#define FR_REG10 ((FR_REG9) + 4) +#define FR_REG11 ((FR_REG10) + 4) +#define FR_REG12 ((FR_REG11) + 4) +#define FR_REG13 ((FR_REG12) + 4) +#define FR_REG14 ((FR_REG13) + 4) +#define FR_REG15 ((FR_REG14) + 4) +#define FR_REG16 ((FR_REG15) + 4) +#define FR_REG17 ((FR_REG16) + 4) +#define FR_REG18 ((FR_REG17) + 4) +#define FR_REG19 ((FR_REG18) + 4) +#define FR_REG20 ((FR_REG19) + 4) +#define FR_REG21 ((FR_REG20) + 4) +#define FR_REG22 ((FR_REG21) + 4) +#define FR_REG23 ((FR_REG22) + 4) +#define FR_REG24 ((FR_REG23) + 4) +#define FR_REG25 ((FR_REG24) + 4) /* * $26 (k0) and $27 (k1) not saved */ -#define FR_REG28 100 -#define FR_REG29 104 -#define FR_REG30 108 -#define FR_REG31 112 +#define FR_REG28 ((FR_REG25) + 4) +#define FR_REG29 ((FR_REG28) + 4) +#define FR_REG30 ((FR_REG29) + 4) +#define FR_REG31 ((FR_REG30) + 4) /* * Saved special registers @@ -66,111 +61,129 @@ */ #define FR_STATUS ((FR_HI) + 4) #define FR_EPC ((FR_STATUS) + 4) -#define FR_ERROREPC ((FR_EPC) + 4) +#define FR_CAUSE ((FR_EPC) + 4) /* * Some goodies... */ -#define FR_INTERRUPT ((FR_ERROREPC) + 4) +#define FR_INTERRUPT ((FR_CAUSE) + 4) #define FR_ORIG_REG2 ((FR_INTERRUPT) + 4) +#define FR_PAD1 ((FR_ORIG_REG2) + 4) /* - * Size of stack frame + * Size of stack frame, word/double word alignment */ -#define FR_SIZE ((FR_ORIG_REG2) + 4) +#define FR_SIZE ((((FR_PAD1) + 4) + (PTRSIZE-1)) & ~(PTRSIZE-1)) + +#ifdef __R4000__ -#define SAVE_ALL \ - mfc0 k0,CP0_STATUS; \ - andi k0,k0,0x18; /* extract KSU bits */ \ - beq zero,k0,1f; \ - move k1,sp; \ - /* \ - * Called from user mode, new stack \ - */ \ - lw k1,_kernelsp; \ -1: move k0,sp; \ - subu sp,k1,FR_SIZE; \ - sw k0,FR_REG29(sp); \ - sw $2,FR_REG2(sp); \ - sw $2,FR_ORIG_REG2(sp); \ - mfc0 v0,CP0_STATUS; \ - sw v0,FR_STATUS(sp); \ - mfc0 v0,CP0_EPC; \ - sw v0,FR_EPC(sp); \ - mfc0 v0,CP0_ERROREPC; \ - sw v0,FR_ERROREPC(sp); \ - mfhi v0; \ - sw v0,FR_HI(sp); \ - mflo v0; \ - sw v0,FR_LO(sp); \ - sw $1,FR_REG1(sp); \ - sw $3,FR_REG3(sp); \ - sw $4,FR_REG4(sp); \ - sw $5,FR_REG5(sp); \ - sw $6,FR_REG6(sp); \ - sw $7,FR_REG7(sp); \ - sw $8,FR_REG8(sp); \ - sw $9,FR_REG9(sp); \ - sw $10,FR_REG10(sp); \ - sw $11,FR_REG11(sp); \ - sw $12,FR_REG12(sp); \ - sw $13,FR_REG13(sp); \ - sw $14,FR_REG14(sp); \ - sw $15,FR_REG15(sp); \ - sw $16,FR_REG16(sp); \ - sw $17,FR_REG17(sp); \ - sw $18,FR_REG18(sp); \ - sw $19,FR_REG19(sp); \ - sw $20,FR_REG20(sp); \ - sw $21,FR_REG21(sp); \ - sw $22,FR_REG22(sp); \ - sw $23,FR_REG23(sp); \ - sw $24,FR_REG24(sp); \ - sw $25,FR_REG25(sp); \ - sw $28,FR_REG28(sp); \ - sw $30,FR_REG30(sp); \ +#define SAVE_ALL \ + mfc0 k0,CP0_STATUS; \ + sll k0,3; /* extract cu0 bit */ \ + bltz k0,8f; \ + move k1,sp; \ + /* \ + * Called from user mode, new stack \ + */ \ + lui k1,%hi(kernelsp); \ + lw k1,%lo(kernelsp)(k1); \ +8: move k0,sp; \ + subu sp,k1,FR_SIZE; \ + sw k0,FR_REG29(sp); \ + sw $2,FR_REG2(sp); \ + sw $2,FR_ORIG_REG2(sp); \ + mfc0 v0,CP0_STATUS; \ + sw v0,FR_STATUS(sp); \ + mfc0 v0,CP0_CAUSE; \ + sw v0,FR_CAUSE(sp); \ + mfc0 v0,CP0_EPC; \ + sw v0,FR_EPC(sp); \ + mfhi v0; \ + sw v0,FR_HI(sp); \ + mflo v0; \ + sw v0,FR_LO(sp); \ + sw $1,FR_REG1(sp); \ + sw $3,FR_REG3(sp); \ + sw $4,FR_REG4(sp); \ + sw $5,FR_REG5(sp); \ + sw $6,FR_REG6(sp); \ + sw $7,FR_REG7(sp); \ + sw $8,FR_REG8(sp); \ + sw $9,FR_REG9(sp); \ + sw $10,FR_REG10(sp); \ + sw $11,FR_REG11(sp); \ + sw $12,FR_REG12(sp); \ + sw $13,FR_REG13(sp); \ + sw $14,FR_REG14(sp); \ + sw $15,FR_REG15(sp); \ + sw $16,FR_REG16(sp); \ + sw $17,FR_REG17(sp); \ + sw $18,FR_REG18(sp); \ + sw $19,FR_REG19(sp); \ + sw $20,FR_REG20(sp); \ + sw $21,FR_REG21(sp); \ + sw $22,FR_REG22(sp); \ + sw $23,FR_REG23(sp); \ + sw $24,FR_REG24(sp); \ + sw $25,FR_REG25(sp); \ + sw $28,FR_REG28(sp); \ + sw $30,FR_REG30(sp); \ sw $31,FR_REG31(sp) -#define RESTORE_ALL \ - lw v0,FR_ERROREPC(sp); \ - lw v1,FR_EPC(sp); \ - mtc0 v0,CP0_ERROREPC; \ - lw v0,FR_HI(sp); \ - mtc0 v1,CP0_EPC; \ - lw v1,FR_LO(sp); \ - mthi v0; \ - lw v0,FR_STATUS(sp); \ - mtlo v1; \ - mtc0 v0,CP0_STATUS; \ - lw $31,FR_REG31(sp); \ - lw $30,FR_REG30(sp); \ - lw $28,FR_REG28(sp); \ - lw $25,FR_REG25(sp); \ - lw $24,FR_REG24(sp); \ - lw $23,FR_REG23(sp); \ - lw $22,FR_REG22(sp); \ - lw $21,FR_REG21(sp); \ - lw $20,FR_REG20(sp); \ - lw $19,FR_REG19(sp); \ - lw $18,FR_REG18(sp); \ - lw $17,FR_REG17(sp); \ - lw $16,FR_REG16(sp); \ - lw $15,FR_REG15(sp); \ - lw $14,FR_REG14(sp); \ - lw $13,FR_REG13(sp); \ - lw $12,FR_REG12(sp); \ - lw $11,FR_REG11(sp); \ - lw $10,FR_REG10(sp); \ - lw $9,FR_REG9(sp); \ - lw $8,FR_REG8(sp); \ - lw $7,FR_REG7(sp); \ - lw $6,FR_REG6(sp); \ - lw $5,FR_REG5(sp); \ - lw $4,FR_REG4(sp); \ - lw $3,FR_REG3(sp); \ - lw $2,FR_REG2(sp); \ - lw $1,FR_REG1(sp); \ +/* + * Note that we restore the IE flags from stack. This means + * that a modified IE mask will be nullified. + */ +#define RESTORE_ALL \ + .set mips3; \ + mfc0 t0,CP0_STATUS; \ + ori t0,0x1f; \ + xori t0,0x1f; \ + mtc0 t0,CP0_STATUS; \ + \ + lw v0,FR_STATUS(sp); \ + lw v1,FR_LO(sp); \ + mtc0 v0,CP0_STATUS; \ + mtlo v1; \ + lw v0,FR_HI(sp); \ + lw v1,FR_EPC(sp); \ + mthi v0; \ + mtc0 v1,CP0_EPC; \ + lw $31,FR_REG31(sp); \ + lw $30,FR_REG30(sp); \ + lw $28,FR_REG28(sp); \ + lw $25,FR_REG25(sp); \ + lw $24,FR_REG24(sp); \ + lw $23,FR_REG23(sp); \ + lw $22,FR_REG22(sp); \ + lw $21,FR_REG21(sp); \ + lw $20,FR_REG20(sp); \ + lw $19,FR_REG19(sp); \ + lw $18,FR_REG18(sp); \ + lw $17,FR_REG17(sp); \ + lw $16,FR_REG16(sp); \ + lw $15,FR_REG15(sp); \ + lw $14,FR_REG14(sp); \ + lw $13,FR_REG13(sp); \ + lw $12,FR_REG12(sp); \ + lw $11,FR_REG11(sp); \ + lw $10,FR_REG10(sp); \ + lw $9,FR_REG9(sp); \ + lw $8,FR_REG8(sp); \ + lw $7,FR_REG7(sp); \ + lw $6,FR_REG6(sp); \ + lw $5,FR_REG5(sp); \ + lw $4,FR_REG4(sp); \ + lw $3,FR_REG3(sp); \ + lw $2,FR_REG2(sp); \ + lw $1,FR_REG1(sp); \ lw sp,FR_REG29(sp); /* Deallocate stack */ \ - eret + .set mips0 + +#else /* !defined (__R4000__) */ + +#error "Implement SAVE_ALL and RESTORE_ALL!" + +#endif /* !defined (__R4000__) */ -#endif /* _ASM_MIPS_STACKFRAME_H_ */ +#endif /* __ASM_MIPS_STACKFRAME_H */ diff --git a/include/asm-mips/stat.h b/include/asm-mips/stat.h new file mode 100644 index 000000000..ffae5bbcf --- /dev/null +++ b/include/asm-mips/stat.h @@ -0,0 +1,55 @@ +#ifndef __ASM_MIPS_STAT_H +#define __ASM_MIPS_STAT_H + +#include <asm/types.h> + +struct old_stat { + unsigned int st_dev; + unsigned int st_ino; + unsigned int st_mode; + unsigned int st_nlink; + unsigned int st_uid; + unsigned int st_gid; + unsigned int st_rdev; + long st_size; + unsigned int st_atime, st_res1; + unsigned int st_mtime, st_res2; + unsigned int st_ctime, st_res3; + unsigned int st_blkize; + int st_blocks; + unsigned int st_flags; + unsigned int st_gen; +}; + +struct new_stat { + dev_t st_dev; + long st_pad1[3]; /* Reserved for network id */ + ino_t st_ino; + mode_t st_mode; + nlink_t st_nlink; + uid_t st_uid; + gid_t st_gid; + dev_t st_rdev; + long st_pad2[2]; + off_t st_size; + long st_pad3; + /* + * Actually this should be timestruc_t st_atime, st_mtime and st_ctime + * but we don't have it under Linux. + */ + time_t st_atime; + long reserved0; + time_t st_mtime; + long reserved1; + time_t st_ctime; + long reserved2; + long st_blksize; + long st_blocks; + char st_fstype[16]; /* Filesystem type name */ + long st_pad4[8]; + /* Linux specific fields */ + unsigned int st_flags; + unsigned int st_gen; +}; + +#endif /* __ASM_MIPS_STAT_H */ diff --git a/include/asm-mips/statfs.h b/include/asm-mips/statfs.h new file mode 100644 index 000000000..3cae73206 --- /dev/null +++ b/include/asm-mips/statfs.h @@ -0,0 +1,25 @@ +#ifndef __ASM_MIPS_STATFS_H +#define __ASM_MIPS_STATFS_H + +typedef struct { + long val[2]; +} fsid_t; + +struct statfs { + long f_type; +#define f_fstyp f_type + long f_bsize; + long f_frsize; /* Fragment size - unsupported */ + long f_blocks; + long f_bfree; + long f_files; + long f_ffree; + + /* Linux specials */ + long f_bavail; + fsid_t f_fsid; + long f_namelen; + long f_spare[6]; +}; + +#endif /* __ASM_MIPS_STATFS_H */ diff --git a/include/asm-mips/string.h b/include/asm-mips/string.h index 0116fd026..1142eaf30 100644 --- a/include/asm-mips/string.h +++ b/include/asm-mips/string.h @@ -5,17 +5,13 @@ * License. See the file "COPYING" in the main directory of this archive * for more details. * - * Copyright (c) 1994 by Ralf Baechle + * Copyright (c) 1994, 1995 Waldorf Electronics + * written by Ralf Baechle */ +#ifndef __ASM_MIPS_STRING_H +#define __ASM_MIPS_STRING_H -#ifndef _ASM_MIPS_STRING_H_ -#define _ASM_MIPS_STRING_H_ - -#include <asm/mipsregs.h> - -#define __USE_PORTABLE_STRINGS_H_ - -extern inline char * strcpy(char * dest,const char *src) +extern __inline__ char * strcpy(char * dest, const char *src) { char *xdest = dest; @@ -23,20 +19,20 @@ extern inline char * strcpy(char * dest,const char *src) ".set\tnoreorder\n\t" ".set\tnoat\n" "1:\tlbu\t$1,(%1)\n\t" - "addiu\t%1,%1,1\n\t" + "addiu\t%1,1\n\t" "sb\t$1,(%0)\n\t" - "bne\t$0,$1,1b\n\t" - "addiu\t%0,%0,1\n\t" + "bnez\t$1,1b\n\t" + "addiu\t%0,1\n\t" ".set\tat\n\t" ".set\treorder" - : "=d" (dest), "=d" (src) + : "=r" (dest), "=r" (src) : "0" (dest), "1" (src) : "$1","memory"); return xdest; } -extern inline char * strncpy(char *dest, const char *src, size_t n) +extern __inline__ char * strncpy(char *dest, const char *src, size_t n) { char *xdest = dest; @@ -47,26 +43,23 @@ extern inline char * strncpy(char *dest, const char *src, size_t n) ".set\tnoreorder\n\t" ".set\tnoat\n" "1:\tlbu\t$1,(%1)\n\t" - "addiu\t%2,%2,-1\n\t" + "subu\t%2,%2,1\n\t" "sb\t$1,(%0)\n\t" - "beq\t$0,$1,2f\n\t" + "beqz\t$1,2f\n\t" "addiu\t%0,%0,1\n\t" - "bne\t$0,%2,1b\n\t" + "bnez\t%2,1b\n\t" "addiu\t%1,%1,1\n" "2:\n\t" ".set\tat\n\t" ".set\treorder\n\t" - : "=d" (dest), "=d" (src), "=d" (n) + : "=r" (dest), "=r" (src), "=r" (n) : "0" (dest), "1" (src), "2" (n) : "$1","memory"); return dest; } -#define __USE_PORTABLE_strcat -#define __USE_PORTABLE_strncat - -extern inline int strcmp(const char * cs,const char * ct) +extern __inline__ int strcmp(const char * cs, const char * ct) { int __res; @@ -75,16 +68,18 @@ extern inline int strcmp(const char * cs,const char * ct) ".set\tnoat\n\t" "lbu\t%2,(%0)\n" "1:\tlbu\t$1,(%1)\n\t" - "addiu\t%0,%0,1\n\t" + "addiu\t%0,1\n\t" "bne\t$1,%2,2f\n\t" - "addiu\t%1,%1,1\n\t" - "bne\t$0,%2,1b\n\t" + "addiu\t%1,1\n\t" + "bnez\t%2,1b\n\t" "lbu\t%2,(%0)\n\t" - STR(FILL_LDS) "\n\t" +#ifndef __R4000__ + "nop\n\t" +#endif "move\t%2,$1\n" - "2:\tsub\t%2,%2,$1\n" + "2:\tsubu\t%2,$1\n" "3:\t.set\tat\n\t" - ".set\treorder\n\t" + ".set\treorder" : "=d" (cs), "=d" (ct), "=d" (__res) : "0" (cs), "1" (ct) : "$1"); @@ -92,7 +87,7 @@ extern inline int strcmp(const char * cs,const char * ct) return __res; } -extern inline int strncmp(const char * cs,const char * ct,size_t count) +extern __inline__ int strncmp(const char * cs, const char * ct, size_t count) { char __res; @@ -100,15 +95,15 @@ extern inline int strncmp(const char * cs,const char * ct,size_t count) ".set\tnoreorder\n\t" ".set\tnoat\n" "1:\tlbu\t%3,(%0)\n\t" - "beq\t$0,%2,2f\n\t" + "beqz\t%2,2f\n\t" "lbu\t$1,(%1)\n\t" - "addiu\t%2,%2,-1\n\t" + "subu\t%2,1\n\t" "bne\t$1,%3,3f\n\t" - "addiu\t%0,%0,1\n\t" - "bne\t$0,%3,1b\n\t" - "addiu\t%1,%1,1\n" + "addiu\t%0,1\n\t" + "bnez\t%3,1b\n\t" + "addiu\t%1,1\n" "2:\tmove\t%3,$1\n" - "3:\tsub\t%3,%3,$1\n\t" + "3:\tsubu\t%3,$1\n\t" ".set\tat\n\t" ".set\treorder" : "=d" (cs), "=d" (ct), "=d" (count), "=d" (__res) @@ -118,13 +113,7 @@ extern inline int strncmp(const char * cs,const char * ct,size_t count) return __res; } -#define __USE_PORTABLE_strchr -#define __USE_PORTABLE_strlen -#define __USE_PORTABLE_strspn -#define __USE_PORTABLE_strpbrk -#define __USE_PORTABLE_strtok - -extern inline void * memset(void * s,char c,size_t count) +extern __inline__ void * memset(void * s, int c, size_t count) { void *xs = s; @@ -133,18 +122,17 @@ extern inline void * memset(void * s,char c,size_t count) __asm__ __volatile__( ".set\tnoreorder\n" "1:\tsb\t%3,(%0)\n\t" - "addiu\t%1,%1,-1\n\t" - "bne\t$0,%1,1b\n\t" - "addiu\t%3,%3,1\n\t" + "bne\t%0,%1,1b\n\t" + "addiu\t%0,%0,1\n\t" ".set\treorder" - : "=d" (s), "=d" (count) - : "0" (s), "d" (c), "1" (count) + : "=r" (s), "=r" (count) + : "0" (s), "r" (c), "1" (s + count - 1) : "memory"); return xs; } -extern inline void * memcpy(void * to, const void * from, size_t n) +extern __inline__ void * memcpy(void * to, const void * from, size_t n) { void *xto = to; @@ -154,20 +142,20 @@ extern inline void * memcpy(void * to, const void * from, size_t n) ".set\tnoreorder\n\t" ".set\tnoat\n" "1:\tlbu\t$1,(%1)\n\t" - "addiu\t%1,%1,1\n\t" + "addiu\t%1,1\n\t" "sb\t$1,(%0)\n\t" - "addiu\t%2,%2,-1\n\t" - "bne\t$0,%2,1b\n\t" - "addiu\t%0,%0,1\n\t" + "subu\t%2,1\n\t" + "bnez\t%2,1b\n\t" + "addiu\t%0,1\n\t" ".set\tat\n\t" ".set\treorder" - : "=d" (to), "=d" (from), "=d" (n) + : "=r" (to), "=r" (from), "=r" (n) : "0" (to), "1" (from), "2" (n) : "$1","memory" ); return xto; } -extern inline void * memmove(void * dest,const void * src, size_t n) +extern __inline__ void * memmove(void * dest,const void * src, size_t n) { void *xdest = dest; @@ -179,14 +167,14 @@ extern inline void * memmove(void * dest,const void * src, size_t n) ".set\tnoreorder\n\t" ".set\tnoat\n" "1:\tlbu\t$1,(%1)\n\t" - "addiu\t%1,%1,1\n\t" + "addiu\t%1,1\n\t" "sb\t$1,(%0)\n\t" - "addiu\t%2,%2,-1\n\t" - "bne\t$0,%2,1b\n\t" - "addiu\t%0,%0,1\n\t" + "subu\t%2,1\n\t" + "bnez\t%2,1b\n\t" + "addiu\t%0,1\n\t" ".set\tat\n\t" ".set\treorder" - : "=d" (dest), "=d" (src), "=d" (n) + : "=r" (dest), "=r" (src), "=r" (n) : "0" (dest), "1" (src), "2" (n) : "$1","memory" ); else @@ -194,39 +182,38 @@ extern inline void * memmove(void * dest,const void * src, size_t n) ".set\tnoreorder\n\t" ".set\tnoat\n" "1:\tlbu\t$1,-1(%1)\n\t" - "addiu\t%1,%1,-1\n\t" + "subu\t%1,1\n\t" "sb\t$1,-1(%0)\n\t" - "addiu\t%2,%2,-1\n\t" - "bne\t$0,%2,1b\n\t" - "addiu\t%0,%0,-1\n\t" + "subu\t%2,1\n\t" + "bnez\t%2,1b\n\t" + "subu\t%0,1\n\t" ".set\tat\n\t" ".set\treorder" - : "=d" (dest), "=d" (src), "=d" (n) + : "=r" (dest), "=r" (src), "=r" (n) : "0" (dest+n), "1" (src+n), "2" (n) : "$1","memory" ); return xdest; } -#define __USE_PORTABLE_memcmp - -static inline char * memscan(void * addr, unsigned char c, int size) +extern __inline__ void * memscan(void * addr, int c, size_t size) { if (!size) return addr; __asm__(".set\tnoreorder\n\t" ".set\tnoat\n" - "1:\tbeq\t$0,%1,2f\n\t" + "1:\tbeqz\t%1,2f\n\t" "lbu\t$1,(%0)\n\t" - "subu\t%1,%1,1\n\t" - "bne\t$0,%1,1b\n\t" - "addiu\t%0,%0,1\n\t" + "subu\t%1,1\n\t" + "bnez\t%1,1b\n\t" + "addiu\t%0,1\n\t" ".set\tat\n\t" ".set\treorder\n" "2:" - : "=d" (addr), "=d" (size) - : "0" (addr), "1" (size), "d" (c) + : "=r" (addr), "=r" (size) + : "0" (addr), "1" (size), "r" (c) : "$1"); return addr; } -#endif /* _ASM_MIPS_STRING_H_ */ + +#endif /* __ASM_MIPS_STRING_H */ diff --git a/include/asm-mips/system.h b/include/asm-mips/system.h index 3a3029b31..ef8c51b21 100644 --- a/include/asm-mips/system.h +++ b/include/asm-mips/system.h @@ -5,85 +5,191 @@ * License. See the file "COPYING" in the main directory of this archive * for more details. * - * Copyright (C) 1994 by Ralf Baechle + * Copyright (C) 1994, 1995 by Ralf Baechle */ +#ifndef __ASM_MIPS_SYSTEM_H +#define __ASM_MIPS_SYSTEM_H -#ifndef _ASM_MIPS_SYSTEM_H_ -#define _ASM_MIPS_SYSTEM_H_ +#if defined (__R4000__) +#define sti() \ +__asm__ __volatile__( \ + ".set\tnoreorder\n\t" \ + ".set\tnoat\n\t" \ + "mfc0\t$1,$12\n\t" \ + "ori\t$1,0x1f\n\t" \ + "xori\t$1,0x1e\n\t" \ + "mtc0\t$1,$12\n\t" \ + ".set\tat\n\t" \ + ".set\treorder" \ + : /* no outputs */ \ + : /* no inputs */ \ + : "$1") -#include <linux/types.h> -#include <asm/segment.h> -#include <asm/mipsregs.h> +#define cli() \ +__asm__ __volatile__( \ + ".set\tnoreorder\n\t" \ + ".set\tnoat\n\t" \ + "mfc0\t$1,$12\n\t" \ + "ori\t$1,1\n\t" \ + "xori\t$1,1\n\t" \ + "mtc0\t$1,$12\n\t" \ + "nop\n\t" \ + "nop\n\t" \ + "nop\n\t" \ + ".set\tat\n\t" \ + ".set\treorder" \ + : /* no outputs */ \ + : /* no inputs */ \ + : "$1") +#else /* !defined (__R4000__) */ /* - * move_to_user_mode() doesn't switch to user mode on the mips, since - * that would run us into problems: The kernel is located at virtual - * address 0x80000000. If we now would switch over to user mode, we - * we would immediately get an address error exception. - * Anyway - we don't have problems with a task running in kernel mode, - * as long it's code is foolproof. + * Untested goodies for the R3000 based DECstation et al. */ -#define move_to_user_mode() - -#define sti() \ +#define sti() \ __asm__ __volatile__( \ + ".set\tnoreorder\n\t" \ ".set\tnoat\n\t" \ - "mfc0\t$1,"STR(CP0_STATUS)"\n\t" \ - "ori\t$1,$1,0x1f\n\t" \ - "xori\t$1,$1,0x1e\n\t" \ - "mtc0\t$1,"STR(CP0_STATUS)"\n\t" \ - ".set\tat" \ + "mfc0\t$1,$12\n\t" \ + "ori\t$1,0x01\n\t" \ + "mtc0\t$1,$12\n\t" \ + ".set\tat\n\t" \ + ".set\treorder" \ : /* no outputs */ \ : /* no inputs */ \ : "$1") -#define cli() \ +#define cli() \ __asm__ __volatile__( \ + ".set\tnoreorder\n\t" \ ".set\tnoat\n\t" \ - "mfc0\t$1,"STR(CP0_STATUS)"\n\t" \ - "ori\t$1,$1,1\n\t" \ - "xori\t$1,$1,1\n\t" \ - "mtc0\t$1,"STR(CP0_STATUS)"\n\t" \ - ".set\tat" \ + "mfc0\t$1,$12\n\t" \ + "ori\t$1,1\n\t" \ + "xori\t$1,1\n\t" \ + "mtc0\t$1,$12\n\t" \ + ".set\tat\n\t" \ + ".set\treorder" \ : /* no outputs */ \ : /* no inputs */ \ : "$1") +#endif /* !defined (__R4000__) */ #define nop() __asm__ __volatile__ ("nop") -extern ulong IRQ_vectors[256]; -extern ulong exception_handlers[256]; - -#define set_intr_gate(n,addr) \ - IRQ_vectors[n] = (ulong) (addr) - -#define set_except_vector(n,addr) \ - exception_handlers[n] = (ulong) (addr) - -/* - * atomic exchange of one word - * - * Fixme: This works only on MIPS ISA >=3 - */ -#define atomic_exchange(m,r) \ - __asm__ __volatile__( \ - "1:\tll\t$8,(%2)\n\t" \ - "move\t$9,%0\n\t" \ - "sc\t$9,(%2)\n\t" \ - "beq\t$0,$9,1b\n\t" \ - : "=r" (r) \ - : "0" (r), "r" (&(m)) \ - : "$8","$9","memory"); - #define save_flags(x) \ __asm__ __volatile__( \ + ".set\tnoreorder\n\t" \ "mfc0\t%0,$12\n\t" \ + ".set\treorder" \ : "=r" (x)) \ #define restore_flags(x) \ __asm__ __volatile__( \ + ".set\tnoreorder\n\t" \ "mtc0\t%0,$12\n\t" \ + ".set\treorder" \ : /* no output */ \ - : "r" (x)); \ + : "r" (x)) \ + +#define sync_mem() \ +__asm__ __volatile__( \ + ".set\tnoreorder\n\t" \ + "sync\n\t" \ + ".set\treorder") \ + +/* + * The 8 and 16 bit variants have to disable interrupts temporarily. + * Both are currently unused. + */ +extern inline unsigned long xchg_u8(char * m, unsigned long val) +{ + unsigned long flags, retval; + + save_flags(flags); + sti(); + retval = *m; + *m = val; + restore_flags(flags); + + return retval; +} + +extern inline unsigned long xchg_u16(short * m, unsigned long val) +{ + unsigned long flags, retval; + + save_flags(flags); + sti(); + retval = *m; + *m = val; + restore_flags(flags); + + return retval; +} + +/* + * For 32 and 64 bit operands we can take advantage of ll and sc. + * FIXME: This doesn't work for R3000 machines. + */ +extern inline unsigned long xchg_u32(int * m, unsigned long val) +{ + unsigned long dummy; + + __asm__ __volatile__( + ".set\tnoreorder\n\t" + ".set\tnoat\n\t" + "ll\t%0,(%1)\n" + "1:\tmove\t$1,%2\n\t" + "sc\t$1,(%1)\n\t" + "beqzl\t$1,1b\n\t" + "ll\t%0,(%1)\n\t" + ".set\tat\n\t" + ".set\treorder" + : "=r" (val), "=r" (m), "=r" (dummy) + : "1" (m), "2" (val)); + + return val; +} + +/* + * Only used for 64 bit kernel. + */ +extern inline unsigned long xchg_u64(long * m, unsigned long val) +{ + unsigned long dummy; + + __asm__ __volatile__( + ".set\tnoreorder\n\t" + ".set\tnoat\n\t" + "lld\t%0,(%1)\n" + "1:\tmove\t$1,%2\n\t" + "scd\t$1,(%1)\n\t" + "beqzl\t$1,1b\n\t" + "ll\t%0,(%1)\n\t" + ".set\tat\n\t" + ".set\treorder" + : "=r" (val), "=r" (m), "=r" (dummy) + : "1" (m), "2" (val)); + + return val; +} + +extern inline void * xchg_ptr(void * m, void * val) +{ +#if __mips == 3 + return (void *) xchg_u64(m, (unsigned long) val); +#else + return (void *) xchg_u32(m, (unsigned long) val); +#endif +} + +extern unsigned long IRQ_vectors[16]; +extern unsigned long exception_handlers[32]; + +#define set_int_vector(n,addr) \ + IRQ_vectors[n] = (unsigned long) (addr) + +#define set_except_vector(n,addr) \ + exception_handlers[n] = (unsigned long) (addr) -#endif /* _ASM_MIPS_SYSTEM_H_ */ +#endif /* __ASM_MIPS_SYSTEM_H */ diff --git a/include/asm-mips/types.h b/include/asm-mips/types.h index 236996dd5..da0310a02 100644 --- a/include/asm-mips/types.h +++ b/include/asm-mips/types.h @@ -1,25 +1,111 @@ -#ifndef _ASM_MIPS_TYPES_H -#define _ASM_MIPS_TYPES_H +/* + * include/asm-mips/types.h + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file "COPYING" in the main directory of this archive + * for more details. + * + * Copyright (C) 1994, 1995 by Waldorf GMBH + * written by Ralf Baechle + */ +#ifndef __ASM_MIPS_TYPES_H +#define __ASM_MIPS_TYPES_H + +#ifndef _SIZE_T +#define _SIZE_T +typedef __SIZE_TYPE__ size_t; +#endif + +#ifndef _SSIZE_T +#define _SSIZE_T +typedef __SSIZE_TYPE__ ssize_t; +#endif + +#ifndef _PTRDIFF_T +#define _PTRDIFF_T +typedef __PTRDIFF_TYPE__ ptrdiff_t; +#endif + +#ifndef _TIME_T +#define _TIME_T +typedef long time_t; +#endif + +#ifndef _CLOCK_T +#define _CLOCK_T +typedef long clock_t; +#endif + +/* + * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the + * header files exported to user space + */ + +typedef __signed__ char __s8; +typedef unsigned char __u8; + +typedef __signed__ short __s16; +typedef unsigned short __u16; + +typedef __signed__ int __s32; +typedef unsigned int __u32; + +#if ((~0UL) == 0xffffffff) + +#if defined(__GNUC__) && !defined(__STRICT_ANSI__) +typedef __signed__ long long __s64; +typedef unsigned long long __u64; +#endif + +#else + +typedef __signed__ long __s64; +typedef unsigned long __u64; + +#endif /* * These aren't exported outside the kernel to avoid name space clashes */ #ifdef __KERNEL__ -typedef signed char s8; +typedef __signed char s8; typedef unsigned char u8; -typedef signed short s16; +typedef __signed short s16; typedef unsigned short u16; -typedef signed long s32; -typedef unsigned long u32; +typedef __signed int s32; +typedef unsigned int u32; + +#if ((~0UL) == 0xffffffff) -typedef signed long long s64; +#if defined(__GNUC__) && !defined(__STRICT_ANSI__) +typedef __signed__ long long s64; typedef unsigned long long u64; +#endif + +#else + +typedef __signed__ long s64; +typedef unsigned long u64; + +#endif #endif /* __KERNEL__ */ +typedef __s32 pid_t; +typedef __s32 uid_t; +typedef __s32 gid_t; +typedef __u32 dev_t; +typedef __u32 ino_t; +typedef __u32 mode_t; +typedef __u32 umode_t; +typedef __u32 nlink_t; +typedef long daddr_t; +typedef long off_t; + +#if 0 /* * These definitions double the definitions from <gnu/types.h>. */ @@ -35,5 +121,6 @@ typedef unsigned long long u64; #define __FD_ISSET(d, set) ((set)->fds_bits[__FDELT(d)] & __FDMASK(d)) #undef __FD_ZERO #define __FD_ZERO(fdsetp) (memset (fdsetp, 0, sizeof(*(fd_set *)fdsetp))) +#endif -#endif /* _ASM_MIPS_TYPES_H */ +#endif /* __ASM_MIPS_TYPES_H */ diff --git a/include/asm-mips/unistd.h b/include/asm-mips/unistd.h index 0776f3fdb..94878e595 100644 --- a/include/asm-mips/unistd.h +++ b/include/asm-mips/unistd.h @@ -1,18 +1,14 @@ -#ifndef _ASM_MIPS_UNISTD_H_ -#define _ASM_MIPS_UNISTD_H_ +#ifndef __ASM_MIPS_UNISTD_H +#define __ASM_MIPS_UNISTD_H /* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */ #define _syscall0(type,name) \ type name(void) \ { \ register long __res __asm__ ("$2"); \ -__asm__ volatile (".set\tnoat\n\t" \ - "li\t$1,%1\n\t" \ - ".set\tat\n\t" \ - "syscall\n\t" \ - : "=d" (__res) \ - : "i" (__NR_##name) \ - : "$1"); \ +__asm__ volatile ("syscall" \ + : "=r" (__res) \ + : "0" (__NR_##name)); \ if (__res >= 0) \ return (type) __res; \ errno = -__res; \ @@ -23,14 +19,11 @@ return -1; \ type name(atype a) \ { \ register long __res __asm__ ("$2"); \ -__asm__ volatile ("move\t$2,%2\n\t" \ - ".set\tnoat\n\t" \ - "li\t$1,%1\n\t" \ - ".set\tat\n\t" \ +__asm__ volatile ("move\t$4,%2\n\t" \ "syscall" \ - : "=d" (__res) \ - : "i" (__NR_##name),"d" ((long)(a)) \ - : "$1","$2"); \ + : "=r" (__res) \ + : "0" (__NR_##name),"r" ((long)(a)) \ + : "$4"); \ if (__res >= 0) \ return (type) __res; \ errno = -__res; \ @@ -41,16 +34,13 @@ return -1; \ type name(atype a,btype b) \ { \ register long __res __asm__ ("$2"); \ -__asm__ volatile ("move\t$2,%2\n\t" \ - "move\t$3,%3\n\t" \ - ".set\tnoat\n\t" \ - "li\t$1,%1\n\t" \ - ".set\tat\n\t" \ +__asm__ volatile ("move\t$4,%2\n\t" \ + "move\t$5,%3\n\t" \ "syscall" \ - : "=d" (__res) \ - : "i" (__NR_##name),"d" ((long)(a)), \ - "d" ((long)(b))); \ - : "$1","$2","$3"); \ + : "=r" (__res) \ + : "0" (__NR_##name),"r" ((long)(a)), \ + "r" ((long)(b))); \ + : "$4","$5"); \ if (__res >= 0) \ return (type) __res; \ errno = -__res; \ @@ -61,18 +51,15 @@ return -1; \ type name (atype a, btype b, ctype c) \ { \ register long __res __asm__ ("$2"); \ -__asm__ volatile ("move\t$2,%2\n\t" \ - "move\t$3,%3\n\t" \ - "move\t$4,%4\n\t" \ - ".set\tnoat\n\t" \ - "li\t$1,%1\n\t" \ - ".set\tat\n\t" \ +__asm__ volatile ("move\t$4,%2\n\t" \ + "move\t$5,%3\n\t" \ + "move\t$6,%4\n\t" \ "syscall" \ - : "=d" (__res) \ - : "i" (__NR_##name),"d" ((long)(a)), \ - "d" ((long)(b)), \ - "d" ((long)(c)) \ - : "$1","$2","$3","$4"); \ + : "=r" (__res) \ + : "0" (__NR_##name),"r" ((long)(a)), \ + "r" ((long)(b)), \ + "r" ((long)(c)) \ + : "$4","$5","$6"); \ if (__res>=0) \ return (type) __res; \ errno=-__res; \ @@ -83,21 +70,17 @@ return -1; \ type name (atype a, btype b, ctype c, dtype d) \ { \ register long __res __asm__ ("$2"); \ -__asm__ volatile (".set\tnoat\n\t" \ - "move\t$2,%2\n\t" \ - "move\t$3,%3\n\t" \ - "move\t$4,%4\n\t" \ - "move\t$5,%5\n\t" \ - ".set\tnoat\n\t" \ - "li\t$1,%1\n\t" \ - ".set\tat\n\t" \ +__asm__ volatile ("move\t$4,%2\n\t" \ + "move\t$5,%3\n\t" \ + "move\t$6,%4\n\t" \ + "move\t$7,%5\n\t" \ "syscall" \ - : "=d" (__res) \ - : "i" (__NR_##name),"d" ((long)(a)), \ - "d" ((long)(b)), \ - "d" ((long)(c)), \ - "d" ((long)(d)) \ - : "$1","$2","$3","$4","$5"); \ + : "=r" (__res) \ + : "0" (__NR_##name),"r" ((long)(a)), \ + "r" ((long)(b)), \ + "r" ((long)(c)), \ + "r" ((long)(d)) \ + : "$4","$5","$6","$7"); \ if (__res>=0) \ return (type) __res; \ errno=-__res; \ @@ -108,27 +91,59 @@ return -1; \ type name (atype a,btype b,ctype c,dtype d,etype e) \ { \ register long __res __asm__ ("$2"); \ -__asm__ volatile (".set\tnoat\n\t" \ - "move\t$2,%2\n\t" \ - "move\t$3,%3\n\t" \ - "move\t$4,%4\n\t" \ - "move\t$5,%5\n\t" \ - "move\t$6,%6\n\t" \ - ".set\tnoat\n\t" \ - "li\t$1,%1\n\t" \ - ".set\tat\n\t" \ +__asm__ volatile ("move\t$4,%2\n\t" \ + "move\t$5,%3\n\t" \ + "move\t$6,%4\n\t" \ + "move\t$7,%5\n\t" \ + "move\t$3,%6\n\t" \ "syscall" \ - : "=d" (__res) \ - : "i" (__NR_##name),"d" ((long)(a)), \ - "d" ((long)(b)), \ - "d" ((long)(c)), \ - "d" ((long)(d)), \ - "d" ((long)(e)) \ - : "$1","$2","$3","$4","$5","$6"); \ + : "=r" (__res) \ + : "0" (__NR_##name),"r" ((long)(a)), \ + "r" ((long)(b)), \ + "r" ((long)(c)), \ + "r" ((long)(d)), \ + "r" ((long)(e)) \ + : "$3","$4","$5","$6","$7"); \ if (__res>=0) \ return (type) __res; \ errno=-__res; \ return -1; \ } -#endif /* _ASM_MIPS_UNISTD_H_ */ +#ifdef __KERNEL_SYSCALLS__ + +/* + * we need this inline - forking from kernel space will result + * in NO COPY ON WRITE (!!!), until an execve is executed. This + * is no problem, but for the stack. This is handled by not letting + * main() use the stack at all after fork(). Thus, no function + * calls - which means inline code for fork too, as otherwise we + * would use the stack upon exit from 'fork()'. + * + * Actually only pause and fork are needed inline, so that there + * won't be any messing with the stack from main(), but we define + * some others too. + */ +#define __NR__exit __NR_exit +static inline _syscall0(int,idle) +static inline _syscall0(int,fork) +static inline _syscall0(int,pause) +static inline _syscall0(int,setup) +static inline _syscall0(int,sync) +static inline _syscall0(pid_t,setsid) +static inline _syscall3(int,write,int,fd,const char *,buf,off_t,count) +static inline _syscall1(int,dup,int,fd) +static inline _syscall3(int,execve,const char *,file,char **,argv,char **,envp) +static inline _syscall3(int,open,const char *,file,int,flag,int,mode) +static inline _syscall1(int,close,int,fd) +static inline _syscall1(int,_exit,int,exitcode) +static inline _syscall3(pid_t,waitpid,pid_t,pid,int *,wait_stat,int,options) + +static inline pid_t wait(int * wait_stat) +{ + return waitpid(-1,wait_stat,0); +} + +#endif + +#endif /* __ASM_MIPS_UNISTD_H */ diff --git a/include/asm-mips/vector.h b/include/asm-mips/vector.h new file mode 100644 index 000000000..bc0d85e3b --- /dev/null +++ b/include/asm-mips/vector.h @@ -0,0 +1,32 @@ +/* + * include/asm-mips/vector.h + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file "COPYING" in the main directory of this archive + * for more details. + * + * Copyright (C) 1995 by Ralf Baechle + */ + +/* + * This structure defines how to access various features of + * different machine types and how to access them. + * + * FIXME: More things need to be accessed via this vector. + */ +struct feature { + void (*handle_int)(void); +}; + +/* + * Similar to the above this is a structure that describes various + * CPU dependend features. + * + * FIXME: This vector isn't being used yet + */ +struct cpu { + int dummy; /* keep GCC from complaining */ +}; + +extern struct feature *feature; +extern struct cpu *cpu; diff --git a/include/asm-sparc/asi.h b/include/asm-sparc/asi.h new file mode 100644 index 000000000..4a404573d --- /dev/null +++ b/include/asm-sparc/asi.h @@ -0,0 +1,43 @@ +#ifndef _SPARC_ASI_H +#define _SPARC_ASI_H + +/* asi.h: Address Space Identifier values for the sparc. + + Copyright (C) 1994 David S. Miller (davem@caip.rutgers.edu) +*/ + +/* These are sun4c, beware on other architectures. Although things should + * be similar under regular sun4's. + */ + +#include <linux/config.h> +#ifdef CONFIG_SUN4M +#include "asi4m.h" +#else + +#define ASI_NULL1 0x0 +#define ASI_NULL2 0x1 + +/* sun4c and sun4 control registers and mmu/vac ops */ +#define ASI_CONTROL 0x2 +#define ASI_SEGMAP 0x3 +#define ASI_PTE 0x4 +#define ASI_HWFLUSHSEG 0x5 /* These are to initiate hw flushes of the cache */ +#define ASI_HWFLUSHPAGE 0x6 +#define ASI_HWFLUSHCONTEXT 0x7 + + +#define ASI_USERTXT 0x8 +#define ASI_KERNELTXT 0x9 +#define ASI_USERDATA 0xa +#define ASI_KERNELDATA 0xb + +/* VAC Cache flushing on sun4c and sun4 */ + +#define ASI_FLUSHSEG 0xc /* These are for "software" flushes of the cache */ +#define ASI_FLUSHPG 0xd +#define ASI_FLUSHCTX 0xe + + +#endif /* CONFIG_SUN4M */ +#endif /* _SPARC_ASI_H */ diff --git a/include/asm-sparc/asi4m.h b/include/asm-sparc/asi4m.h new file mode 100644 index 000000000..68b1d21e7 --- /dev/null +++ b/include/asm-sparc/asi4m.h @@ -0,0 +1,29 @@ +#ifndef _SPARC_ASI4M_H +#define _SPARC_ASI4M_H + +/* asi4m.h: Address Space Identifier values for sun4m + + Copyright (C) 1995 Paul Hatchman (paul@sfe.com.au) +*/ + +#define ASI_PTE 0x0 + +#define ASI_NULL1 0x0 +#define ASI_NULL2 0x1 +#define ASI_CONTROL 0x4 /* hmm? */ +#define ASI_USERTXT 0x8 /* user text */ +#define ASI_KERNELTXT 0x9 /* kernel text */ +#define ASI_USERDATA 0xA /* user data */ +#define ASI_KERNELDATA 0xB /* kernel data */ + +/* cache flushing */ +#define ASI_FLUSHPG 0x10 +#define ASI_FLUSHSEG 0x11 +#define ASI_FLUSHRGN 0x12 +#define ASI_FLUSHCTX 0x13 + +/* MMU REGS */ +#define SRMMU_CTL 0x000 +#define SRMMU_CTP 0x100 /* set/get context pointer */ +#define SRMMU_CTX 0x200 /* get/set context */ +#endif _SPARC_ASI4M_H diff --git a/include/asm-sparc/bitops.h b/include/asm-sparc/bitops.h new file mode 100644 index 000000000..241e5e8c1 --- /dev/null +++ b/include/asm-sparc/bitops.h @@ -0,0 +1,173 @@ +#ifndef _SPARC_BITOPS_H +#define _SPARC_BITOPS_H + +/* + * Copyright 1994, David S. Miller (davem@caip.rutgers.edu). + */ + + +/* Set bit 'nr' in 32-bit quantity at address 'addr' where bit '0' + * is in the highest of the four bytes and bit '31' is the high bit + * within the first byte. Sparc is BIG-Endian. Unless noted otherwise + * all bit-ops return 0 if bit was previously clear and != 0 otherwise. + */ + +/* For now, the sun4c implementation will disable and enable traps + * in order to insure atomicity. Things will have to be different + * for sun4m (ie. SMP) no doubt. + */ + +extern __inline__ unsigned int set_bit(unsigned int nr, void *addr) +{ + register unsigned long retval, tmp, mask, psr; + + __asm__ __volatile__("or %%g0, 0x1, %3\n\t" /* produce the mask */ + "sll %3, %4, %3\n\t" + "rd %%psr, %5\n\t" /* read the psr */ + "wr %5, 0x20, %%psr\n\t" /* traps disabled */ + "ld [%1], %2\n\t" /* critical section */ + "and %3, %2, %0\n\t" + "or %3, %2, %2\n\t" + "st %2, [%1]\n\t" + "wr %5, 0x0, %%psr\n\t" : /* re-enable traps */ + "=r" (retval) : + "r" (addr), "r" (tmp=0), "r" (mask=0), + "r" (nr), "r" (psr=0)); + + return retval; /* confuse gcc :-) */ + +} + +extern __inline__ unsigned int clear_bit(unsigned int nr, void *addr) +{ + register unsigned long retval, tmp, mask, psr; + + __asm__ __volatile__("or %%g0, 0x1, %3\n\t" + "sll %3, %4, %3\n\t" + "rd %%psr, %5\n\t" + "wr %5, 0x20, %%psr\n\t" /* disable traps */ + "ld [%1], %2\n\t" + "and %2, %3, %0\n\t" /* get old bit */ + "andn %2, %3, %2\n\t" /* set new val */ + "st %2, [%1]\n\t" + "wr %5, 0x0, %%psr\n\t" : /* enable traps */ + "=r" (retval) : + "r" (addr), "r" (tmp=0), "r" (mask=0), + "r" (nr), "r" (psr=0)); + + return retval; /* confuse gcc ;-) */ + +} + +extern __inline__ unsigned int change_bit(unsigned int nr, void *addr) +{ + register unsigned long retval, tmp, mask, psr; + + __asm__ __volatile__("or %%g0, 0x1, %3\n\t" + "sll %3, %4, %3\n\t" + "rd %%psr, %5\n\t" + "wr %5, 0x20, %%psr\n\t" /* disable traps */ + "ld [%1], %2\n\t" + "and %3, %2, %0\n\t" /* get old bit val */ + "xor %3, %2, %2\n\t" /* set new val */ + "st %2, [%1]\n\t" + "wr %5, 0x0, %%psr\n\t" : /* enable traps */ + "=r" (retval) : + "r" (addr), "r" (tmp=0), "r" (mask=0), + "r" (nr), "r" (psr=0)); + + return retval; /* confuse gcc ;-) */ + +} + +/* The following routine need not be atomic. */ + +extern __inline__ unsigned int test_bit(int nr, void *addr) +{ + register unsigned long retval, tmp; + + __asm__ __volatile__("ld [%1], %2\n\t" + "or %%g0, 0x1, %0\n\t" + "sll %0, %3, %0\n\t" + "and %0, %2, %0\n\t" : + "=r" (retval) : + "r" (addr), "r" (tmp=0), + "r" (nr)); + + return retval; /* confuse gcc :> */ + +} + +/* There has to be a faster way to do this, sigh... */ + +extern __inline__ unsigned long ffz(unsigned long word) +{ + register unsigned long cnt, tmp, tmp2; + + cnt = 0; + + __asm__("or %%g0, %3, %2\n\t" + "1: and %2, 0x1, %1\n\t" + "srl %2, 0x1, %2\n\t" + "cmp %1, 0\n\t" + "bne,a 1b\n\t" + "add %0, 0x1, %0\n\t" : + "=r" (cnt) : + "r" (tmp=0), "r" (tmp2=0), "r" (word)); + + return cnt; +} + +/* find_next_zero_bit() finds the first zero bit in a bit string of length + * 'size' bits, starting the search at bit 'offset'. This is largely based + * on Linus's ALPHA routines, which are pretty portable BTW. + */ + +extern __inline__ unsigned long find_next_zero_bit(void *addr, unsigned long size, unsigned long offset) +{ + unsigned long *p = ((unsigned long *) addr) + (offset >> 6); + unsigned long result = offset & ~31UL; + unsigned long tmp; + + if (offset >= size) + return size; + size -= result; + offset &= 31UL; + if (offset) + { + tmp = *(p++); + tmp |= ~0UL >> (32-offset); + if (size < 32) + goto found_first; + if (~tmp) + goto found_middle; + size -= 32; + result += 32; + } + while (size & ~32UL) + { + if (~(tmp = *(p++))) + goto found_middle; + result += 32; + size -= 32; + } + if (!size) + return result; + tmp = *p; + +found_first: + tmp |= ~0UL << size; +found_middle: + return result + ffz(tmp); +} + +/* Linus sez that gcc can optimize the following correctly, we'll see if this + * holds on the Sparc as it does for the ALPHA. + */ + +#define find_first_zero_bit(addr, size) \ + find_next_zero_bit((addr), (size), 0) + + +#endif /* defined(_SPARC_BITOPS_H) */ + diff --git a/include/asm-sparc/bugs.h b/include/asm-sparc/bugs.h new file mode 100644 index 000000000..55f5434ad --- /dev/null +++ b/include/asm-sparc/bugs.h @@ -0,0 +1,48 @@ +/* include/asm-sparc/bugs.h: Sparc probes for various bugs. + * + * Copyright (C) 1994 David S. Miller (davem@caip.rutgers.edu) + */ + +/* + * This is included by init/main.c to check for architecture-dependent bugs. + * + * Needs: + * void check_bugs(void); + */ + +#define CONFIG_BUGSPARC + +#include <asm/openprom.h> + +extern struct linux_romvec *romvec; +extern int tbase_needs_unmapping; /* We do the bug workaround in pagetables.c */ + +static void check_mmu(void) +{ + register struct linux_romvec *lvec; + register int root_node; + unsigned int present; + + lvec = romvec; + + root_node = (*(romvec->pv_nodeops->no_nextnode))(0); + tbase_needs_unmapping=0; + + present = 0; + (*(romvec->pv_nodeops->no_getprop))(root_node, "buserr-type", + (char *) &present); + if(present == 1) + { + tbase_needs_unmapping=1; + printk("MMU bug found: not allowing trapbase to be cached\n"); + } + + return; +} + + +static void +check_bugs(void) +{ + check_mmu(); +} diff --git a/include/asm-sparc/byteorder.h b/include/asm-sparc/byteorder.h new file mode 100644 index 000000000..b734cf8a6 --- /dev/null +++ b/include/asm-sparc/byteorder.h @@ -0,0 +1,85 @@ +#ifndef _SPARC_BYTEORDER_H +#define _SPARC_BYTEORDER_H + +#undef ntohl +#undef ntohs +#undef htonl +#undef htons + +#define BIG_ENDIAN +#define BIG_ENDIAN_BITFIELD + +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); + +extern unsigned long int __ntohl(unsigned long int); +extern unsigned short int __ntohs(unsigned short int); +extern unsigned long int __constant_ntohl(unsigned long int); +extern unsigned short int __constant_ntohs(unsigned short int); + +/* + * The constant and non-constant versions here are the same. + * Maybe I'll come up with an alpha-optimized routine for the + * non-constant ones (the constant ones don't need it: gcc + * will optimize it to the correct constant) + */ + +extern __inline__ unsigned long int +__ntohl(unsigned long int x) +{ + return (((x & 0x000000ffU) << 24) | + ((x & 0x0000ff00U) << 8) | + ((x & 0x00ff0000U) >> 8) | + ((x & 0xff000000U) >> 24)); +} + +extern __inline__ unsigned long int +__constant_ntohl(unsigned long int x) +{ + return (((x & 0x000000ffU) << 24) | + ((x & 0x0000ff00U) << 8) | + ((x & 0x00ff0000U) >> 8) | + ((x & 0xff000000U) >> 24)); +} + +extern __inline__ unsigned short int +__ntohs(unsigned short int x) +{ + return (((x & 0x00ff) << 8) | + ((x & 0xff00) >> 8)); +} + +extern __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 /* !(_SPARC_BYTEORDER_H) */ diff --git a/include/asm-sparc/clock.h b/include/asm-sparc/clock.h new file mode 100644 index 000000000..ce5ce6762 --- /dev/null +++ b/include/asm-sparc/clock.h @@ -0,0 +1,53 @@ +/* clock.h: Definitions for the clock/timer chips on the Sparc. + * + * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) + */ + +/* Clock timer structures. The interrupt timer has two properties which + * are the counter (which is handled in do_timer in sched.c) and the limit. + * This limit is where the timer's counter 'wraps' around. Oddly enough, + * the sun4c timer when it hits the limit wraps back to 1 and not zero + * thus when calculating the value at which it will fire a microsecond you + * must adjust by one. Thanks SUN for designing such great hardware ;( + */ + +/* Note that I am only going to use the timer that interrupts at + * Sparc IRQ 10. There is another one available that can fire at + * IRQ 14. If I can think of some creative uses for it this may + * change. It might make a nice kernel/user profiler etc. + */ + +struct sparc_timer_info { + unsigned int cur_count10; + unsigned int timer_limit10; + unsigned int cur_count14; + unsigned int timer_limit14; +}; + +struct sparc_clock_info { + unsigned char hsec; + unsigned char hr; + unsigned char min; + unsigned char sec; + unsigned char mon; + unsigned char day; + unsigned char yr; + unsigned char wkday; + unsigned char ram_hsec; + unsigned char ram_hr; + unsigned char ram_min; + unsigned char ram_sec; + unsigned char ram_mon; + unsigned char ram_day; + unsigned char ram_year; + unsigned char ram_wkday; + unsigned char intr_reg; + unsigned char cmd_reg; + unsigned char foo[14]; +}; + +#define TIMER_PHYSADDR 0xf3000000 + +/* YUCK YUCK YUCK, grrr... */ +#define TIMER_STRUCT ((struct sparc_timer_info *)((struct sparc_clock_info *) TIMER_VADDR)) + diff --git a/include/asm-sparc/contregs.h b/include/asm-sparc/contregs.h new file mode 100644 index 000000000..326e888ff --- /dev/null +++ b/include/asm-sparc/contregs.h @@ -0,0 +1,19 @@ +#ifndef _SPARC_CONTREGS_H +#define _SPARC_CONTREGS_H + +/* contregs.h: Addresses of registers in the ASI_CONTROL alternate address + space. These are for the mmu's context register, etc. + + Copyright (C) 1994 David S. Miller (davem@caip.rutgers.edu) +*/ + +#define AC_CONTEXT 0x30000000 /* current mmu-context, handy for invalidate()'s ;-) */ +#define AC_SENABLE 0x40000000 /* system dvma/cache enable, plus special reset poking */ +#define AC_CACHETAGS 0x80000000 /* direct access to the VAC cache, unused... */ +#define AC_SYNC_ERR 0x60000000 /* what type of synchronous memory error happened */ +#define AC_SYNC_VA 0x60000004 /* what virtual address caused the error to occur */ +#define AC_ASYNC_ERR 0x60000008 /* what type of asynchronous mem-error happened */ +#define AC_ASYNC_VA 0x6000000c /* what virtual address caused the async-err to happen */ +#define AC_CACHEDDATA 0x90000000 /* where the actual VAC cached data sits */ + +#endif /* _SPARC_CONTREGS_H */ diff --git a/include/asm-sparc/cprefix.h b/include/asm-sparc/cprefix.h new file mode 100644 index 000000000..439c7c671 --- /dev/null +++ b/include/asm-sparc/cprefix.h @@ -0,0 +1,20 @@ +/* cprefix.h: This file is included by assembly source which needs + * to know what the c-label prefixes are. The newer versions + * of cpp that come with gcc predefine such things to help + * us out. The reason this stuff is needed is to make + * solaris compiles of the kernel work. + * + * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) + */ + + +#ifndef __svr4__ +#define C_LABEL_PREFIX _ +#else +#define C_LABEL_PREFIX +#endif + +#define CONCAT1(a, b) CONCAT2(a, b) +#define CONCAT2(a, b) a##b + +#define C_LABEL(name) CONCAT1(C_LABEL_PREFIX, name) diff --git a/include/asm-sparc/delay.h b/include/asm-sparc/delay.h new file mode 100644 index 000000000..d6c4b360e --- /dev/null +++ b/include/asm-sparc/delay.h @@ -0,0 +1,40 @@ +#ifndef __SPARC_DELAY_H +#define __SPARC_DELAY_H + +extern unsigned long loops_per_sec; + +/* + * Copyright (C) 1994 David S. Miller (davem@caip.rutgers.edu). + * + * Delay quick inlined code using 'loops_per_second' which is + * calculated in calibrate_delay() in main.c (ie. BogoMIPS :-) + */ + +extern __inline__ void __delay(unsigned int loops) +{ + __asm__ __volatile__("\n1:\tcmp %0, 0\n\t" + "bne,a 1b\n\t" + "sub %0, 1, %0\n": "=&r" (loops) : "0" (loops)); +} + +/* udelay(usecs) is used for very short delays up to 1 millisecond. */ + +extern __inline__ void udelay(unsigned int usecs) +{ + usecs *= 0x000010c6; /* Sparc is 32-bit just like ix86 */ + + __asm__("sethi %hi(_loops_per_sec), %o1\n\t" + "ld [%o1 + %lo(_loops_per_sec)], %o1\n\t" + "call ___delay\n\t" + "umul %o1, %o0, %o0\n\t"); +} + +/* calibrate_delay() wants this... */ + +extern __inline__ unsigned long muldiv(unsigned long a, unsigned long b, unsigned long c) +{ + return ((a*b)/c); +} + +#endif /* defined(__SPARC_DELAY_H) */ + diff --git a/include/asm-sparc/dma.h b/include/asm-sparc/dma.h new file mode 100644 index 000000000..138e7a445 --- /dev/null +++ b/include/asm-sparc/dma.h @@ -0,0 +1,20 @@ +/* + * include/asm-sparc/dma.h + * + * Don't even ask, I am figuring out how this crap works + * on the Sparc. It may end up being real hairy to plug + * into this code, maybe not, we'll see. + * + * Copyright (C) David S. Miller (davem@caip.rutgers.edu) + */ + +#include <asm/vac-ops.h> /* for invalidate's, etc. */ + +#define MAX_DMA_CHANNELS 8 +#define MAX_DMA_ADDRESS 0x0 + +#ifndef _ASM_SPARC_DMA_H +#define _ASM_SPARC_DMA_H + + +#endif /* !(_ASM_SPARC_DMA_H) */ diff --git a/include/asm-sparc/head.h b/include/asm-sparc/head.h new file mode 100644 index 000000000..b26067623 --- /dev/null +++ b/include/asm-sparc/head.h @@ -0,0 +1,75 @@ +#ifndef __SPARC_HEAD_H +#define __SPARC_HEAD_H + +#define KERNSIZE 134217728 /* this is how much of a mapping the prom promises */ +#define PAGESIZE 4096 /* luckily this is the same on sun4c's and sun4m's */ +#define PAGESHIFT 12 +#define PROM_BASE -1568768 /* casa 'de PROM */ +#define LOAD_ADDR 0x4000 /* prom jumps to us here */ +#define C_STACK 96 +#define SUN4C_SEGSZ (1 << 18) +#define USRSTACK 0x0 /* no joke, this is temporary, trust me */ +#define INT_ENABLE_REG_PHYSADR 0xf5000000 +#define INTS_ENAB 0x01 + +#define BOOT_MSG_LEN 61 +#define BOOT_MSG2_LEN 50 + + +#define WRITE_PAUSE nop; nop; nop; + +#define PAGE_SIZE 4096 + +/* Here are some trap goodies */ + + +/* Generic trap entry. */ + +#define TRAP_ENTRY(type, label) \ + mov (type), %l3; b label; rd %psr, %l0; nop; + +/* This is for hard interrupts from level 1-14, 15 is non-maskable (nmi) and + * gets handled with another macro. + */ + +#define TRAP_ENTRY_INTERRUPT(int_level) \ + mov int_level, %l3; b stray_irq_entry; rd %psr, %l0; nop; + +/* Here is the macro for soft interrupts (ie. not as urgent as hard ones) + * which need to jump to a different handler. + */ + +#define TRAP_ENTRY_INTERRUPT_SOFT(int_level, ident) \ + mov int_level, %l3; rd %psr, %l0; b stray_irq_entry; mov ident, %l4; + +/* The above two macros are for generic traps. The following is made + * especially for timer interrupts at IRQ level 14. + */ + +#define TRAP_ENTRY_TIMER \ + mov 10, %l3; rd %psr, %l0; b sparc_timer; nop; + +/* Non-maskable interrupt entry macro. You have to turn off all interrupts + * to not receive this. This is usually due to a asynchronous memory error. + * All we can really do is stop the show. :-( + */ + +#define TRAP_ENTRY_INTERRUPT_NMI(t_type, jmp_to) \ + mov t_type, %l3; b jmp_to; rd %psr, %l0; nop; + +/* Trap entry code in entry.S needs the offsets into task_struct + * to get at the thread_struct goodies during window craziness. + * + * NOTE: We need to keep these values under 0x3ff in order to do + * efficient load/stores in the window fill/spill handlers. + * See TRAP_WIN_CLEAN in entry.S for details. + */ + +#define THREAD_UWINDOWS 0x3bc +#define THREAD_WIM 0x3c0 +#define THREAD_W_SAVED 0x3c4 +#define THREAD_KSP 0x3c8 +#define THREAD_USP 0x3cc +#define THREAD_REG_WINDOW 0x3d4 + +#endif __SPARC_HEAD_H diff --git a/include/asm-sparc/idprom.h b/include/asm-sparc/idprom.h new file mode 100644 index 000000000..e7a136891 --- /dev/null +++ b/include/asm-sparc/idprom.h @@ -0,0 +1,21 @@ +/* idprom.h: Macros and defines for idprom routines + * + * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) + */ + +extern struct linux_romvec *romvec; + +#define IDPROM_ADDR (0xffd04000 + 0x7d8) +#define IDPROM_SIZE 36 + +struct idp_struct +{ + unsigned char id_f_id; /* format identifier */ + unsigned char id_machtype; /* Machine type */ + unsigned char id_eaddr[6]; /* hardware ethernet address */ + long id_domf; /* Date when this machine was manufactured */ + unsigned int id_sernum:24; /* Unique serial number */ + unsigned char id_cksum; /* XXX */ + unsigned char dummy[16]; /* XXX */ +}; + diff --git a/include/asm-sparc/io.h b/include/asm-sparc/io.h new file mode 100644 index 000000000..5aa1a3fac --- /dev/null +++ b/include/asm-sparc/io.h @@ -0,0 +1,100 @@ +#ifndef __SPARC_IO_H +#define __SPARC_IO_H + +#include <asm/page.h> /* IO address mapping routines need this */ + +/* + * Defines for io operations on the Sparc. Whether a memory access is going + * to i/o sparc is encoded in the pte. The type bits determine whether this + * is i/o sparc, on board memory, or VME space for VME cards. I think VME + * space only works on sun4's + */ + +extern inline unsigned long inb_local(unsigned long addr) +{ + return 0; +} + +extern inline void outb_local(unsigned char b, unsigned long addr) +{ + return; +} + +extern inline unsigned long inb(unsigned long addr) +{ + return 0; +} + +extern inline unsigned long inw(unsigned long addr) +{ + return 0; +} + +extern inline unsigned long inl(unsigned long addr) +{ + return 0; +} + +extern inline void outb(unsigned char b, unsigned long addr) +{ + return; +} + +extern inline void outw(unsigned short b, unsigned long addr) +{ + return; +} + +extern inline void outl(unsigned int b, unsigned long addr) +{ + return; +} + +/* + * Memory functions + */ +extern inline unsigned long readb(unsigned long addr) +{ + return 0; +} + +extern inline unsigned long readw(unsigned long addr) +{ + return 0; +} + +extern inline unsigned long readl(unsigned long addr) +{ + return 0; +} + +extern inline void writeb(unsigned short b, unsigned long addr) +{ + return; +} + +extern inline void writew(unsigned short b, unsigned long addr) +{ + return; +} + +extern inline void writel(unsigned int b, unsigned long addr) +{ + return; +} + +#define inb_p inb +#define outb_p outb + +extern inline void mapioaddr(unsigned long physaddr, unsigned long virt_addr) +{ + unsigned long page_entry; + + page_entry = physaddr >> PAGE_SHIFT; + page_entry |= (PTE_V | PTE_ACC | PTE_NC | PTE_IO); /* kernel io addr */ + + put_pte(virt_addr, page_entry); + return; +} + +#endif /* !(__SPARC_IO_H) */ diff --git a/include/asm-sparc/irq.h b/include/asm-sparc/irq.h new file mode 100644 index 000000000..0e96ffb8c --- /dev/null +++ b/include/asm-sparc/irq.h @@ -0,0 +1,43 @@ +#ifndef _ALPHA_IRQ_H +#define _ALPHA_IRQ_H + +/* + * linux/include/asm-sparc/irq.h + * + * Copyright (C) 1994 David S. Miller (davem@caip.rutgers.edu) + */ + +#include <linux/linkage.h> + +extern void disable_irq(unsigned int); +extern void enable_irq(unsigned int); + +#define __STR(x) #x +#define STR(x) __STR(x) + +#define SAVE_ALL "xx" + +#define SAVE_MOST "yy" + +#define RESTORE_MOST "zz" + +#define ACK_FIRST(mask) "aa" + +#define ACK_SECOND(mask) "dummy" + +#define UNBLK_FIRST(mask) "dummy" + +#define UNBLK_SECOND(mask) "dummy" + +#define IRQ_NAME2(nr) nr##_interrupt(void) +#define IRQ_NAME(nr) IRQ_NAME2(IRQ##nr) +#define FAST_IRQ_NAME(nr) IRQ_NAME2(fast_IRQ##nr) +#define BAD_IRQ_NAME(nr) IRQ_NAME2(bad_IRQ##nr) + +#define BUILD_IRQ(chip,nr,mask) \ +asmlinkage void IRQ_NAME(nr); \ +asmlinkage void FAST_IRQ_NAME(nr); \ +asmlinkage void BAD_IRQ_NAME(nr); \ +asm code comes here + +#endif diff --git a/include/asm-sparc/memerr.h b/include/asm-sparc/memerr.h new file mode 100644 index 000000000..cd0ca3264 --- /dev/null +++ b/include/asm-sparc/memerr.h @@ -0,0 +1,32 @@ +#ifndef _SPARC_MEMERR_H +#define _SPARC_MEMERR_H + +/* memerr.h: Bit fields in the asynchronous and synchronous memory error + registers used to determine what 'type' of error has just + induced a trap. + + Copyright (C) 1994 David S. Miller (davem@caip.rutgers.edu) +*/ + +/* synchronous error register fields come first... */ + +#define SYNCER_WRITE 0x8000 /* write error... */ +#define SYNCER_INVAL 0x0080 /* invalid page access was attempted */ +#define SYNCER_PROT 0x0040 /* protection violation */ +#define SYNCER_TIMEOUT 0x0020 /* mem-bus access timeout (mem does not exist). */ +#define SYNCER_SBUSERR 0x0010 /* same as above, but for an SBUS access */ +#define SYNCER_MEMERR 0x0008 /* Bus parity error, lose lose... panic time */ +#define SYNCER_SZERR 0x0002 /* an attempted access was of BAD size, whoops */ +#define SYNCER_WATCHDOG 0x0001 /* although we never see these, the prom will.. */ + +/* asynchronous error bits go here */ + +#define ASYNCER_WBINVAL 0x80 /* situation arose where the cache tried to write + * back a page for which the valid bit was not set + * within the mmu. This is due to bad mm kernel bugs. + */ + +#define ASYNCER_TIMEOUT 0x20 /* mem-access bus timeout... */ +#define ASYNCER_DVMAERR 0x10 /* dvma transfer to/from memory bombed... */ + +#endif /* _SPARC_MEMERR_H */ diff --git a/include/asm-sparc/openprom.h b/include/asm-sparc/openprom.h new file mode 100644 index 000000000..ca6d9e36d --- /dev/null +++ b/include/asm-sparc/openprom.h @@ -0,0 +1,304 @@ +#ifndef __SPARC_OPENPROM_H +#define __SPARC_OPENPROM_H + +/* openprom.h: Prom structures and defines for access to the OPENBOOT + prom routines and data areas. + + Copyright (C) 1994 David S. Miller (davem@caip.rutgers.edu) +*/ + +/* In the v0 interface of the openboot prom we could traverse a nice + little list structure to figure out where in vm-space the prom had + mapped itself and how much space it was taking up. In the v2 prom + interface we have to rely on 'magic' values. :-( Most of the machines + I have checked on have the prom mapped here all the time though. +*/ +#define LINUX_OPPROM_BEGVM 0xffd00000 +#define LINUX_OPPROM_ENDVM 0xfff00000 + +#define LINUX_OPPROM_MAGIC 0x10010407 + +/* The device functions structure for the v0 prom. Nice and neat, open, + close, read & write divvied up between net + block + char devices. We + also have a seek routine only usable for block devices. The divide + and conquer strategy of this struct becomes unnecessary for v2. + + V0 device names are limited to two characters, 'sd' for scsi-disk, + 'le' for local-ethernet, etc. Note that it is technically possible + to boot a kernel off of a tape drive and use the tape as the root + partition! In order to do this you have to have 'magic' formatted + tapes from Sun supposedly :-) +*/ + +struct linux_dev_v0_funcs { + int (*v0_devopen)(char *device_str); + int (*v0_devclose)(int dev_desc); + int (*v0_rdblkdev)(int dev_desc, int num_blks, int blk_st, char* buf); + int (*v0_wrblkdev)(int dev_desc, int num_blks, int blk_st, char* buf); + int (*v0_wrnetdev)(int dev_desc, int num_bytes, char* buf); + int (*v0_rdnetdev)(int dev_desc, int num_bytes, char* buf); + int (*v0_rdchardev)(int dev_desc, int num_bytes, int dummy, char* buf); + int (*v0_wrchardev)(int dev_desc, int num_bytes, int dummy, char* buf); + int (*v0_seekdev)(int dev_desc, long logical_offst, int from); +}; + +/* The OpenBoot Prom device operations for version-2 interfaces are both + good and bad. They now allow you to address ANY device whatsoever + that is in the machine via these funny "device paths". They look like + this: + + "/sbus/esp@0,0xf004002c/sd@3,1" + + You can basically reference any device on the machine this way, and + you pass this string to the v2 dev_ops. Producing these strings all + the time can be a pain in the rear after a while. Why v2 has memory + allocations in here are beyond me. Perhaps they figure that if you + are going to use only the prom's device drivers then your memory + management is either non-existent or pretty sad. :-) +*/ + +struct linux_dev_v2_funcs { + int (*v2_aieee)(int d); /* figure this out later... */ + + /* "dumb" prom memory management routines, probably + only safe to use for mapping device address spaces... + */ + + char* (*v2_dumb_mem_alloc)(char* va, unsigned sz); + void (*v2_dumb_mem_free)(char* va, unsigned sz); + + /* "dumb" mmap() munmap(), copy on write? what's that? */ + char* (*v2_dumb_mmap)(char* virta, int asi, unsigned prot, unsigned sz); + void (*v2_dumb_munmap)(char* virta, unsigned size); + + /* Basic Operations, self-explanatory */ + int (*v2_dev_open)(char *devpath); + void (*v2_dev_close)(int d); + int (*v2_dev_read)(int d, char* buf, int nbytes); + int (*v2_dev_write)(int d, char* buf, int nbytes); + void (*v2_dev_seek)(int d, int hi, int lo); + + /* huh? */ + void (*v2_wheee2)(void); + void (*v2_wheee3)(void); +}; + +/* Just like the device ops, they slightly screwed up the mem-list + from v0 to v2. Probably easier on the prom-writer dude, sucks for + us though. See above comment about prom-vm mapped address space + magic numbers. :-( +*/ + +struct linux_mlist_v0 { + struct linux_mlist_v0 *theres_more; + char* start_adr; + unsigned num_bytes; +}; + +/* The linux_mlist_v0's are pointer by this structure. One list + per description. This means one list for total physical memory, + one for prom's address mapping, and one for physical mem left after + the kernel is loaded. + */ +struct linux_mem_v0 { + struct linux_mlist_v0 **v0_totphys; /* all of physical */ + struct linux_mlist_v0 **v0_prommap; /* addresses map'd by prom */ + struct linux_mlist_v0 **v0_available; /* what phys. is left over */ +}; + +/* Arguments sent to the kernel from the boot prompt. */ + +struct linux_arguments_v0 { + char *argv[8]; /* argv format for boot string */ + char args[100]; /* string space */ + char boot_dev[2]; /* e.g., "sd" for `b sd(...' */ + int boot_dev_ctrl; /* controller # */ + int boot_dev_unit; /* unit # */ + int dev_partition; /* partition # */ + char *kernel_file_name; /* kernel to boot, e.g., "vmunix" */ + void *aieee1; /* give me some time :> */ +}; + +/* Prom version-2 gives us the raw strings for boot arguments and + boot device path. We also get the stdin and stdout file pseudo + descriptors for use with the mungy v2 device functions. +*/ +struct linux_bootargs_v2 { + char **bootpath; /* V2: Path to boot device */ + char **bootargs; /* V2: Boot args */ + int *fd_stdin; /* V2: Stdin descriptor */ + int *fd_stdout; /* V2: Stdout descriptor */ +}; + +/* This is the actual Prom Vector from which everything else is accessed + via struct and function pointers, etc. The prom when it loads us into + memory plops a pointer to this master structure in register %o0 before + it jumps to the kernel start address. I will update this soon to cover + the v3 semantics (cpu_start, cpu_stop and other SMP fun things). :-) +*/ +struct linux_romvec { + /* Version numbers. */ + unsigned int pv_magic_cookie; /* Magic Mushroom... */ + unsigned int pv_romvers; /* iface vers (0, 2, or 3) */ + unsigned int pv_plugin_revision; /* revision relative to above vers */ + unsigned int pv_printrev; /* print revision */ + + /* Version 0 memory descriptors (see below). */ + struct linux_mem_v0 pv_v0mem; /* V0: Memory description lists. */ + + /* Node operations (see below). */ + struct linux_nodeops *pv_nodeops; /* node functions, gets device data */ + + char **pv_bootstr; /* Boot command, eg sd(0,0,0)vmunix */ + + struct linux_dev_v0_funcs pv_v0devops; /* V0: device ops */ + + /* + * PROMDEV_* cookies. I fear these may vanish in lieu of fd0/fd1 + * (see below) in future PROMs, but for now they work fine. + */ + char *pv_stdin; /* stdin cookie */ + char *pv_stdout; /* stdout cookie */ +#define PROMDEV_KBD 0 /* input from keyboard */ +#define PROMDEV_SCREEN 0 /* output to screen */ +#define PROMDEV_TTYA 1 /* in/out to ttya */ +#define PROMDEV_TTYB 2 /* in/out to ttyb */ + + /* Blocking getchar/putchar. NOT REENTRANT! (grr) */ + int (*pv_getchar)(void); + void (*pv_putchar)(int ch); + + /* Non-blocking variants that return -1 on error. */ + int (*pv_nbgetchar)(void); + int (*pv_nbputchar)(int ch); + + /* Put counted string (can be very slow). */ + void (*pv_putstr)(char *str, int len); + + /* Miscellany. */ + void (*pv_reboot)(char *bootstr); + void (*pv_printf)(const char *fmt, ...); + void (*pv_abort)(void); /* BREAK key abort */ + int *pv_ticks; /* milliseconds since last reset */ + void (*pv_halt)(void); /* End the show */ + void (**pv_synchook)(void); /* "sync" ptr to function */ + + /* + * This eval's a FORTH string. Unfortunately, its interface + * changed between V0 and V2, which gave us much pain. + */ + union { + void (*v0_eval)(int len, char *str); + void (*v2_eval)(char *str); + } pv_fortheval; + + struct linux_arguments_v0 **pv_v0bootargs; /* V0: Boot args */ + + /* Extract Ethernet address from network device. */ + unsigned int (*pv_enaddr)(int d, char *enaddr); + + struct linux_bootargs_v2 pv_v2bootargs; /* V2: Boot args+std-in/out */ + struct linux_dev_v2_funcs pv_v2devops; /* V2: device operations */ + + int whatzthis[15]; /* huh? */ + + /* + * The following is machine-dependent. + * + * The sun4c needs a PROM function to set a PMEG for another + * context, so that the kernel can map itself in all contexts. + * It is not possible simply to set the context register, because + * contexts 1 through N may have invalid translations for the + * current program counter. The hardware has a mode in which + * all memory references go to the PROM, so the PROM can do it + * easily. + */ + void (*pv_setctxt)(int ctxt, char* va, int pmeg); + + /* Prom version 3 Multiprocessor routines. This stuff is crazy. + * No joke. Calling these when there is only one cpu probably + * crashes the machine, have to test this. :-) + */ + + /* v3_cpustart() will start the cpu 'whichcpu' in mmu-context + * 'thiscontext' executing at address 'prog_counter' + * + * XXX Have to figure out what 'cancontext' means. + */ + + int (*v3_cpustart)(unsigned int whichcpu, int cancontext, + int thiscontext, char* prog_counter); + + /* v3_cpustop() will cause cpu 'whichcpu' to stop executing + * until a resume cpu call is made. + */ + + int (*v3_cpustop)(unsigned int whichcpu); + + /* v3_cpuidle() will idle cpu 'whichcpu' until a stop or + * resume cpu call is made. + */ + + int (*v3_cpuidle)(unsigned int whichcpu); + + /* v3_cpuresume() will resume processor 'whichcpu' executing + * starting with whatever 'pc' and 'npc' were left at the + * last 'idle' or 'stop' call. + */ + + int (*v3_cpuresume)(unsigned int whichcpu); + +}; + +/* + * In addition to the global stuff defined in the PROM vectors above, + * the PROM has quite a collection of `nodes'. A node is described by + * an integer---these seem to be internal pointers, actually---and the + * nodes are arranged into an N-ary tree. Each node implements a fixed + * set of functions, as described below. The first two deal with the tree + * structure, allowing traversals in either breadth- or depth-first fashion. + * The rest deal with `properties'. + * + * A node property is simply a name/value pair. The names are C strings + * (NUL-terminated); the values are arbitrary byte strings (counted strings). + * Many values are really just C strings. Sometimes these are NUL-terminated, + * sometimes not, depending on the the interface version; v0 seems to + * terminate and v2 not. Many others are simply integers stored as four + * bytes in machine order: you just get them and go. The third popular + * format is an `address', which is made up of one or more sets of three + * integers as defined below. + * + * One uses these functions to traverse the device tree to see what devices + * this machine has attached to it. + * + * N.B.: for the `next' functions, next(0) = first, and next(last) = 0. + * Whoever designed this part had good taste. On the other hand, these + * operation vectors are global, rather than per-node, yet the pointers + * are not in the openprom vectors but rather found by indirection from + * there. So the taste balances out. + */ +struct linux_prom_addr { + int oa_space; /* address space (may be relative) */ + unsigned int oa_base; /* address within space */ + unsigned int oa_size; /* extent (number of bytes) */ +}; + +struct linux_nodeops { + /* + * Tree traversal. + */ + int (*no_nextnode)(int node); /* next(node) */ + int (*no_child)(int node); /* first child */ + + /* + * Property functions. Proper use of getprop requires calling + * proplen first to make sure it fits. Kind of a pain, but no + * doubt more convenient for the PROM coder. + */ + int (*no_proplen)(int node, char* name); + int (*no_getprop)(int node, char* name, char* val); + int (*no_setprop)(int node, char* name, char* val, int len); + char* (*no_nextprop)(int node, char* name); +}; + +#endif /* !(__SPARC_OPENPROM_H) */ diff --git a/include/asm-sparc/page.h b/include/asm-sparc/page.h new file mode 100644 index 000000000..a048ac76c --- /dev/null +++ b/include/asm-sparc/page.h @@ -0,0 +1,181 @@ +/* page.h: Various defines and such for MMU operations on the Sparc for + the Linux kernel. + + Copyright (C) 1994 David S. Miller (davem@caip.rutgers.edu) +*/ + +#ifndef _SPARC_PAGE_H +#define _SPARC_PAGE_H + +#include <asm/asi.h> /* for get/set segmap/pte routines */ +#include <asm/contregs.h> /* for switch_to_context */ + +#define PAGE_SHIFT 12 /* This is the virtual page... */ + +#ifndef __ASSEMBLY__ +#define PAGE_SIZE (1UL << PAGE_SHIFT) + +/* to mask away the intra-page address bits */ +#define PAGE_MASK (~(PAGE_SIZE-1)) + +#ifdef __KERNEL__ + +/* The following structure is used to hold the physical + * memory configuration of the machine. This is filled + * in probe_memory() and is later used by mem_init() to + * set up mem_map[]. We statically allocate 14 of these + * structs, this is arbitrary. The entry after the last + * valid one has num_bytes==0. + */ + +struct sparc_phys_banks { + unsigned long base_addr; + unsigned long num_bytes; +}; + +#define CONFIG_STRICT_MM_TYPECHECKS + +#ifdef CONFIG_STRICT_MM_TYPECHECKS +/* + * These are used to make use of C type-checking.. + */ +typedef struct { unsigned long pte; } pte_t; +typedef struct { unsigned long pmd; } pmd_t; +typedef struct { unsigned long pgd; } pgd_t; +typedef struct { unsigned long pgprot; } pgprot_t; + +#define pte_val(x) ((x).pte) +#define pmd_val(x) ((x).pmd) +#define pgd_val(x) ((x).pgd) +#define pgprot_val(x) ((x).pgprot) + +#define __pte(x) ((pte_t) { (x) } ) +#define __pmd(x) ((pmd_t) { (x) } ) +#define __pgd(x) ((pgd_t) { (x) } ) +#define __pgprot(x) ((pgprot_t) { (x) } ) + +#else +/* + * .. while these make it easier on the compiler + */ +typedef unsigned long pte_t; +typedef unsigned long pmd_t; +typedef unsigned long pgd_t; +typedef unsigned long pgprot_t; + +#define pte_val(x) (x) +#define pmd_val(x) (x) +#define pgd_val(x) (x) +#define pgprot_val(x) (x) + +#define __pte(x) (x) +#define __pmd(x) (x) +#define __pgd(x) (x) +#define __pgprot(x) (x) + +#endif + +/* The current va context is global and known, so all that is needed to + * do an invalidate is flush the VAC. + */ + +#define invalidate() flush_vac_context() /* how conveeeiiiiinnnient :> */ + +#define copy_page(from,to) memcpy((void *) to, (void *) from, PAGE_SIZE) + +/* to align the pointer to the (next) page boundary */ +#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK) + +#define PAGE_OFFSET 0 +#define MAP_NR(addr) (((unsigned long)(addr)) >> PAGE_SHIFT) +#define MAP_PAGE_RESERVED (1<<15) + + +#endif /* !(__ASSEMBLY__) */ + +/* The rest is kind of funky because on the sparc, the offsets into the mmu + * entries are encoded in magic alternate address space tables. I will + * probably find some nifty inline assembly routines to do the equivalent. + * Much thought must go into this code. (davem@caip.rutgers.edu) + */ + +/* Bitfields within a Sparc sun4c PTE (page table entry). */ + +#define PTE_V 0x80000000 /* valid bit */ +#define PTE_ACC 0x60000000 /* access bits */ +#define PTE_W 0x40000000 /* writable bit */ +#define PTE_P 0x20000000 /* privileged page */ +#define PTE_NC 0x10000000 /* page is non-cacheable */ +#define PTE_TYP 0x0c000000 /* page type field */ +#define PTE_RMEM 0x00000000 /* type == on board real memory */ +#define PTE_IO 0x04000000 /* type == i/o area */ +#define PTE_VME16 0x08000000 /* type == 16-bit VME area */ +#define PTE_VME32 0x0c000000 /* type == 32-bit VME area */ +#define PTE_R 0x02000000 /* page has been referenced */ +#define PTE_M 0x01000000 /* page has been modified */ +#define PTE_RESV 0x00f80000 /* reserved bits */ +#define PTE_PHYPG 0x0007ffff /* phys pg number, sun4c only uses 16bits */ + +extern __inline__ unsigned long get_segmap(unsigned long addr) +{ + register unsigned long entry; + + __asm__ __volatile__("lduba [%1] 0x3, %0" : + "=r" (entry) : + "r" (addr)); + + return (entry&0x7f); +} + +extern __inline__ void put_segmap(unsigned long addr, unsigned long entry) +{ + + __asm__ __volatile__("stba %1, [%0] 0x3" : : "r" (addr), "r" (entry&0x7f)); + + return; +} + +extern __inline__ unsigned long get_pte(unsigned long addr) +{ + register unsigned long entry; + + __asm__ __volatile__("lda [%1] 0x4, %0" : + "=r" (entry) : + "r" (addr)); + return entry; +} + +extern __inline__ void put_pte(unsigned long addr, unsigned long entry) +{ + __asm__ __volatile__("sta %1, [%0] 0x4" : : + "r" (addr), + "r" (entry)); + + return; +} + +extern __inline__ void switch_to_context(int context) +{ + __asm__ __volatile__("stba %0, [%1] 0x2" : : + "r" (context), + "r" (0x30000000)); + + return; +} + +extern __inline__ int get_context(void) +{ + register int ctx; + + __asm__ __volatile__("lduba [%1] 0x2, %0" : + "=r" (ctx) : + "r" (0x30000000)); + + return ctx; +} + +typedef unsigned short mem_map_t; + +#endif /* __KERNEL__ */ + +#endif /* _SPARC_PAGE_H */ diff --git a/include/asm-sparc/param.h b/include/asm-sparc/param.h new file mode 100644 index 000000000..45a9133af --- /dev/null +++ b/include/asm-sparc/param.h @@ -0,0 +1,20 @@ +#ifndef _ASMSPARC_PARAM_H +#define _ASMSPARC_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/asm-sparc/pgtable.h b/include/asm-sparc/pgtable.h new file mode 100644 index 000000000..45b652108 --- /dev/null +++ b/include/asm-sparc/pgtable.h @@ -0,0 +1,342 @@ +#ifndef _SPARC_PGTABLE_H +#define _SPARC_PGTABLE_H + +/* asm-sparc/pgtable.h: Defines and functions used to work + * with Sparc page tables. + * + * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) + */ + +/* PMD_SHIFT determines the size of the area a second-level page table can map */ +#define PMD_SHIFT 18 +#define PMD_SIZE (1UL << PMD_SHIFT) +#define PMD_MASK (~(PMD_SIZE-1)) + +/* PGDIR_SHIFT determines what a third-level page table entry can map */ +#define PGDIR_SHIFT 18 +#define PGDIR_SIZE (1UL << PGDIR_SHIFT) +#define PGDIR_MASK (~(PGDIR_SIZE-1)) +#define PGDIR_ALIGN(addr) (((addr)+PGDIR_SIZE-1)&PGDIR_MASK) + +/* + * Just following the i386 lead, because it works on the Sparc sun4c + * machines. Two-level, therefore there is no real PMD. + */ + +#define PTRS_PER_PTE 1024 +#define PTRS_PER_PMD 1 +#define PTRS_PER_PGD 1024 + +/* the no. of pointers that fit on a page: this will go away */ +#define PTRS_PER_PAGE (PAGE_SIZE/sizeof(void*)) + +/* Just any arbitrary offset to the start of the vmalloc VM area: the + * current 8MB value just means that there will be a 8MB "hole" after the + * physical memory until the kernel virtual memory starts. That means that + * any out-of-bounds memory accesses will hopefully be caught. + * The vmalloc() routines leaves a hole of 4kB between each vmalloced + * area for the same reason. ;) + */ +#define VMALLOC_OFFSET (8*1024*1024) +#define VMALLOC_START ((high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1)) +#define VMALLOC_VMADDR(x) (TASK_SIZE + (unsigned long)(x)) + +/* + * Sparc page table fields. + */ + +#define _PAGE_VALID 0x80000000 /* valid page */ +#define _PAGE_WRITE 0x40000000 /* can be written to */ +#define _PAGE_PRIV 0x20000000 /* bit to signify privileged page */ +#define _PAGE_NOCACHE 0x10000000 /* non-cacheable page */ +#define _PAGE_REF 0x02000000 /* Page has been accessed/referenced */ +#define _PAGE_DIRTY 0x01000000 /* Page has been modified, is dirty */ +#define _PAGE_COW 0x00800000 /* COW page, hardware ignores this bit (untested) */ + + +/* Sparc sun4c mmu has only a writable bit. Thus if a page is valid it can be + * read in a load, and executed as code automatically. Although, the memory fault + * hardware does make a distinction between date-read faults and insn-read faults + * which is determined by which trap happened plus magic sync/async fault register + * values which must be checked in the actual fault handler. + */ + +/* We want the swapper not to swap out page tables, thus dirty and writable + * so that the kernel can change the entries as needed. Also valid for + * obvious reasons. + */ +#define _PAGE_TABLE (_PAGE_VALID | _PAGE_WRITE | _PAGE_DIRTY) +#define _PAGE_CHG_MASK (PAGE_MASK | _PAGE_REF | _PAGE_DIRTY) + +#define PAGE_NONE __pgprot(_PAGE_VALID | _PAGE_REF) +#define PAGE_SHARED __pgprot(_PAGE_VALID | _PAGE_WRITE | _PAGE_REF) +#define PAGE_COPY __pgprot(_PAGE_VALID | _PAGE_REF | _PAGE_COW) +#define PAGE_READONLY __pgprot(_PAGE_VALID | _PAGE_REF) +#define PAGE_KERNEL __pgprot(_PAGE_VALID | _PAGE_WRITE | _PAGE_NOCACHE | _PAGE_REF | _PAGE_PRIV) +#define PAGE_INVALID __pgprot(_PAGE_PRIV) + +#define _PAGE_NORMAL(x) __pgprot(_PAGE_VALID | _PAGE_REF | (x)) + +/* I define these like the i386 does because the check for text or data fault + * is done at trap time by the low level handler. Maybe I can set these bits + * then once determined. I leave them like this for now though. + */ +#define __P000 PAGE_NONE +#define __P001 PAGE_READONLY +#define __P010 PAGE_COPY +#define __P011 PAGE_COPY +#define __P100 PAGE_READONLY +#define __P101 PAGE_READONLY +#define __P110 PAGE_COPY +#define __P111 PAGE_COPY + +#define __S000 PAGE_NONE +#define __S001 PAGE_READONLY +#define __S010 PAGE_SHARED +#define __S011 PAGE_SHARED +#define __S100 PAGE_READONLY +#define __S101 PAGE_READONLY +#define __S110 PAGE_SHARED +#define __S111 PAGE_SHARED + + +extern unsigned long pg0[1024]; + +/* + * BAD_PAGETABLE is used when we need a bogus page-table, while + * BAD_PAGE is used for a bogus page. + * + * ZERO_PAGE is a global shared page that is always zero: used + * for zero-mapped memory areas etc.. + */ +extern pte_t __bad_page(void); +extern pte_t * __bad_pagetable(void); + +extern unsigned long __zero_page(void); + + +#define BAD_PAGETABLE __bad_pagetable() +#define BAD_PAGE __bad_page() +#define ZERO_PAGE __zero_page() + +/* number of bits that fit into a memory pointer */ +#define BITS_PER_PTR (8*sizeof(unsigned long)) /* better check this stuff */ + +/* to align the pointer to a pointer address */ +#define PTR_MASK (~(sizeof(void*)-1)) + + +#define SIZEOF_PTR_LOG2 2 + + +/* to set the page-dir + * + * On the Sparc the page segments hold 64 pte's which means 256k/segment. + * Therefore there is no global idea of 'the' page directory, although we + * make a virtual one in kernel memory so that we can keep the stats on + * all the pages since not all can be loaded at once in the mmu. + */ + +#define SET_PAGE_DIR(tsk,pgdir) + +/* to find an entry in a page-table */ +#define PAGE_PTR(address) \ +((unsigned long)(address)>>(PAGE_SHIFT-SIZEOF_PTR_LOG2)&PTR_MASK&~PAGE_MASK) + +extern unsigned long high_memory; + +extern inline int pte_none(pte_t pte) { return !pte_val(pte); } +extern inline int pte_present(pte_t pte) { return pte_val(pte) & _PAGE_VALID; } +extern inline int pte_inuse(pte_t *ptep) { return mem_map[MAP_NR(ptep)] > 1; } +extern inline void pte_clear(pte_t *ptep) { pte_val(*ptep) = 0; } +extern inline void pte_reuse(pte_t *ptep) +{ + if(!(mem_map[MAP_NR(ptep)] & MAP_PAGE_RESERVED)) + mem_map[MAP_NR(ptep)]++; +} + +extern inline int pmd_none(pmd_t pmd) { return !pmd_val(pmd); } +extern inline int pmd_bad(pmd_t pmd) { return (pmd_val(pmd) & ~PAGE_MASK) != _PAGE_TABLE || pmd_val(pmd) > high_memory; } +extern inline int pmd_present(pmd_t pmd) { return pmd_val(pmd) & _PAGE_VALID; } +extern inline int pmd_inuse(pmd_t *pmdp) { return 0; } +extern inline void pmd_clear(pmd_t *pmdp) { pmd_val(*pmdp) = 0; } +extern inline void pmd_reuse(pmd_t * pmdp) { } + +extern inline int pgd_none(pgd_t pgd) { return !pgd_val(pgd); } +extern inline int pgd_bad(pgd_t pgd) { return (pgd_val(pgd) & ~PAGE_MASK) != _PAGE_TABLE || pgd_val(pgd) > high_memory; } +extern inline int pgd_present(pgd_t pgd) { return pgd_val(pgd) & _PAGE_VALID; } +extern inline int pgd_inuse(pgd_t *pgdp) { return mem_map[MAP_NR(pgdp)] > 1; } +extern inline void pgd_clear(pgd_t * pgdp) { pgd_val(*pgdp) = 0; } +extern inline void pgd_reuse(pgd_t *pgdp) +{ + if (!(mem_map[MAP_NR(pgdp)] & MAP_PAGE_RESERVED)) + mem_map[MAP_NR(pgdp)]++; +} + +/* + * The following only work if pte_present() is true. + * Undefined behaviour if not.. + */ +extern inline int pte_read(pte_t pte) { return pte_val(pte) & _PAGE_VALID; } +extern inline int pte_write(pte_t pte) { return pte_val(pte) & _PAGE_WRITE; } +extern inline int pte_exec(pte_t pte) { return pte_val(pte) & _PAGE_VALID; } +extern inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_REF; } +extern inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_REF; } +extern inline int pte_cow(pte_t pte) { return pte_val(pte) & _PAGE_COW; } + +extern inline pte_t pte_wrprotect(pte_t pte) { pte_val(pte) &= ~_PAGE_WRITE; return pte; } +extern inline pte_t pte_rdprotect(pte_t pte) { pte_val(pte) &= ~_PAGE_VALID; return pte; } +extern inline pte_t pte_exprotect(pte_t pte) { pte_val(pte) &= ~_PAGE_VALID; return pte; } +extern inline pte_t pte_mkclean(pte_t pte) { pte_val(pte) &= ~_PAGE_DIRTY; return pte; } +extern inline pte_t pte_mkold(pte_t pte) { pte_val(pte) &= ~_PAGE_REF; return pte; } +extern inline pte_t pte_uncow(pte_t pte) { pte_val(pte) &= ~_PAGE_COW; return pte; } +extern inline pte_t pte_mkwrite(pte_t pte) { pte_val(pte) |= _PAGE_WRITE; return pte; } +extern inline pte_t pte_mkread(pte_t pte) { pte_val(pte) |= _PAGE_VALID; return pte; } +extern inline pte_t pte_mkexec(pte_t pte) { pte_val(pte) |= _PAGE_VALID; return pte; } +extern inline pte_t pte_mkdirty(pte_t pte) { pte_val(pte) |= _PAGE_DIRTY; return pte; } +extern inline pte_t pte_mkyoung(pte_t pte) { pte_val(pte) |= _PAGE_REF; return pte; } +extern inline pte_t pte_mkcow(pte_t pte) { pte_val(pte) |= _PAGE_COW; return pte; } + +/* + * Conversion functions: convert a page and protection to a page entry, + * and a page entry and page directory to the page they refer to. + */ +extern inline pte_t mk_pte(unsigned long page, pgprot_t pgprot) +{ pte_t pte; pte_val(pte) = page | pgprot_val(pgprot); return pte; } + +extern inline pte_t pte_modify(pte_t pte, pgprot_t newprot) +{ pte_val(pte) = (pte_val(pte) & _PAGE_CHG_MASK) | pgprot_val(newprot); return pte; } + +extern inline unsigned long pte_page(pte_t pte) { return pte_val(pte) & PAGE_MASK; } + +extern inline unsigned long pmd_page(pmd_t pmd) { return pmd_val(pmd) & PAGE_MASK; } + +extern inline unsigned long pgd_page(pgd_t pgd) { return pgd_val(pgd) & PAGE_MASK; } + +extern inline void pgd_set(pgd_t * pgdp, pte_t * ptep) +{ pgd_val(*pgdp) = _PAGE_TABLE | (unsigned long) ptep; } + +/* to find an entry in a page-table-directory */ +#define PAGE_DIR_OFFSET(tsk,address) \ +((((unsigned long)(address)) >> 22) + (pgd_t *) (tsk)->tss.cr3) + +/* to find an entry in a page-table-directory */ +extern inline pgd_t * pgd_offset(struct task_struct * tsk, unsigned long address) +{ + return (pgd_t *) tsk->tss.cr3 + (address >> PGDIR_SHIFT); +} + +/* Find an entry in the second-level page table.. */ +extern inline pmd_t * pmd_offset(pgd_t * dir, unsigned long address) +{ + return (pmd_t *) dir; +} + +/* Find an entry in the third-level page table.. */ +extern inline pte_t * pte_offset(pmd_t * dir, unsigned long address) +{ + return (pte_t *) pmd_page(*dir) + ((address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)); +} + + +/* + * Allocate and free page tables. The xxx_kernel() versions are + * used to allocate a kernel page table - this turns on ASN bits + * if any, and marks the page tables reserved. + */ +extern inline void pte_free_kernel(pte_t * pte) +{ + mem_map[MAP_NR(pte)] = 1; + free_page((unsigned long) pte); +} + +extern inline pte_t * pte_alloc_kernel(pmd_t * pmd, unsigned long address) +{ + address = (address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1); + if (pmd_none(*pmd)) { + pte_t * page = (pte_t *) get_free_page(GFP_KERNEL); + if (pmd_none(*pmd)) { + if (page) { + pmd_val(*pmd) = _PAGE_TABLE | (unsigned long) page; + mem_map[MAP_NR(page)] = MAP_PAGE_RESERVED; + return page + address; + } + pmd_val(*pmd) = _PAGE_TABLE | (unsigned long) BAD_PAGETABLE; + return NULL; + } + free_page((unsigned long) page); + } + if (pmd_bad(*pmd)) { + printk("Bad pmd in pte_alloc: %08lx\n", pmd_val(*pmd)); + pmd_val(*pmd) = _PAGE_TABLE | (unsigned long) BAD_PAGETABLE; + return NULL; + } + return (pte_t *) pmd_page(*pmd) + address; +} + +/* + * allocating and freeing a pmd is trivial: the 1-entry pmd is + * inside the pgd, so has no extra memory associated with it. + */ +extern inline void pmd_free_kernel(pmd_t * pmd) +{ +} + +extern inline pmd_t * pmd_alloc_kernel(pgd_t * pgd, unsigned long address) +{ + return (pmd_t *) pgd; +} + +extern inline void pte_free(pte_t * pte) +{ + free_page((unsigned long) pte); +} + +extern inline pte_t * pte_alloc(pmd_t * pmd, unsigned long address) +{ + address = (address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1); + if (pmd_none(*pmd)) { + pte_t * page = (pte_t *) get_free_page(GFP_KERNEL); + if (pmd_none(*pmd)) { + if (page) { + pmd_val(*pmd) = _PAGE_TABLE | (unsigned long) page; + return page + address; + } + pmd_val(*pmd) = _PAGE_TABLE | (unsigned long) BAD_PAGETABLE; + return NULL; + } + free_page((unsigned long) page); + } + if (pmd_bad(*pmd)) { + printk("Bad pmd in pte_alloc: %08lx\n", pmd_val(*pmd)); + pmd_val(*pmd) = _PAGE_TABLE | (unsigned long) BAD_PAGETABLE; + return NULL; + } + return (pte_t *) pmd_page(*pmd) + address; +} + +/* + * allocating and freeing a pmd is trivial: the 1-entry pmd is + * inside the pgd, so has no extra memory associated with it. + */ +extern inline void pmd_free(pmd_t * pmd) +{ +} + +extern inline pmd_t * pmd_alloc(pgd_t * pgd, unsigned long address) +{ + return (pmd_t *) pgd; +} + +extern inline void pgd_free(pgd_t *pgd) +{ + free_page((unsigned long) pgd); +} +extern inline pgd_t *pgd_alloc(void) +{ + return (pgd_t *) get_free_page(GFP_KERNEL); +} + +extern pgd_t swapper_pg_dir[1024]; + +#endif /* !(_SPARC_PGTABLE_H) */ diff --git a/include/asm-sparc/processor.h b/include/asm-sparc/processor.h new file mode 100644 index 000000000..7e18bfb2f --- /dev/null +++ b/include/asm-sparc/processor.h @@ -0,0 +1,156 @@ +/* include/asm-sparc/processor.h + * + * Copyright (C) 1994 David S. Miller (davem@caip.rutgers.edu) + */ + +#ifndef __ASM_SPARC_PROCESSOR_H +#define __ASM_SPARC_PROCESSOR_H + +/* + * Bus types + */ +#define EISA_bus 1 +#define EISA_bus__is_a_macro /* for versions in ksyms.c */ +#define MCA_bus 0 +#define MCA_bus__is_a_macro /* for versions in ksyms.c */ + +/* + * Write Protection works right in supervisor mode on the Sparc + */ + +#define wp_works_ok 1 +#define wp_works_ok__is_a_macro /* for versions in ksyms.c */ + +/* + * User space process size: 3GB. This is hardcoded into a few places, + * so don't change it unless you know what you are doing. + * + * "this is gonna have to change to 1gig for the sparc" - David S. Miller + */ +#define TASK_SIZE (0xC0000000UL) + +/* + * Size of io_bitmap in longwords: 32 is ports 0-0x3ff. + */ +#define IO_BITMAP_SIZE 32 + +/* The first five entries here MUST be the first four. This allows me to + * do %lo(offset) loads and stores in entry.S. See TRAP_WIN_CLEAN to see + * why. + */ + +struct thread_struct { + unsigned long uwindows; /* how many user windows are in the set */ + unsigned long wim; /* user's window invalid mask */ + unsigned long w_saved; /* how many windows saved in reg_window[] */ + unsigned long ksp; /* kernel stack pointer */ + unsigned long usp; /* user's sp, throw reg windows here */ + unsigned long psr; /* save for condition codes */ + unsigned long reg_window[16*24]; + unsigned long cr3; /* why changed from ptbr? */ + unsigned int pcc; + unsigned int asn; + unsigned long unique; + unsigned long flags; + unsigned long res1, res2; + unsigned long pc; /* program counter */ + unsigned long npc; /* next program counter */ + +/* 8 local registers + 8 in registers * 24 register windows. + * Most sparcs I know of only have 8 windows implemented, + * we determine how many at boot time and store that value + * in nwindows. + */ + unsigned long globl_regs[8]; /* global regs need to be saved too */ + unsigned long yreg; + unsigned long float_regs[64]; /* V8 and below have 32, V9 has 64 */ +}; + +#define INIT_MMAP { &init_task, 0x0, 0x40000000, \ + PAGE_SHARED , VM_READ | VM_WRITE | VM_EXEC } + +#define INIT_TSS { \ + 0, 0, 0, 0, 0, 0, \ + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + { 0, 0, 0, 0, 0, 0, 0, 0, }, \ + 0, \ + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, \ +} + +/* The thread_frame is what needs to be set up in certain circumstances + * upon entry to a trap. It is also loaded sometimes during a window + * spill if things don't go right (bad user stack pointer). In reality + * it is not per-process per se, it just sits in the kernel stack while + * the current process is in a handler then it is basically forgotten + * about. + */ + +struct thread_frame { + unsigned int thr_psr; + unsigned int thr_pc; + unsigned int thr_npc; + unsigned int thr_y; + unsigned int thr_globals[8]; + unsigned int thr_outs[8]; +}; + +/* + * These are the "cli()" and "sti()" for software interrupts + * They work by increasing/decreasing the "intr_count" value, + * and as such can be nested arbitrarily. + */ +extern inline void start_bh_atomic(void) +{ + unsigned long dummy, psr; + __asm__ __volatile__("rd %%psr, %2\n\t" + "wr %2, 0x20, %%psr\n\t" /* disable traps */ + "ld %1,%0\n\t" + "add %0,1,%0\n\t" + "st %0,%1\n\t" + "wr %2, 0x0, %%psr\n\t" /* enable traps */ + : "=r" (dummy), "=m" (intr_count) + : "0" (0), "r" (psr=0)); +} + +extern inline void end_bh_atomic(void) +{ + unsigned long dummy, psr; + __asm__ __volatile__("rd %%psr, %2\n\t" + "wr %2, 0x20, %%psr\n\t" + "ld %1,%0\n\t" + "sub %0,1,%0\n\t" + "st %0,%1\n\t" + "wr %2, 0x0, %%psr\n\t" + : "=r" (dummy), "=m" (intr_count) + : "0" (0), "r" (psr=0)); +} + +#endif /* __ASM_SPARC_PROCESSOR_H */ + diff --git a/include/asm-sparc/psr.h b/include/asm-sparc/psr.h new file mode 100644 index 000000000..60b9757ad --- /dev/null +++ b/include/asm-sparc/psr.h @@ -0,0 +1,99 @@ +/* psr.h: This file holds the macros for masking off various parts of + the processor status register on the Sparc. This is valid + for Version 8. On the V9 this is renamed to the PSTATE + register and its members are accessed as fields like + PSTATE.PRIV for the current CPU privilege level. + + Copyright (C) 1994 David S. Miller (davem@caip.rutgers.edu) +*/ + +#ifndef __LINUX_SPARC_PSR_H +#define __LINUX_SPARC_PSR_H + +#define __LINUX_SPARC_V8 /* duh */ + +#ifdef __LINUX_SPARC_V8 + +/* The Sparc PSR fields are laid out as the following: + + ------------------------------------------------------------------------ + | impl | vers | icc | resv | EC | EF | PIL | S | PS | ET | CWP | +bits| 31-28 | 27-24 | 23-20 | 19-14 | 13 | 12 | 11-8 | 7 | 6 | 5 | 4-0 | + ------------------------------------------------------------------------ + + The PSR can only be directly be written/read by the privileged instructions + 'rd' and 'wr'. Certain fields are changed as a side effect due to the 'Ticc', + 'save', 'restore', and 'rett' instructions. Also the integer condition codes + 'icc' are modified by various arithmetic instructions. + + For example: wr %o2, or'd_bit_pattern, %psr + rd %psr, %o3 + +*/ + +#define PSR_CWP 0x0000001f /* current window pointer */ +#define PSR_ET 0x00000020 /* enable traps field */ +#define PSR_PS 0x00000040 /* previous privilege level */ +#define PSR_S 0x00000080 /* current privilege level */ +#define PSR_PIL 0x00000f00 /* processor interrupt level */ +#define PSR_EF 0x00001000 /* enable floating point */ +#define PSR_EC 0x00002000 /* enable co-processor */ +#define PSR_ICC 0x00f00000 /* integer condition codes */ +#define PSR_C 0x00100000 /* carry bit */ +#define PSR_V 0x00200000 /* overflow bit */ +#define PSR_Z 0x00400000 /* zero bit */ +#define PSR_N 0x00800000 /* negative bit */ +#define PSR_VERS 0x0f000000 /* cpu-version field */ +#define PSR_IMPL 0xf0000000 /* cpu-implementation field */ + +#endif /* !(__LINUX_SPARC_V8) */ + +#ifdef __LINUX_SPARC_V9 + +/* The information available in the %psr on the V8 is spread amongst + a whole bunch of registers on the V9. The main one being PSTATE. + + -------------------------------------------------------- + | CLE | TLE | MM | RED | PEF | AM | PRIV | IE | AG | +bits | 9 | 8 | 7-6 | 5 | 4 | 3 | 2 | 1 | 0 | + -------------------------------------------------------- + + Writes and reads to PSTATE are done via 'wrpr' and 'rdpr' instructions. + + For example: wrpr %o2, or'd_bit_pattern, %pstate + rdpr %pstate, %o3 +*/ + +#define PSTATE_AG 0x001 /* Alternate Globals */ +#define PSTATE_IE 0x002 /* Interrupt Enable */ +#define PSTATE_PRIV 0x004 /* Current privilege level */ +#define PSTATE_AM 0x008 /* Address mask (data reads can */ + /* be chosen to be either big or */ + /* little endian on V9). */ +#define PSTATE_PEF 0x010 /* enable floating point */ +#define PSTATE_RED 0x020 /* RED trap state (set if trap */ + /* trap_level == max_tl). */ +#define PSTATE_MM 0x0c0 /* Memory model (Total Store */ + /* Order=0, Partial Store Order */ + /* =1 or Relaxed Memory Order=2) */ +#define PSTATE_TLE 0x100 /* Trap Little Endian */ +#define PSTATE_CLE 0x200 /* Current Little Endian */ + + +/* The Version Register holds vendor information for the chip: + + --------------------------------------------------------------------------- + | manufacturer | implementation | mask | reserved | maxtl | resv | maxwin | +bits| 63-48 | 47-32 | 31-24| 23-16 | 15-8 | 7-5 | 4-0 | + --------------------------------------------------------------------------- + +*/ + +#define VERS_MAXWIN 0x000000000000001f /* 'nwindows' on this chip */ +#define VERS_MAXTL 0x00000000000ff000 /* Maximum Trap-level supported */ +#define VERS_MASK 0x0000000ff0000000 /* impl. dep. chip mask revision */ +#define VERS_MANUF 0xffff000000000000 /* Manufacturer ID code */ + +#endif /* !(__LINUX_SPARC_V9) */ + +#endif /* !(__LINUX_SPARC_PSR_H) */ diff --git a/include/asm-sparc/ptrace.h b/include/asm-sparc/ptrace.h new file mode 100644 index 000000000..70fb8d5df --- /dev/null +++ b/include/asm-sparc/ptrace.h @@ -0,0 +1,32 @@ +#ifndef _SPARC_PTRACE_H +#define _SPARC_PTRACE_H + +/* I have not looked enough into how this should be done. Without playing + * lots of tricks to optimize I think we need to save the whole register + * window frame plus the floating-point registers. We'll see... + */ + +/* this struct defines the way the registers are stored on the + stack during a system call. */ + +struct pt_regs { + unsigned long ps; /* previous supervisor, same as alpha I believe */ + unsigned long pc; /* current and next program counter */ + unsigned long npc; + unsigned long sp; /* stack and frame pointer */ + unsigned long fp; + unsigned long psr; /* for condition codes */ + unsigned long nuwin; /* number of user windows */ + /* not sure yet whether all regs are necessary + * but this is how it is traditionally done on the sparc. + */ + unsigned long u_regs[24*16]; + unsigned long f_regs[64]; /* yuck yuck yuck */ +}; + +#ifdef __KERNEL__ +#define user_mode(regs) (0x0) /* if previous supervisor is 0, came from user */ +extern void show_regs(struct pt_regs *); +#endif + +#endif diff --git a/include/asm-sparc/segment.h b/include/asm-sparc/segment.h new file mode 100644 index 000000000..27489b3e5 --- /dev/null +++ b/include/asm-sparc/segment.h @@ -0,0 +1,87 @@ +#ifndef _ASM_SEGMENT_H +#define _ASM_SEGMENT_H + +#define KERNEL_CS 0x0 +#define KERNEL_DS 0x0 + +#define USER_CS 0x1 +#define USER_DS 0x1 + +#include <linux/string.h> +#include <asm/vac-ops.h> + +static inline unsigned char get_user_byte(const char * addr) +{ + return *addr; +} + +#define get_fs_byte(addr) get_user_byte((char *)(addr)) + +static inline unsigned short get_user_word(const short *addr) +{ + return *addr; +} + +#define get_fs_word(addr) get_user_word((short *)(addr)) + +static inline unsigned long get_user_long(const int *addr) +{ + return *addr; +} + +#define get_fs_long(addr) get_user_long((int *)(addr)) + +static inline unsigned long get_user_quad(const long *addr) +{ + return *addr; +} + +#define get_fs_quad(addr) get_user_quad((long *)(addr)) + +static inline void put_user_byte(char val,char *addr) +{ + *addr = val; +} + +#define put_fs_byte(x,addr) put_user_byte((x),(char *)(addr)) + +static inline void put_user_word(short val,short * addr) +{ + *addr = val; +} + +#define put_fs_word(x,addr) put_user_word((x),(short *)(addr)) + +static inline void put_user_long(unsigned long val,int * addr) +{ + *addr = val; +} + +#define put_fs_long(x,addr) put_user_long((x),(int *)(addr)) + +static inline void put_user_quad(unsigned long val,long * addr) +{ + *addr = val; +} + +#define put_fs_quad(x,addr) put_user_quad((x),(long *)(addr)) + +#define memcpy_fromfs(to, from, n) memcpy((to),(from),(n)) + +#define memcpy_tofs(to, from, n) memcpy((to),(from),(n)) + +static inline unsigned long get_fs(void) +{ + return 0; +} + +static inline unsigned long get_ds(void) +{ + return 0; +} + +static inline void set_fs(unsigned long val) +{ +} + +#endif /* _ASM_SEGMENT_H */ diff --git a/include/asm-sparc/signal.h b/include/asm-sparc/signal.h new file mode 100644 index 000000000..2e599e18d --- /dev/null +++ b/include/asm-sparc/signal.h @@ -0,0 +1,11 @@ +#ifndef _ASMSPARC_SIGNAL_H +#define _ASMSPARC_SIGNAL_H + +struct sigcontext_struct { + /* + * Have to find out what SUNOS and Solaris do. This could + * get real ugly. David S. Miller (davem@caip.rutgers.edu) + */ +}; + +#endif diff --git a/include/asm-sparc/string.h b/include/asm-sparc/string.h new file mode 100644 index 000000000..6e0bfc1f7 --- /dev/null +++ b/include/asm-sparc/string.h @@ -0,0 +1,367 @@ +/* string.h: External definitions for optimized assembly string + routines for the Linux Kernel. + + Copyright (C) 1994 David S. Miller (davem@caip.rutgers.edu) +*/ + +extern inline size_t strlen(const char * str) +{ + register size_t retval = 0; + register char tmp = 0; + register char * lstr; + + lstr = (char *) str; + + __asm__("ldub [%1], %2\n\t" + "or %%g0, %%g0, %0\n\t" + "orcc %2, %%g0, %%g0\n\t" + "be 2f\n\t" + "add %1, 0x1, %1\n\t" + "1: ldub [%1], %2\n\t" + "add %0, 0x1, %0\n\t" + "orcc %2, %%g0, %%g0\n\t" + "bne 1b\n\t" + "add %1, 0x1, %1\n\t" + "2:" : + "=r" (retval), "=r" (lstr), "=r" (tmp) : + "0" (retval), "1" (lstr), "2" (tmp)); + + return retval; +} + +extern __inline__ int strcmp(const char* str1, const char* str2) +{ + register unsigned int tmp1=0, tmp2=0; + register int retval=0; + + __asm__("ldub [%1], %3\n\t" + "ldub [%2], %4\n\t" + "1: add %2, 0x1, %2\n\t" + "cmp %3, %4\n\t" + "bne,a 2f\n\t" + "sub %2, 0x1, %2\n\t" + "ldub [%1], %3\n\t" + "add %1, 0x1, %1\n\t" + "cmp %3, 0x0\n\t" + "bne,a 1b\n\t" + "ldub [%2], %4\n\t" + "b 3f\n\t" + "or %%g0, %%g0, %0\n\t" + "2: ldub [%1], %3\n\t" + "ldub [%2], %4\n\t" + "sub %3, %4, %0\n\t" + "3: \n\t" : + "=r" (retval), "=r" (str1), "=r" (str2), "=r" (tmp1), "=r" (tmp2) : + "0" (retval), "1" (str1), "2" (str2), + "3" (tmp1), "4" (tmp2)); + + return retval; +} + +extern __inline__ int strncmp(const char* str1, const char* str2, size_t strlen) +{ + register int retval=0; + + __asm__("cmp %3, 0x0\n\t" + "be 2f\n\t" + "ldub [%2], %%g3\n\t" + "1: ldub [%1], %%g2\n\t" + "sub %%g2, %%g3, %0\n\t" + "cmp %0, 0x0\n\t" + "bne 2f\n\t" + "add %2, 0x1, %2\n\t" + "cmp %%g2, 0x0\n\t" + "be 2f\n\t" + "add %1, 0x1, %1\n\t" + "addcc %3, -1, %3\n\t" + "bne,a 1b\n\t" + "ldub [%2], %%g3\n\t" + "2: " : + "=r" (retval), "=r" (str1), "=r" (str2), "=r" (strlen) : + "0" (retval), "1" (str1), "2" (str2), "3" (strlen) : + "%g2", "%g3"); + + return retval; +} + + +extern __inline__ char *strcpy(char* dest, const char* source) +{ + register char tmp; + register char *retval; + + __asm__("or %%g0, %2, %0\n\t" + "ldub [%1], %3\n\t" + "1: stb %3, [%2]\n\t" + "cmp %3, 0x0\n\t" + "bne,a 1b\n\t" + "ldub [%1], %3\n\t" : + "=r" (retval), "=r" (source), "=r" (dest), "=r" (tmp) : + "0" (retval), "1" (source), "2" (dest), "3" (tmp)); + + return retval; +} + +extern __inline__ char *strncpy(char *dest, const char *source, size_t cpylen) +{ + register char tmp; + register char *retval; + + __asm__("or %%g0, %1, %0\n\t" + "1: cmp %4, 0x0\n\t" + "be 2f\n\t" + "ldub [%1], %3\n\t" + "add %1, 0x1, %1\n\t" + "stb %3, [%2]\n\t" + "sub %4, 0x1, %4\n\t" + "ba 1\n\t" + "add %2, 0x1, %2\n\t" : + "=r" (retval), "=r" (dest), "=r" (source), "=r"(tmp), "=r" (cpylen) : + "0" (retval), "1" (dest), "2" (source), + "3" (tmp), "4" (cpylen)); + + return retval; +} + +extern __inline__ char *strcat(char *dest, const char *src) +{ + register char *retval; + register char temp=0; + + __asm__("or %%g0, %1, %0\n\t" + "1: ldub [%1], %3\n\t" + "cmp %3, 0x0\n\t" + "bne,a 1b\n\t" + "add %1, 0x1, %1\n\t" + "2: ldub [%2], %3\n\t" + "stb %3, [%1]\n\t" + "add %1, 0x1, %1\n\t" + "cmp %3, 0x0\n\t" + "bne 2b\n\t" + "add %2, 0x1, %2\n\t" : + "=r" (retval), "=r" (dest), "=r" (src), "=r" (temp) : + "0" (retval), "1" (dest), "2" (src), "3" (temp)); + + return retval; +} + +extern __inline__ char *strncat(char *dest, const char *src, size_t len) +{ + register char *retval; + register char temp=0; + + __asm__("or %%g0, %1, %0\n\t" + "1: ldub [%1], %3\n\t" + "cmp %3, 0x0\n\t" + "bne,a 1b\n\t" + "add %1, 0x1, %1\n\t" + "2: ldub [%2], %3\n\t" + "stb %3, [%1]\n\t" + "add %1, 0x1, %1\n\t" + "add %3, -1, %3\n\t" + "cmp %3, 0x0\n\t" + "bne 2b\n\t" + "add %2, 0x1, %2\n\t" : + "=r" (retval), "=r" (dest), "=r" (src), "=r" (len), "=r" (temp) : + "0" (retval), "1" (dest), "2" (src), "3" (len), "4" (temp)); + + return retval; +} + +extern __inline__ char *strchr(const char *src, int c) +{ + register char temp=0; + register char *trick=0; + + __asm__("1: ldub [%0], %2\n\t" + "cmp %2, %1\n\t" + "bne,a 1b\n\t" + "add %0, 0x1, %0\n\t" + "or %%g0, %0, %3\n\t" : + "=r" (src), "=r" (c), "=r" (temp), "=r" (trick), "=r" (src) : + "0" (src), "1" (c), "2" (temp), "3" (trick), "4" (src)); + + return trick; +} + +extern __inline__ char *strpbrk(const char *cs, const char *ct) +{ + register char temp1, temp2; + register char *scratch; + register char *trick; + + __asm__("or %%g0, %1, %4\n\t" + "1: ldub [%0], %2\n\t" + "2: ldub [%1], %3\n\t" + "cmp %3, %2\n\t" + "be 3f\n\t" + "nop\n\t" + "cmp %3, 0x0\n\t" + "bne 2b\n\t" + "add %1, 0x1, %1\n\t" + "or %%g0, %4, %1\n\t" + "b 1b\n\t" + "add %0, 0x1, %0\n\t" + "or %%g0, %0, %5\n\t" : + "=r" (cs) : + "r" (ct), "r" (temp1), "r" (temp2), "r" (scratch), "r" (trick=0), + "0" (cs), "1" (ct)); + + return trick; + +} + + +extern __inline__ size_t strspn(const char *s, const char *accept) +{ + register char temp1, temp2; + register char* scratch; + register size_t trick; + + __asm__("or %%g0, %1, %4\n\t" + "1: ldub [%0], %2\n\t" + "2: ldub [%1], %3\n\t" + "cmp %3, 0x0\n\t" + "be 3f\n\t" + "cmp %3, %2" + "bne 2b\n\t" + "add %1, 0x1, %1\n\t" + "add %0, 0x1, %0\n\t" + "b 1b\n\t" + "add %5, 0x1, %5\n\t" + "3: or %%g0, %0, %4\n\t" : + "=r" (s) : + "r" (accept), "r" (temp1), "r" (temp2), + "r" (scratch), "r" (trick=0), "0" (s)); + + return trick; + +} + +extern __inline__ char *strtok(char *s, const char *ct) +{ + static char* old; /* frob this kludge for now */ + register char *tok; + + if (s == (char *) 0) + { + if (old == (char *) 0) + { + return (char *) 0; + } + else + s = old; + } + + s += strspn(s, ct); + if(*s == '\0') + { + old = (char *) 0; + return (char *) 0; + } + + tok = s; + s = strpbrk(tok, ct); + if (s == (char *) 0) + old = (char *) 0; + else + { + *s = '\0'; + old = s + 1; + } + return tok; +} + + +extern __inline__ void *memset(void *src, int c, size_t count) +{ + register void *retval; + + __asm__("or %%g0, %1, %0\n\t" + "1: add %1, 0x1, %1\n\t" + "2: add %3, -1, %3\n\t" + "cmp %3, -1\n\t" + "bne,a 1b\n\t" + "stb %2, [%1]\n\t" : + "=r" (retval), "=r" (src), "=r" (c), "=r" (count) : + "0" (retval), "1" (src), "2" (c), "3" (count)); + + return retval; +} + +extern __inline__ void *memcpy(void *dest, const void *src, size_t count) +{ + register void *retval; + register char tmp; + + __asm__("or %%g0, %1, %0\n\t" + "add %3, -1, %3\n\t" + "cmp %3, -1\n\t" + "be 2f\n\t" + "1: ldub [%2], %4\n\t" + "add %2, 0x1, %2\n\t" + "add %3, -1, %3\n\t" + "cmp %3, -1\n\t" + "stb %4, [%1]\n\t" + "bne 1b\n\t" + "add %1, 0x1, %1\n\t" + "2: " : + "=r" (retval), "=r" (dest), "=r" (src), "=r" (count), "=r" (tmp) : + "0" (retval), "1" (dest), "2" (src), "3" (count), "4" (tmp)); + + return retval; +} + +extern __inline__ void *memmove(void *dest, const void *src, size_t count) +{ + register void *retval; + register char tmp; + + __asm__("or %%g0, %1, %1\n\t" + "add %3, -1, %3\n\t" + "cmp %3, -1\n\t" + "be 2f\n\t" + "1: ldub [%2], %4\n\t" + "add %2, 0x1, %2\n\t" + "add %3, -1, %3\n\t" + "cmp %3, -1\n\t" + "stb %4, [%1]\n\t" + "bne 1b\n\t" + "add %1, 0x1, %1\n\t" + "2: " : + "=r" (retval), "=r" (dest), "=r" (src), "=r" (count), "=r" (tmp) : + "0" (retval), "1" (dest), "2" (src), "3" (count), "4" (tmp)); + + return retval; +} + +extern __inline__ int memcmp(const void *cs, const void *ct, size_t count) +{ + register int retval; + register unsigned long tmp1, tmp2; + + __asm__("or %%g0, %1, %0\n\t" + "cmp %3, 0x0\n\t" + "ble,a 3f\n\t" + "or %%g0, %%g0, %0\n\t" + "1: ldub [%1], %4\n\t" + "ldub [%2], %5\n\t" + "cmp %4, %5\n\t" + "be,a 2f\n\t" + "add %1, 0x1, %1\n\t" + "bgeu 3f\n\t" + "or %%g0, 0x1, %0\n\t" + "b 3f\n\t" + "or %%g0, -1, %0\n\t" + "2: add %3, -1, %3\n\t" + "cmp %3, 0x0\n\t" + "bg 1b\n\t" + "add %2, 0x1, %2\n\t" + "or %%g0, %%g0, %0\n\t" + "3: " : + "=r" (retval) : + "r" (cs), "r" (ct), "r" (count), "r" (tmp1=0), "r" (tmp2=0)); + + return retval; +} + diff --git a/include/asm-sparc/sysen.h b/include/asm-sparc/sysen.h new file mode 100644 index 000000000..f72b40c67 --- /dev/null +++ b/include/asm-sparc/sysen.h @@ -0,0 +1,14 @@ +#ifndef _SPARC_SYSEN_H +#define _SPARC_SYSEN_H + +/* sysen.h: Bit fields within the "System Enable" register accessed via + the ASI_CONTROL address space at address AC_SYSENABLE. + + Copyright (C) 1994 David S. Miller (davem@caip.rutgers.edu) +*/ + +#define SENABLE_DVMA 0x20 /* enable dvma transfers */ +#define SENABLE_CACHE 0x10 /* enable VAC cache */ +#define SENABLE_RESET 0x04 /* reset the whole machine, danger Will Robinson */ + +#endif /* _SPARC_SYSEN_H */ diff --git a/include/asm-sparc/system.h b/include/asm-sparc/system.h new file mode 100644 index 000000000..3c4a62c9a --- /dev/null +++ b/include/asm-sparc/system.h @@ -0,0 +1,135 @@ +#ifndef __SPARC_SYSTEM_H +#define __SPARC_SYSTEM_H + +#include <asm/segment.h> + +/* + * System defines.. Note that this is included both from .c and .S + * files, so it does only defines, not any C code. + */ + +/* + * I wish the boot time image was as beautiful as the Alpha's + * but no such luck. The icky PROM loads us at 0x0, and jumps + * to magic address 0x4000 to start thing going. This means that + * I can stick the pcb and user/kernel stacks in the area from + * 0x0-0x4000 and be reasonably sure that this is sane. + * + * Sorry, I can't impress people with cool looking 64-bit values + * yet. ;-) + */ + +#include <asm/openprom.h> +#include <asm/psr.h> + +#define INIT_PCB 0x00011fe0 +#define INIT_STACK 0x00013fe0 +#define START_ADDR 0x00004000 +#define START_SIZE (32*1024) +#define EMPTY_PGT 0x00001000 +#define EMPTY_PGE 0x00001000 +#define ZERO_PGE 0x00001000 + +#define IRQ_ENA_ADR 0x2000 /* This is a bitmap of all activated IRQ's + * which is mapped in head.S during boot. + */ + +#ifndef __ASSEMBLY__ + +extern void wrent(void *, unsigned long); +extern void wrkgp(unsigned long); +extern struct linux_romvec *romvec; + +#define halt() { romvec->pv_halt(); } +#define move_to_user_mode() halt() +#define switch_to(x) halt() + +#ifndef stbar /* store barrier Sparc insn to synchronize stores in PSO */ +#define stbar() __asm__ __volatile__("stbar": : :"memory") +#endif + +/* Changing the PIL on the sparc is a bit hairy. I'll figure out some + * more optimized way of doing this soon. This is bletcherous code. + */ + +#define swpipl(__new_ipl) \ +({ unsigned long psr, retval; \ +__asm__ __volatile__( \ + "rd %%psr, %0\n\t" : "=&r" (psr)); \ +retval = psr; \ +psr = (psr & ~(PSR_PIL)); \ +psr |= ((__new_ipl << 8) & PSR_PIL); \ +__asm__ __volatile__( \ + "wr %0, 0x0, %%psr\n\t" \ + : : "r" (psr)); \ +retval = ((retval>>8)&15); \ +retval; }) + +#define cli() swpipl(15) /* 15 = no int's except nmi's */ +#define sti() swpipl(0) /* I'm scared */ +#define save_flags(flags) do { flags = swpipl(15); } while (0) +#define restore_flags(flags) swpipl(flags) + +#define iret() __asm__ __volatile__ ("jmp %%l1\n\t" \ + "rett %%l2\n\t": : :"memory") + +#define _set_gate(gate_addr,type,dpl,addr) \ +__asm__ __volatile__ ("nop\n\t") + +#define set_intr_gate(n,addr) \ + _set_gate(&idt[n],14,0,addr) + +#define set_trap_gate(n,addr) \ + _set_gate(&idt[n],15,0,addr) + +#define set_system_gate(n,addr) \ + _set_gate(&idt[n],15,3,addr) + +#define set_call_gate(a,addr) \ + _set_gate(a,12,3,addr) + + +extern inline unsigned int get_psr(void) +{ + unsigned int ret_val; + __asm__("rd %%psr, %0\n\t" : + "=r" (ret_val)); + return ret_val; +} + +extern inline void put_psr(unsigned int new_psr) +{ + __asm__("wr %0, 0x0, %%psr\n\t" : : + "r" (new_psr)); +} + +/* Must this be atomic? */ + +extern inline void *xchg_u32(int * m, unsigned long val) +{ + unsigned long dummy; + + __asm__ __volatile__( + "ld %1,%2 ! xchg_u32() is here\n\t" + "st %0, %1\n\t" + "or %%g0, %2, %0" + : "=r" (val), "=m" (*m), "=r" (dummy) + : "0" (val)); + return (void *) val; +} + + +/* pointers are 32 bits on the sparc (at least the v8, and they'll work + * on the V9 none the less). I don't need the xchg_u64 routine for now. + */ + +extern inline void *xchg_ptr(void *m, void *val) +{ + return (void *) xchg_u32((int *) m, (unsigned long) val); +} + + + +#endif /* __ASSEMBLY__ */ + +#endif diff --git a/include/asm-sparc/types.h b/include/asm-sparc/types.h new file mode 100644 index 000000000..c7b65be7a --- /dev/null +++ b/include/asm-sparc/types.h @@ -0,0 +1,64 @@ +#ifndef _SPARC_TYPES_H +#define _SPARC_TYPES_H + +/* + * _xx is ok: it doesn't pollute the POSIX namespace. Use these in the + * header files exported to user space <-- Linus sez this + */ + +/* NOTE: I will have to change these when the V9 sparcs come into play, + * however this won't be for a while. + */ + +#ifndef _SIZE_T +#define _SIZE_T +#ifdef __svr4__ +typedef unsigned int size_t; /* solaris sucks */ +#else +typedef long unsigned int size_t; /* sunos is much better */ +#endif /* !(__svr4__) */ +#endif + +#ifndef _SSIZE_T +#define _SSIZE_T +typedef int ssize_t; +#endif + +#ifndef _PTRDIFF_T +#define _PTRDIFF_T +typedef int ptrdiff_t; +#endif + +typedef signed char __s8; +typedef unsigned char __u8; + +typedef signed short __s16; +typedef unsigned short __u16; + +typedef signed int __s32; +typedef unsigned int __u32; + +/* Only 32-bit sparcs for now so.... */ + +typedef signed long long __s64; +typedef unsigned long long __u64; + +#ifdef __KERNEL__ + +typedef signed char s8; +typedef unsigned char u8; + +typedef signed short s16; +typedef unsigned short u16; + +typedef signed int s32; +typedef unsigned int u32; + +/* Again, only have to worry about 32-bits */ + +typedef signed long long s64; +typedef unsigned long long u64; + +#endif /* __KERNEL__ */ + +#endif /* defined(_SPARC_TYPES_H) */ diff --git a/include/asm-sparc/unistd.h b/include/asm-sparc/unistd.h new file mode 100644 index 000000000..3b0551461 --- /dev/null +++ b/include/asm-sparc/unistd.h @@ -0,0 +1,163 @@ +#ifndef _SPARC_UNISTD_H +#define _SPARC_UNISTD_H + +/* + * System calls under the Sparc. + * + * Don't be scared by the ugly clobbers, it is the only way I can + * think of right now to force the arguments into fixed registers + * before the trap into the system call with gcc 'asm' statements. + * + * Copyright (C) 1994 David S. Miller (davem@caip.rutgers.edu) + */ + +/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */ +#define _syscall0(type,name) \ +type name(void) \ +{ \ +long __res; \ +__asm__ volatile ("or %%g0, %0, %%o0\n\t" \ + "t 0xa\n\t" \ + : "=r" (__res) \ + : "0" (__NR_##name) \ + : "o0"); \ +if (__res >= 0) \ + return (type) __res; \ +errno = -__res; \ +return -1; \ +} + +#define _syscall1(type,name,type1,arg1) \ +type name(type1 arg1) \ +{ \ +long __res; \ +__asm__ volatile ("or %%g0, %0, %%o0\n\t" \ + "or %%g0, %1, %%o1\n\t" \ + "t 0xa\n\t" \ + : "=r" (__res), "=r" ((long)(arg1)) \ + : "0" (__NR_##name),"1" ((long)(arg1)) \ + : "o0", "o1"); \ +if (__res >= 0) \ + return (type) __res; \ +errno = -__res; \ +return -1; \ +} + +#define _syscall2(type,name,type1,arg1,type2,arg2) \ +type name(type1 arg1,type2 arg2) \ +{ \ +long __res; \ +__asm__ volatile ("or %%g0, %0, %%o0\n\t" \ + "or %%g0, %1, %%o1\n\t" \ + "or %%g0, %2, %%o2\n\t" \ + "t 0xa\n\t" \ + : "=r" (__res), "=r" ((long)(arg1)), "=r" ((long)(args)) \ + : "0" (__NR_##name),"1" ((long)(arg1)),"2" ((long)(arg2)) \ + : "o0", "o1", "o2"); \ +if (__res >= 0) \ + return (type) __res; \ +errno = -__res; \ +return -1; \ +} + +#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \ +type name(type1 arg1,type2 arg2,type3 arg3) \ +{ \ +long __res; \ +__asm__ volatile ("or %%g0, %0, %%o0\n\t" \ + "or %%g0, %1, %%o1\n\t" \ + "or %%g0, %2, %%o2\n\t" \ + "or %%g0, %3, %%o3\n\t" \ + "t 0xa\n\t" \ + : "=r" (__res), "=r" ((long)(arg1)), "=r" ((long)(arg2)), \ + "=r" ((long)(arg3)) \ + : "0" (__NR_##name), "1" ((long)(arg1)), "2" ((long)(arg2)), \ + "3" ((long)(arg3)) \ + : "o0", "o1", "o2", "o3"); \ +if (__res>=0) \ + return (type) __res; \ +errno=-__res; \ +return -1; \ +} + +#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \ +type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \ +{ \ +long __res; \ +__asm__ volatile ("or %%g0, %0, %%o0\n\t" \ + "or %%g0, %1, %%o1\n\t" \ + "or %%g0, %2, %%o2\n\t" \ + "or %%g0, %3, %%o3\n\t" \ + "or %%g0, %4, %%o4\n\t" \ + "t 0xa\n\t" \ + : "=r" (__res), "=r" ((long)(arg1)), "=r" ((long)(arg2)), \ + "=r" ((long)(arg3)), "=r" ((long)(arg4)) \ + : "0" (__NR_##name),"1" ((long)(arg1)),"2" ((long)(arg2)), \ + "3" ((long)(arg3)),"4" ((long)(arg4)) \ + : "o0", "o1", "o2", "o3", "o4"); \ +if (__res>=0) \ + return (type) __res; \ +errno=-__res; \ +return -1; \ +} + +#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ + type5,arg5) \ +type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \ +{ \ +long __res; \ +__asm__ volatile ("or %%g0, %0, %%o0\n\t" \ + "or %%g0, %1, %%o1\n\t" \ + "or %%g0, %2, %%o2\n\t" \ + "or %%g0, %3, %%o3\n\t" \ + "or %%g0, %4, %%o4\n\t" \ + "or %%g0, %5, %%o5\n\t" \ + "t 0xa\n\t" \ + : "=r" (__res), "=r" ((long)(arg1)), "=r" ((long)(arg2)), \ + "=r" ((long)(arg3)), "=r" ((long)(arg4)), "=r" ((long)(arg5)) \ + : "0" (__NR_##name),"1" ((long)(arg1)),"2" ((long)(arg2)), \ + "3" ((long)(arg3)),"4" ((long)(arg4)),"5" ((long)(arg5)) \ + : "o0", "o1", "o2", "o3", "o4", "o5"); \ +if (__res>=0) \ + return (type) __res; \ +errno=-__res; \ +return -1; \ +} + +#ifdef __KERNEL_SYSCALLS__ + +/* + * we need this inline - forking from kernel space will result + * in NO COPY ON WRITE (!!!), until an execve is executed. This + * is no problem, but for the stack. This is handled by not letting + * main() use the stack at all after fork(). Thus, no function + * calls - which means inline code for fork too, as otherwise we + * would use the stack upon exit from 'fork()'. + * + * Actually only pause and fork are needed inline, so that there + * won't be any messing with the stack from main(), but we define + * some others too. + */ +#define __NR__exit __NR_exit +static inline _syscall0(int,idle) +static inline _syscall0(int,fork) +static inline _syscall0(int,pause) +static inline _syscall0(int,setup) +static inline _syscall0(int,sync) +static inline _syscall0(pid_t,setsid) +static inline _syscall3(int,write,int,fd,const char *,buf,off_t,count) +static inline _syscall1(int,dup,int,fd) +static inline _syscall3(int,execve,const char *,file,char **,argv,char **,envp) +static inline _syscall3(int,open,const char *,file,int,flag,int,mode) +static inline _syscall1(int,close,int,fd) +static inline _syscall1(int,_exit,int,exitcode) +static inline _syscall3(pid_t,waitpid,pid_t,pid,int *,wait_stat,int,options) + +static inline pid_t wait(int * wait_stat) +{ + return waitpid(-1,wait_stat,0); +} + +#endif + +#endif /* _SPARC_UNISTD_H */ diff --git a/include/asm-sparc/vac-ops.h b/include/asm-sparc/vac-ops.h new file mode 100644 index 000000000..18755e048 --- /dev/null +++ b/include/asm-sparc/vac-ops.h @@ -0,0 +1,89 @@ +#ifndef _SPARC_VAC_OPS_H +#define _SPARC_VAC_OPS_H + +/* vac-ops.h: Inline assembly routines to do operations on the Sparc + VAC (virtual address cache). + + Copyright (C) 1994, David S. Miller (davem@caip.rutgers.edu) +*/ + +extern unsigned long *trapbase; +extern char end, etext, msgbuf; + +extern void flush_vac_context(void); +extern void flush_vac_segment(unsigned int foo_segment); +extern void flush_vac_page(unsigned int foo_addr); + +extern int vac_do_hw_vac_flushes, vac_size, vac_linesize; +extern int vac_entries_per_context, vac_entries_per_segment; +extern int vac_entries_per_page; + +/* enable_vac() enables the virtual address cache. It returns 0 on + success, 1 on failure. +*/ + +extern __inline__ int enable_vac(void) +{ + int success=0; + + __asm__ __volatile__("lduba [%1] 2, %0\n\t" + "or %0, 0x10, %0\n\t" + "stba %0, [%1] 2\n\t" + "or %%g0, %%g0, %0" : + "=r" (success) : + "r" ((unsigned int) 0x40000000), + "0" (success)); + return success; +} + +/* disable_vac() disables the virtual address cache. It returns 0 on + success, 1 on failure. +*/ + +extern __inline__ int disable_vac(void) +{ + int success=0; + + __asm__ __volatile__("lduba [%1] 0x2, %0\n\t" + "xor %0, 0x10, %0\n\t" + "stba %0, [%1] 0x2\n\t" + "or %%g0, %%g0, %0" : + "=r" (success) : + "r" (0x40000000), + "0" (success)); + return success; +} + +/* Various one-shot VAC entry flushes on the Sparc */ + +extern __inline__ void hw_flush_vac_context_entry(char* addr) +{ + __asm__ __volatile__("sta %%g0, [%0] 0x7" : : "r" (addr)); +} + +extern __inline__ void sw_flush_vac_context_entry(char* addr) +{ + __asm__ __volatile__("sta %%g0, [%0] 0xe" : : "r" (addr)); +} + +extern __inline__ void hw_flush_vac_segment_entry(char* addr) +{ + __asm__ __volatile__("sta %%g0, [%0] 0x5" : : "r" (addr)); +} + +extern __inline__ void sw_flush_vac_segment_entry(char* addr) +{ + __asm__ __volatile__("sta %%g0, [%0] 0xc" : : "r" (addr)); +} + +extern __inline__ void hw_flush_vac_page_entry(unsigned long* addr) +{ + __asm__ __volatile__("sta %%g0, [%0] 0x6" : : "r" (addr)); +} + +extern __inline__ void sw_flush_vac_page_entry(unsigned long* addr) +{ + __asm__ __volatile__("sta %%g0, [%0] 0xd" : : "r" (addr)); +} + +#endif /* !(_SPARC_VAC_OPS_H) */ diff --git a/include/asm-sparc/vaddrs.h b/include/asm-sparc/vaddrs.h new file mode 100644 index 000000000..7df443103 --- /dev/null +++ b/include/asm-sparc/vaddrs.h @@ -0,0 +1,16 @@ +#ifndef _SPARC_VADDRS_H +#define _SPARC_VADDRS_H + +/* asm-sparc/vaddrs.h: Here will be define the virtual addresses at + * which important I/O addresses will be mapped. + * For instance the timer register virtual address + * is defined here. + * + * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) + */ + +#define TIMER_VADDR 0x3000 /* Next page after where the interrupt enable + * register gets mapped at boot. + */ + +#endif /* !(_SPARC_VADDRS_H) */ diff --git a/include/asm-sparc/version.h b/include/asm-sparc/version.h new file mode 100644 index 000000000..0c238e9cf --- /dev/null +++ b/include/asm-sparc/version.h @@ -0,0 +1 @@ +#define WHO_COMPILED_ME "someone@somewhere.domain" diff --git a/include/asm-sparc/wim.h b/include/asm-sparc/wim.h new file mode 100644 index 000000000..74b0a65a9 --- /dev/null +++ b/include/asm-sparc/wim.h @@ -0,0 +1,56 @@ +/* wim.h: Defines the layout of the "Window Invalid Register" on + Version 8 of the Sparc Architecture. + + Copyright (C) 1994 David S. Miller (davem@caip.rutgers.edu) +*/ + +#ifndef __LINUX_SPARC_WIM_H +#define __LINUX_SPARC_WIM_H + +#ifdef __LINUX_SPARC_V8 /* register doesn't exist on the V9 */ + +/* The Window Invalid Register %wim, holds a set of which register + windows are 'valid' at this point in time. + + ------------------------------------------------------------ + |W31|W30|W29|W28|W27|W26|W25|W24|W23|....|W5|W4|W3|W2|W1|W0| + ------------------------------------------------------------ + + Each register window on the chip gets one bit. If the bit is + set then the window is currently 'invalid' and hardware will + trap if that window is entered via a 'save', 'restore', or + 'rett' instruction. Privileged software is responsible for + updating this on trap fills/spills etc. Therefore if a 'save' + instruction is executed and it causes the Current Window + Pointer to equal a register window which has its bit set in + %wim we get a 'overflow' trap, a restore into such a register + invokes a window 'spill' trap. +*/ + +#define __LINUX_SPARC_HAS_WIM + +/* Macro to fine the %wim bit mask for the current window pointer */ +#define CWP_TO_WIM_MASK(cwp) (1<<(cwp)) + +/* Assembly version of above macro, 'cwp' and 'wimask' must be registers */ +#define ASM_CWP_TO_WIM_MASK(cwp,wimask) \ + or %g0, 0x1, wimask \ + sll wimask, cwp, wimask + +/* Assembly macro to find if the given window is set to invalid in the %wim. + Again 'window', 'result', and 'scratch' must be in registers. This leaves + a non-zero value in result if the window is indeed invalid. This routine + works because we keep exactly one window invalid at all times to maximize + register utilization, which means both kernel and user windows can be in + the register file at the same time in certain trap situations. +*/ +#define ASM_REG_WIN_INVAL(window,result,scratch) \ + rd %wim, result \ + or %g0, 0x1, scratch \ + sll scratch, window, scratch \ + and scratch, result, result + +#endif /* !(__LINUX_SPARC_V8) */ + +#endif /* !(__LINUX_SPARC_WIM_H) */ + diff --git a/include/linux/a.out.h b/include/linux/a.out.h index 4e1a815a2..ce141e011 100644 --- a/include/linux/a.out.h +++ b/include/linux/a.out.h @@ -43,6 +43,8 @@ enum machine_type { #endif /* skip a bunch so we don't run into any of sun's numbers */ M_386 = 100, + M_MIPS1 = 151, /* MIPS R3000/R3000 binary */ + M_MIPS2 = 152, /* MIPS R6000/R4000 binary */ }; #if !defined (N_MAGIC) diff --git a/include/linux/ax25.h b/include/linux/ax25.h new file mode 100644 index 000000000..f6bce2787 --- /dev/null +++ b/include/linux/ax25.h @@ -0,0 +1,39 @@ +#define PF_AX25 AF_AX25 +#define AX25_MTU 256 +#define AX25_MAX_DIGIS 8 + +typedef struct +{ + char ax25_call[7]; /* 6 call + SSID (shifted ascii!) */ +} +ax25_address; + +struct sockaddr_ax25 +{ + short sax25_family; + ax25_address sax25_call; + int sax25_ndigis; + /* Digipeater ax25_address sets follow */ +}; + +#define sax25_uid sax25_ndigis + +struct full_sockaddr_ax25 +{ + struct sockaddr_ax25 fsa_ax25; + ax25_address fsa_digipeater[AX25_MAX_DIGIS]; +}; + +#define AX25_WINDOW 1 +#define AX25_T1 2 +#define AX25_N2 3 +#define AX25_T3 4 +#define AX25_T2 5 + +#define SIOCAX25GETUID (SIOCPROTOPRIVATE) +#define SIOCAX25ADDUID (SIOCPROTOPRIVATE+1) +#define SIOCAX25DELUID (SIOCPROTOPRIVATE+2) +#define SIOCAX25NOUID (SIOCPROTOPRIVATE+3) + +#define AX25_NOUID_DEFAULT 0 +#define AX25_NOUID_BLOCK 1 diff --git a/include/linux/aztcd.h b/include/linux/aztcd.h new file mode 100644 index 000000000..b85f37ee8 --- /dev/null +++ b/include/linux/aztcd.h @@ -0,0 +1,120 @@ +/* $Id: aztcd.h,v 1.0 1995/03/25 08:27:19 root Exp $ + * Definitions for a AztechCD268 CD-ROM interface + * Copyright (C) 1994, 1995 Werner Zimmermann + * + * based on Mitsumi CDROM driver by Martin Harriss + * + * 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. + * + * History: W.Zimmermann adaption to Aztech CD268-01A Version 1.3 + * October 1994 Email: zimmerma@rz.fht-esslingen.de + */ + +/* *** change this to set the I/O port address */ +#define AZT_BASE_ADDR 0x320 + +/* Comment this out to prevent tray from locking */ +#define AZT_ALLOW_TRAY_LOCK 1 + +/* use incompatible ioctls for reading in raw and cooked mode */ +#define AZT_PRIVATE_IOCTLS + +/* Increase this if you get lots of timeouts; if you get kernel panic, replace + STEN_LOW_WAIT by STEN_LOW in the source code */ +#define AZT_STATUS_DELAY 400 /*for timer wait, STEN_LOW_WAIT*/ +#define AZT_TIMEOUT 8000000 /*for busy wait STEN_LOW, DTEN_LOW*/ +#define AZT_FAST_TIMEOUT 10000 /*for reading the version string*/ + +/* number of times to retry a command before giving up */ +#define AZT_RETRY_ATTEMPTS 3 + +/* port access macros */ +#define CMD_PORT azt_port +#define DATA_PORT azt_port +#define STATUS_PORT azt_port+1 +#define MODE_PORT azt_port+2 + +/* status bits */ +#define AST_CMD_CHECK 0x80 /* command error */ +#define AST_DSK_CHG 0x20 /* disk removed or changed */ +#define AST_NOT_READY 0x02 /* no disk in the drive */ +#define AST_DOOR_OPEN 0x40 /* door is open */ +#define AST_MODE_BITS 0x1C /* Mode Bits */ +#define AST_INITIAL 0x0C /* initial, only valid ... */ +#define AST_BUSY 0x04 /* now playing, only valid + in combination with mode + bits */ +/* flag bits */ +#define AFL_DATA 0x02 /* data available if low */ +#define AFL_STATUS 0x04 /* status available if low */ +#define AFL_OP_OK 0x01 /* OP_OK command correct*/ +#define AFL_PA_OK 0x02 /* PA_OK parameter correct*/ +#define AFL_OP_ERR 0x05 /* error in command*/ +#define AFL_PA_ERR 0x06 /* error in parameters*/ +#define POLLED 0x04 /* polled mode */ + +/* commands */ +#define ACMD_SOFT_RESET 0x10 /* reset drive */ +#define ACMD_PLAY_READ 0x20 /* read data track in cooked mode */ +#define ACMD_DATA_READ_RAW 0x21 /* reading in raw mode*/ +#define ACMD_SEEK_TO_LEADIN 0x31 /* seek to leadin track*/ +#define ACMD_GET_ERROR 0x40 /* get error code */ +#define ACMD_GET_STATUS 0x41 /* get status */ +#define ACMD_GET_Q_CHANNEL 0x50 /* read info from q channel */ +#define ACMD_EJECT 0x60 /* eject/open tray */ +#define ACMD_CLOSE 0x61 /* close tray */ +#define ACMD_LOCK 0x71 /* lock tray closed */ +#define ACMD_UNLOCK 0x72 /* unlock tray */ +#define ACMD_PAUSE 0x80 /* pause */ +#define ACMD_STOP 0x81 /* stop play */ +#define ACMD_PLAY_AUDIO 0x90 /* play audio track */ +#define ACMD_SET_VOLUME 0x93 /* set audio level */ +#define ACMD_GET_VERSION 0xA0 /* get firmware version */ +#define ACMD_SET_MODE 0xA1 /* set drive mode */ + +#define SET_TIMER(func, jifs) \ + delay_timer.expires = jifs; \ + delay_timer.function = (void *) func; \ + add_timer(&delay_timer); + +#define CLEAR_TIMER del_timer(&delay_timer) + +#define MAX_TRACKS 104 + +struct msf { + unsigned char min; + unsigned char sec; + unsigned char frame; +}; + +struct azt_Play_msf { + struct msf start; + struct msf end; +}; + +struct azt_DiskInfo { + unsigned char first; + unsigned char last; + struct msf diskLength; + struct msf firstTrack; +}; + +struct azt_Toc { + unsigned char ctrl_addr; + unsigned char track; + unsigned char pointIndex; + struct msf trackTime; + struct msf diskTime; +}; diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h index 10f639e78..832bde64c 100644 --- a/include/linux/binfmts.h +++ b/include/linux/binfmts.h @@ -45,9 +45,12 @@ extern int read_exec(struct inode *inode, unsigned long offset, 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 setup_arg_pages(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); +/* this eventually goes away */ +#define change_ldt(a,b) setup_arg_pages(a,b) + #endif diff --git a/include/linux/bios32.h b/include/linux/bios32.h index 4684186e5..ee8f862ea 100644 --- a/include/linux/bios32.h +++ b/include/linux/bios32.h @@ -22,24 +22,39 @@ #ifndef BIOS32_H #define BIOS32_H -unsigned long bios32_init(unsigned long memory_start, unsigned long memory_end); +/* + * Error values that may be returned by the PCI bios. Use + * pci_strbioserr() to convert to a printable string. + */ +#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 +#define PCIBIOS_SET_FAILED 0x88 +#define PCIBIOS_BUFFER_TOO_SMALL 0x89 -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 */ +extern unsigned long pcibios_init (unsigned long memory_start, + unsigned long memory_end); +extern unsigned long pcibios_fixup (unsigned long memory_start, + unsigned long memory_end); +extern int pcibios_find_class (unsigned int class_code, unsigned short index, + unsigned char *bus, unsigned char *dev_fn); +extern int pcibios_find_device (unsigned short vendor, unsigned short dev_id, + unsigned short index, unsigned char *bus, + unsigned char *dev_fn); +extern int pcibios_read_config_byte (unsigned char bus, unsigned char dev_fn, + unsigned char where, unsigned char *val); +extern int pcibios_read_config_word (unsigned char bus, unsigned char dev_fn, + unsigned char where, unsigned short *val); +extern int pcibios_read_config_dword (unsigned char bus, unsigned char dev_fn, + unsigned char where, unsigned int *val); +extern int pcibios_write_config_byte (unsigned char bus, unsigned char dev_fn, + unsigned char where, unsigned char val); +extern int pcibios_write_config_word (unsigned char bus, unsigned char dev_fn, + unsigned char where, unsigned short val); +extern pcibios_write_config_dword (unsigned char bus, unsigned char dev_fn, + unsigned char where, unsigned int val); +extern char *pcibios_strerror (int error); +#endif /* BIOS32_H */ diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 84b48d93c..1e0b17c81 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -44,4 +44,6 @@ extern int * blk_size[MAX_BLKDEV]; extern int * blksize_size[MAX_BLKDEV]; +extern int * hardsect_size[MAX_BLKDEV]; + #endif diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h index f7e7d7b5c..1cd8cbeda 100644 --- a/include/linux/cdrom.h +++ b/include/linux/cdrom.h @@ -334,6 +334,27 @@ struct cdrom_read_audio u_char *buf; /* frame buffer (size: nframes*2352 bytes) */ }; +/* + * this has to be the "arg" of the CDROMMULTISESSION ioctl + * for obtaining multi session info. + * The returned "addr" is valid only if "xa_flag" is true. + */ +struct cdrom_multisession + { + union + { + struct + { + u_char minute; + u_char second; + u_char frame; + } msf; + int lba; + } addr; /* frame address: start-of-last-session (not the new "frame 16"!)*/ + u_char xa_flag; /* 1: "is XA disk" */ + u_char addr_format; /* CDROM_LBA or CDROM_MSF */ + }; + #ifdef FIVETWELVE #define CDROM_MODE1_SIZE 512 #else @@ -387,6 +408,10 @@ struct cdrom_read_audio * (still may change if other drivers will use it, too): */ #define CDROMEJECT_SW 0x530f /* arg: 0 or 1 */ + +/* + * obtain the start-of-last-session address of multi session disks + */ +#define CDROMMULTISESSION 0x5310 /* (struct cdrom_multisession) */ #endif _LINUX_CDROM_H - diff --git a/include/linux/config.h b/include/linux/config.h index a22241e91..a54cdff20 100644 --- a/include/linux/config.h +++ b/include/linux/config.h @@ -9,12 +9,13 @@ #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 */ +#define UTS_MACHINE "unknown" +#endif + +#ifndef UTS_NODENAME +#define UTS_NODENAME "(none)" /* set by sethostname() */ #endif #ifndef UTS_DOMAINNAME @@ -37,55 +38,4 @@ #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/cyclades.h b/include/linux/cyclades.h new file mode 100644 index 000000000..73f01e26a --- /dev/null +++ b/include/linux/cyclades.h @@ -0,0 +1,257 @@ +struct cyclades_card { + int base_addr; + int irq; + int num_chips; /* implies card type, 0 if card is absent */ + int first_line; /* line number of first channel of first chip on card */ +}; + +struct cyclades_chip { + int filler; +}; + +struct cyclades_monitor { + unsigned long int_count; + unsigned long char_count; + unsigned long char_max; + unsigned long char_last; +}; + +/* + * 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 cyclades_port { + int magic; + int type; + int card; + int line; + int flags; /* defined in tty.h */ + struct tty_struct *tty; + int read_status_mask; + int timeout; + int xmit_fifo_size; + int cor1,cor2,cor3,cor4,cor5; + int tbpr,tco,rbpr,rco; + int ignore_status_mask; + int close_delay; + int IER; /* Interrupt Enable Register */ + int event; + unsigned long last_active; + int count; /* # of fd on device */ + int x_char; /* to be pushed out ASAP */ + int x_break; + 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; + int default_threshold; + int default_timeout; + struct tq_struct tqueue; + struct termios normal_termios; + struct termios callout_termios; + struct wait_queue *open_wait; + struct wait_queue *close_wait; + struct cyclades_monitor mon; +}; + +#define CYCLADES_MAGIC 0x4359 + +#define CYGETMON 0x435901 +#define CYGETTHRESH 0x435902 +#define CYSETTHRESH 0x435903 +#define CYGETDEFTHRESH 0x435904 +#define CYSETDEFTHRESH 0x435905 +#define CYGETTIMEOUT 0x435906 +#define CYSETTIMEOUT 0x435907 +#define CYGETDEFTIMEOUT 0x435908 +#define CYSETDEFTIMEOUT 0x435909 + +/* + * Events are used to schedule things to happen at timer-interrupt + * time, instead of at cy interrupt time. + */ +#define Cy_EVENT_READ_PROCESS 0 +#define Cy_EVENT_WRITE_WAKEUP 1 +#define Cy_EVENT_HANGUP 2 +#define Cy_EVENT_BREAK 3 +#define Cy_EVENT_OPEN_WAKEUP 4 + + + +#define CyMaxChipsPerCard 8 + +/**** CD1400 registers ****/ + +#define CyRegSize 0x0400 +#define Cy_HwReset 0x1400 +#define Cy_ClrIntr 0x1800 + +/* Global Registers */ + +#define CyGFRCR (0x40*2) +#define CyRevE (44) +#define CyCAR (0x68*2) +#define CyCHAN_0 (0x00) +#define CyCHAN_1 (0x01) +#define CyCHAN_2 (0x02) +#define CyCHAN_3 (0x03) +#define CyGCR (0x4B*2) +#define CyCH0_SERIAL (0x00) +#define CyCH0_PARALLEL (0x80) +#define CySVRR (0x67*2) +#define CySRModem (0x04) +#define CySRTransmit (0x02) +#define CySRReceive (0x01) +#define CyRICR (0x44*2) +#define CyTICR (0x45*2) +#define CyMICR (0x46*2) +#define CyICR0 (0x00) +#define CyICR1 (0x01) +#define CyICR2 (0x02) +#define CyICR3 (0x03) +#define CyRIR (0x6B*2) +#define CyTIR (0x6A*2) +#define CyMIR (0x69*2) +#define CyIRDirEq (0x80) +#define CyIRBusy (0x40) +#define CyIRUnfair (0x20) +#define CyIRContext (0x1C) +#define CyIRChannel (0x03) +#define CyPPR (0x7E*2) +#define CyCLOCK_20_1MS (0x27) +#define CyCLOCK_25_1MS (0x31) + +/* Virtual Registers */ + +#define CyRIVR (0x43*2) +#define CyTIVR (0x42*2) +#define CyMIVR (0x41*2) +#define CyIVRMask (0x07) +#define CyIVRRxEx (0x07) +#define CyIVRRxOK (0x03) +#define CyIVRTxOK (0x02) +#define CyIVRMdmOK (0x01) +#define CyTDR (0x63*2) +#define CyRDSR (0x62*2) +#define CyTIMEOUT (0x80) +#define CySPECHAR (0x70) +#define CyBREAK (0x08) +#define CyPARITY (0x04) +#define CyFRAME (0x02) +#define CyOVERRUN (0x01) +#define CyMISR (0x4C*2) +/* see CyMCOR_ and CyMSVR_ for bits*/ +#define CyEOSRR (0x60*2) + +/* Channel Registers */ + +#define CyLIVR (0x18*2) +#define CyMscsr (0x01) +#define CyTdsr (0x02) +#define CyRgdsr (0x03) +#define CyRedsr (0x07) +#define CyCCR (0x05*2) +/* Format 1 */ +#define CyCHAN_RESET (0x80) +#define CyCHIP_RESET (0x81) +#define CyFlushTransFIFO (0x82) +/* Format 2 */ +#define CyCOR_CHANGE (0x40) +#define CyCOR1ch (0x02) +#define CyCOR2ch (0x04) +#define CyCOR3ch (0x08) +/* Format 3 */ +#define CySEND_SPEC_1 (0x21) +#define CySEND_SPEC_2 (0x22) +#define CySEND_SPEC_3 (0x23) +#define CySEND_SPEC_4 (0x24) +/* Format 4 */ +#define CyCHAN_CTL (0x10) +#define CyDIS_RCVR (0x01) +#define CyENB_RCVR (0x02) +#define CyDIS_XMTR (0x04) +#define CyENB_XMTR (0x08) +#define CySRER (0x06*2) +#define CyMdmCh (0x80) +#define CyRxData (0x10) +#define CyTxRdy (0x04) +#define CyTxMpty (0x02) +#define CyNNDT (0x01) +#define CyCOR1 (0x08*2) +#define CyPARITY_NONE (0x00) +#define CyPARITY_0 (0x20) +#define CyPARITY_1 (0xA0) +#define CyPARITY_E (0x40) +#define CyPARITY_O (0xC0) +#define Cy_1_STOP (0x00) +#define Cy_1_5_STOP (0x04) +#define Cy_2_STOP (0x08) +#define Cy_5_BITS (0x00) +#define Cy_6_BITS (0x01) +#define Cy_7_BITS (0x02) +#define Cy_8_BITS (0x03) +#define CyCOR2 (0x09*2) +#define CyIXM (0x80) +#define CyTxIBE (0x40) +#define CyETC (0x20) +#define CyAUTO_TXFL (0x60) +#define CyLLM (0x10) +#define CyRLM (0x08) +#define CyRtsAO (0x04) +#define CyCtsAE (0x02) +#define CyDsrAE (0x01) +#define CyCOR3 (0x0A*2) +#define CySPL_CH_DRANGE (0x80) /* special character detect range */ +#define CySPL_CH_DET1 (0x40) /* enable special character detection + on SCHR4-SCHR3 */ +#define CyFL_CTRL_TRNSP (0x20) /* Flow Control Transparency */ +#define CySPL_CH_DET2 (0x10) /* Enable special character detection + on SCHR2-SCHR1 */ +#define CyREC_FIFO (0x0F) /* Receive FIFO threshold */ +#define CyCOR4 (0x1E*2) +#define CyCOR5 (0x1F*2) +#define CyCCSR (0x0B*2) +#define CyRxEN (0x80) +#define CyRxFloff (0x40) +#define CyRxFlon (0x20) +#define CyTxEN (0x08) +#define CyTxFloff (0x04) +#define CyTxFlon (0x02) +#define CyRDCR (0x0E*2) +#define CySCHR1 (0x1A*2) +#define CySCHR2 (0x1B*2) +#define CySCHR3 (0x1C*2) +#define CySCHR4 (0x1D*2) +#define CySCRL (0x22*2) +#define CySCRH (0x23*2) +#define CyLNC (0x24*2) +#define CyMCOR1 (0x15*2) +#define CyMCOR2 (0x16*2) +#define CyRTPR (0x21*2) +#define CyMSVR1 (0x6C*2) +#define CyMSVR2 (0x6D*2) +#define CyDSR (0x80) +#define CyCTS (0x40) +#define CyRI (0x20) +#define CyDCD (0x10) +#define CyDTR (0x02) +#define CyRTS (0x01) +#define CyPVSR (0x6F*2) +#define CyRBPR (0x78*2) +#define CyRCOR (0x7C*2) +#define CyTBPR (0x72*2) +#define CyTCOR (0x76*2) + +/* max number of chars in the FIFO */ + +#define CyMAX_CHAR_FIFO 12 + +/***************************************************************************/ diff --git a/include/linux/elf.h b/include/linux/elf.h index cc47c39bd..52dedbda4 100644 --- a/include/linux/elf.h +++ b/include/linux/elf.h @@ -1,16 +1,29 @@ -#ifndef _ELF_H -#define _ELF_H +#ifndef _LINUX_ELF_H +#define _LINUX_ELF_H + +typedef unsigned long Elf32_Addr; +typedef unsigned short Elf32_Half; +typedef unsigned long Elf32_Off; +typedef long Elf32_Sword; +typedef unsigned long Elf32_Word; /* 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 +#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 +#define PT_MIPS_REGINFO 0x70000000 + +/* Flags in the e_flags field of the header */ +#define EF_MIPS_NOREORDER 0x00000001 +#define EF_MIPS_PIC 0x00000002 +#define EF_MIPS_CPIC 0x00000004 +#define EF_MIPS_ARCH 0xf0000000 /* These constants define the different elf file types */ #define ET_NONE 0 @@ -18,46 +31,75 @@ #define ET_EXEC 2 #define ET_DYN 3 #define ET_CORE 4 +#if 0 +/* These seem to be wrong ... */ #define ET_LOPROC 5 #define ET_HIPROC 6 +#else +#define ET_LOPROC 0xff00 +#define ET_HIPROC 0xffff +#endif /* 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 +#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 +#define EM_MIPS 8 /* MIPS R3000 (officially, big-endian only) */ +#define EM_MIPS_RS4_BE 10 +#define EM_SPARC64 11 /* SPARC v9 (not official) 64-bit */ +#define EM_PARISC 15 /* 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 +#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 +#define DT_MIPS_RLD_VERSION 0x70000001 +#define DT_MIPS_TIME_STAMP 0x70000002 +#define DT_MIPS_ICHECKSUM 0x70000003 +#define DT_MIPS_IVERSION 0x70000004 +#define DT_MIPS_FLAGS 0x70000005 + #define RHF_NONE 0 + #define RHF_HARDWAY 1 + #define RHF_NOTPOT 2 +#define DT_MIPS_BASE_ADDRESS 0x70000006 +#define DT_MIPS_CONFLICT 0x70000008 +#define DT_MIPS_LIBLIST 0x70000009 +#define DT_MIPS_LOCAL_GOTNO 0x7000000a +#define DT_MIPS_CONFLICTNO 0x7000000b +#define DT_MIPS_LIBLISTNO 0x70000010 +#define DT_MIPS_SYMTABNO 0x70000011 +#define DT_MIPS_UNREFEXTNO 0x70000012 +#define DT_MIPS_GOTSYM 0x70000013 +#define DT_MIPS_HIPAGENO 0x70000014 +#define DT_MIPS_RLD_MAP 0x70000016 /* This info is needed when parsing the symbol table */ #define STB_LOCAL 0 @@ -76,78 +118,219 @@ typedef struct dynamic{ - int d_tag; + Elf32_Sword d_tag; union{ - int d_val; - char * d_ptr; + Elf32_Sword d_val; + Elf32_Addr d_ptr; } d_un; } Elf32_Dyn; +extern Elf32_Dyn _DYNAMIC []; + /* 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 +#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 + +#define R_MIPS_NONE 0 +#define R_MIPS_16 1 +#define R_MIPS_32 2 +#define R_MIPS_REL32 3 +#define R_MIPS_26 4 +#define R_MIPS_HI16 5 +#define R_MIPS_LO16 6 +#define R_MIPS_GPREL16 7 +#define R_MIPS_LITERAL 8 +#define R_MIPS_GOT16 9 +#define R_MIPS_PC16 10 +#define R_MIPS_CALL16 11 +#define R_MIPS_GPREL32 12 +/* The remaining relocs are defined on Irix, although they are not + in the MIPS ELF ABI. */ +#define R_MIPS_UNUSED1 13 +#define R_MIPS_UNUSED2 14 +#define R_MIPS_UNUSED3 15 +#define R_MIPS_SHIFT5 16 +#define R_MIPS_SHIFT6 17 +#define R_MIPS_64 18 +#define R_MIPS_GOT_DISP 19 +#define R_MIPS_GOT_PAGE 20 +#define R_MIPS_GOT_OFST 21 +#define R_MIPS_GOT_HI16 22 +#define R_MIPS_GOT_LO16 23 +#define R_MIPS_SUB 24 +#define R_MIPS_INSERT_A 25 +#define R_MIPS_INSERT_B 26 +#define R_MIPS_DELETE 27 +#define R_MIPS_HIGHER 28 +#define R_MIPS_HIGHEST 29 +#define R_MIPS_CALL_HI16 30 +#define R_MIPS_CALL_LO16 31 typedef struct elf32_rel { - unsigned int * offset; - int info; + Elf32_Addr r_offset; + Elf32_Word r_info; } Elf32_Rel; typedef struct elf32_rela{ - unsigned int * offset; - int info; - int addend; + Elf32_Addr r_offset; + Elf32_Word r_info; + Elf32_Sword r_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_Word st_name; + Elf32_Addr st_value; + Elf32_Word st_size; + unsigned char st_info; + unsigned char st_other; + Elf32_Half st_shndx; } Elf32_Sym; + +#define EI_NIDENT 16 + 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; + unsigned char e_ident[EI_NIDENT]; + Elf32_Half e_type; + Elf32_Half e_machine; + Elf32_Word e_version; + Elf32_Addr e_entry; /* Entry point */ + Elf32_Off e_phoff; + Elf32_Off e_shoff; + Elf32_Word e_flags; + Elf32_Half e_ehsize; + Elf32_Half e_phentsize; + Elf32_Half e_phnum; + Elf32_Half e_shentsize; + Elf32_Half e_shnum; + Elf32_Half e_shstrndx; } Elf32_Ehdr; +/* These constants define the permissions on sections in the program + header, p_flags. */ +#define PF_R 0x4 +#define PF_W 0x2 +#define PF_X 0x1 + 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_Word p_type; + Elf32_Off p_offset; + Elf32_Addr p_vaddr; + Elf32_Addr p_paddr; + Elf32_Word p_filesz; + Elf32_Word p_memsz; + Elf32_Word p_flags; + Elf32_Word p_align; } Elf32_Phdr; +/* sh_type */ +#define SHT_NULL 0 +#define SHT_PROGBITS 1 +#define SHT_SYMTAB 2 +#define SHT_STRTAB 3 +#define SHT_RELA 4 +#define SHT_HASH 5 +#define SHT_DYNAMIC 6 +#define SHT_NOTE 7 +#define SHT_NOBITS 8 +#define SHT_REL 9 +#define SHT_SHLIB 10 +#define SHT_DYNSYM 11 +#define SHT_NUM 12 +#define SHT_LOPROC 0x70000000 +#define SHT_HIPROC 0x7fffffff +#define SHT_LOUSER 0x80000000 +#define SHT_HIUSER 0xffffffff +#define SHT_MIPS_LIST 0x70000000 +#define SHT_MIPS_CONFLICT 0x70000002 +#define SHT_MIPS_GPTAB 0x70000003 +#define SHT_MIPS_UCODE 0x70000004 + +/* sh_flags */ +#define SHF_WRITE 0x1 +#define SHF_ALLOC 0x2 +#define SHF_EXECINSTR 0x4 +#define SHF_MASKPROC 0xf0000000 +#define SHF_MIPS_GPREL 0x10000000 + +/* special section indexes */ +#define SHN_UNDEF 0 +#define SHN_LORESERVE 0xff00 +#define SHN_LOPROC 0xff00 +#define SHN_HIPROC 0xff1f +#define SHN_ABS 0xfff1 +#define SHN_COMMON 0xfff2 +#define SHN_HIRESERVE 0xffff +#define SHN_MIPS_ACCOMON 0xff00 + +typedef struct { + Elf32_Word sh_name; + Elf32_Word sh_type; + Elf32_Word sh_flags; + Elf32_Addr sh_addr; + Elf32_Off sh_offset; + Elf32_Word sh_size; + Elf32_Word sh_link; + Elf32_Word sh_info; + Elf32_Word sh_addralign; + Elf32_Word sh_entsize; +} Elf32_Shdr; + +#define EI_MAG0 0 /* e_ident[] indexes */ +#define EI_MAG1 1 +#define EI_MAG2 2 +#define EI_MAG3 3 +#define EI_CLASS 4 +#define EI_DATA 5 +#define EI_VERSION 6 +#define EI_PAD 7 + +#define ELFMAG0 0x7f /* EI_MAG */ +#define ELFMAG1 'E' +#define ELFMAG2 'L' +#define ELFMAG3 'F' +#define ELFMAG "\177ELF" +#define SELFMAG 4 + +#define ELFCLASSNONE 0 /* EI_CLASS */ +#define ELFCLASS32 1 +#define ELFCLASS64 2 +#define ELFCLASSNUM 3 + +#define ELFDATANONE 0 /* e_ident[EI_DATA] */ +#define ELFDATA2LSB 1 +#define ELFDATA2MSB 2 + +#define EV_NONE 0 /* e_version, EI_VERSION */ +#define EV_CURRENT 1 +#define EV_NUM 2 + +/* Notes used in ET_CORE */ +#define NT_PRSTATUS 1 +#define NT_PRFPREG 2 +#define NT_PRPSINFO 3 +#define NT_TASKSTRUCT 4 + +/* Note header in a PT_NOTE section */ +typedef struct elf_note { + Elf32_Word n_namesz; /* Name size */ + Elf32_Word n_descsz; /* Content size */ + Elf32_Word n_type; /* Content type */ +} Elf32_Nhdr; + #define ELF_START_MMAP 0x80000000 -#endif +#endif /* _LINUX_ELF_H */ diff --git a/include/linux/errno.h b/include/linux/errno.h index 3ce3e606d..ac2128445 100644 --- a/include/linux/errno.h +++ b/include/linux/errno.h @@ -1,128 +1,9 @@ #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 */ +#include <asm/errno.h> + +#ifdef __KERNEL__ /* Should never be seen by user programs */ #define ERESTARTSYS 512 @@ -131,3 +12,5 @@ #define ENOIOCTLCMD 515 /* No ioctl command */ #endif + +#endif diff --git a/include/linux/ext2_fs.h b/include/linux/ext2_fs.h index 8a01bf234..c96a04dc3 100644 --- a/include/linux/ext2_fs.h +++ b/include/linux/ext2_fs.h @@ -1,9 +1,10 @@ /* * 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) + * Copyright (C) 1992, 1993, 1994, 1995 + * Remy Card (card@masi.ibp.fr) + * Laboratoire MASI - Institut Blaise Pascal + * Universite Pierre et Marie Curie (Paris VI) * * from * @@ -15,6 +16,8 @@ #ifndef _LINUX_EXT2_FS_H #define _LINUX_EXT2_FS_H +#include <linux/types.h> + /* * The second extended filesystem constants/structures */ @@ -47,7 +50,7 @@ /* * The second extended file system version */ -#define EXT2FS_DATE "94/10/23" +#define EXT2FS_DATE "95/03/19" #define EXT2FS_VERSION "0.5a" /* @@ -97,7 +100,7 @@ # 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)) +#define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (__u32)) #ifdef __KERNEL__ # define EXT2_BLOCK_SIZE_BITS(s) ((s)->u.ext2_sb.s_es->s_log_block_size + 10) #else @@ -124,20 +127,20 @@ */ 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; + __u32 aclh_size; + __u32 aclh_file_count; + __u32 aclh_acle_count; + __u32 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 */ + __u32 acle_size; + __u16 acle_perms; /* Access permissions */ + __u16 acle_type; /* Type of entry */ + __u16 acle_tag; /* User or group identity */ + __u16 acle_pad1; + __u32 acle_next; /* Pointer on next entry for the */ /* same inode or on next free entry */ }; @@ -146,23 +149,23 @@ struct ext2_acl_entry /* Access Control List Entry */ */ 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 */ + __u32 bg_block_bitmap; /* Blocks bitmap block */ + __u32 bg_inode_bitmap; /* Inodes bitmap block */ + __u32 bg_inode_table; /* Inodes table block */ + __u16 bg_free_blocks_count; /* Free blocks count */ + __u16 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]; + __u32 bg_block_bitmap; /* Blocks bitmap block */ + __u32 bg_inode_bitmap; /* Inodes bitmap block */ + __u32 bg_inode_table; /* Inodes table block */ + __u16 bg_free_blocks_count; /* Free blocks count */ + __u16 bg_free_inodes_count; /* Free inodes count */ + __u16 bg_used_dirs_count; /* Directories count */ + __u16 bg_pad; + __u32 bg_reserved[3]; }; /* @@ -210,58 +213,58 @@ struct ext2_group_desc * 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 */ + __u16 i_mode; /* File mode */ + __u16 i_uid; /* Owner Uid */ + __u32 i_size; /* Size in bytes */ + __u32 i_atime; /* Access time */ + __u32 i_ctime; /* Creation time */ + __u32 i_mtime; /* Modification time */ + __u32 i_dtime; /* Deletion Time */ + __u16 i_gid; /* Group Id */ + __u16 i_links_count; /* Links count */ + __u32 i_blocks; /* Blocks count */ + __u32 i_flags; /* File flags */ union { struct { - unsigned long l_i_reserved1; + __u32 l_i_reserved1; } linux1; struct { - unsigned long h_i_translator; + __u32 h_i_translator; } hurd1; struct { - unsigned long m_i_reserved1; + __u32 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 */ + __u32 i_block[EXT2_N_BLOCKS];/* Pointers to blocks */ + __u32 i_version; /* File version (for NFS) */ + __u32 i_file_acl; /* File ACL */ + __u32 i_dir_acl; /* Directory ACL */ + __u32 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]; + __u8 l_i_frag; /* Fragment number */ + __u8 l_i_fsize; /* Fragment size */ + __u16 i_pad1; + __u32 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; + __u8 h_i_frag; /* Fragment number */ + __u8 h_i_fsize; /* Fragment size */ + __u16 h_i_mode_high; + __u16 h_i_uid_high; + __u16 h_i_gid_high; + __u32 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]; + __u8 m_i_frag; /* Fragment number */ + __u8 m_i_fsize; /* Fragment size */ + __u16 m_pad1; + __u32 m_i_reserved2[2]; } masix2; } osd2; /* OS dependent 2 */ }; -#ifdef __linux__ +#if defined(__KERNEL__) || defined(__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 @@ -326,32 +329,32 @@ struct ext2_inode { * 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 */ + __u32 s_inodes_count; /* Inodes count */ + __u32 s_blocks_count; /* Blocks count */ + __u32 s_r_blocks_count; /* Reserved blocks count */ + __u32 s_free_blocks_count; /* Free blocks count */ + __u32 s_free_inodes_count; /* Free inodes count */ + __u32 s_first_data_block; /* First Data Block */ + __u32 s_log_block_size; /* Block size */ + __s32 s_log_frag_size; /* Fragment size */ + __u32 s_blocks_per_group; /* # Blocks per group */ + __u32 s_frags_per_group; /* # Fragments per group */ + __u32 s_inodes_per_group; /* # Inodes per group */ + __u32 s_mtime; /* Mount time */ + __u32 s_wtime; /* Write time */ + __u16 s_mnt_count; /* Mount count */ + __s16 s_max_mnt_count; /* Maximal mount count */ + __u16 s_magic; /* Magic signature */ + __u16 s_state; /* File system state */ + __u16 s_errors; /* Behaviour when detecting errors */ + __u16 s_pad; + __u32 s_lastcheck; /* time of last check */ + __u32 s_checkinterval; /* max. time between checks */ + __u32 s_creator_os; /* OS */ + __u32 s_rev_level; /* Revision level */ + __u16 s_def_resuid; /* Default uid for reserved blocks */ + __u16 s_def_resgid; /* Default gid for reserved blocks */ + __u32 s_reserved[235]; /* Padding to the end of the block */ }; #define EXT2_OS_LINUX 0 @@ -369,10 +372,10 @@ struct ext2_super_block { #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 */ + __u32 inode; /* Inode number */ + __u16 rec_len; /* Directory entry length */ + __u16 name_len; /* Name length */ + char name[EXT2_NAME_LEN]; /* File name */ }; /* @@ -409,7 +412,7 @@ extern int ext2_permission (struct inode *, int); /* balloc.c */ extern int ext2_new_block (struct super_block *, unsigned long, - unsigned long *, unsigned long *); + __u32 *, __u32 *); extern void ext2_free_blocks (struct super_block *, unsigned long, unsigned long); extern unsigned long ext2_count_free_blocks (struct super_block *); @@ -479,7 +482,7 @@ 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 *); +extern void ext2_statfs (struct super_block *, struct statfs *, int); /* truncate.c */ extern void ext2_truncate (struct inode *); diff --git a/include/linux/ext2_fs_i.h b/include/linux/ext2_fs_i.h index 103e36087..f3eca4480 100644 --- a/include/linux/ext2_fs_i.h +++ b/include/linux/ext2_fs_i.h @@ -1,9 +1,10 @@ /* * 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) + * Copyright (C) 1992, 1993, 1994, 1995 + * Remy Card (card@masi.ibp.fr) + * Laboratoire MASI - Institut Blaise Pascal + * Universite Pierre et Marie Curie (Paris VI) * * from * @@ -19,21 +20,21 @@ * 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; + __u32 i_data[15]; + __u32 i_flags; + __u32 i_faddr; + __u8 i_frag_no; + __u8 i_frag_size; + __u16 i_osync; + __u32 i_file_acl; + __u32 i_dir_acl; + __u32 i_dtime; + __u32 i_version; + __u32 i_block_group; + __u32 i_next_alloc_block; + __u32 i_next_alloc_goal; + __u32 i_prealloc_block; + __u32 i_prealloc_count; }; #endif /* _LINUX_EXT2_FS_I */ diff --git a/include/linux/ext2_fs_sb.h b/include/linux/ext2_fs_sb.h index 2a05a98be..685efeb34 100644 --- a/include/linux/ext2_fs_sb.h +++ b/include/linux/ext2_fs_sb.h @@ -1,9 +1,10 @@ /* * 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) + * Copyright (C) 1992, 1993, 1994, 1995 + * Remy Card (card@masi.ibp.fr) + * Laboratoire MASI - Institut Blaise Pascal + * Universite Pierre et Marie Curie (Paris VI) * * from * diff --git a/include/linux/ext_fs.h b/include/linux/ext_fs.h index 58eae0b0a..52ab5413f 100644 --- a/include/linux/ext_fs.h +++ b/include/linux/ext_fs.h @@ -94,7 +94,7 @@ 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 void ext_statfs(struct super_block *, struct statfs *, int); extern int ext_sync_inode(struct inode *); extern int ext_sync_file(struct inode *, struct file *); diff --git a/include/linux/fcntl.h b/include/linux/fcntl.h index b98266268..9de3512e8 100644 --- a/include/linux/fcntl.h +++ b/include/linux/fcntl.h @@ -1,51 +1,6 @@ #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; -}; +#include <asm/fcntl.h> #endif diff --git a/include/linux/fd.h b/include/linux/fd.h index 42ec48cf8..044f0bace 100644 --- a/include/linux/fd.h +++ b/include/linux/fd.h @@ -127,6 +127,7 @@ struct floppy_drive_params { #define FD_BROKEN_DCL 0x20 #define FD_DEBUG 0x02 #define FD_SILENT_DCL_CLEAR 0x4 +#define FD_INVERTED_DCL 0x80 char read_track; /* use readtrack during probing? */ @@ -212,7 +213,7 @@ struct floppy_fdc_state { int dtr; unsigned char version; /* FDC version code */ unsigned char dor; - int address; /* io address */ + unsigned int address; /* io address */ unsigned int rawcmd:2; unsigned int reset:1; unsigned int need_configure:1; diff --git a/include/linux/fs.h b/include/linux/fs.h index c2bb6e835..617a11a41 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -10,7 +10,6 @@ #include <linux/limits.h> #include <linux/wait.h> #include <linux/types.h> -#include <linux/dirent.h> #include <linux/vfs.h> #include <linux/net.h> @@ -63,12 +62,12 @@ extern unsigned long name_cache_init(unsigned long start, unsigned long end); /* * 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 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_SYNCHRONOUS 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 */ @@ -96,7 +95,7 @@ extern unsigned long name_cache_init(unsigned long start, unsigned long end); #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_SYNC(inode) ((inode)->i_flags & MS_SYNCHRONOUS) #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND) #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE) @@ -225,13 +224,13 @@ struct inode { 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_sock; unsigned char i_seek; unsigned char i_update; union { @@ -246,6 +245,7 @@ struct inode { struct nfs_inode_info nfs_i; struct xiafs_inode_info xiafs_i; struct sysv_inode_info sysv_i; + struct socket socket_i; void * generic_ip; } u; }; @@ -265,13 +265,15 @@ struct file { }; 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 file_lock *fl_next; /* singly linked list for this inode */ + struct file_lock *fl_nextlink; /* doubly linked list of all locks */ + struct file_lock *fl_prevlink; /* used to simplify lock removal */ + struct file_lock *fl_block; + struct task_struct *fl_owner; struct wait_queue *fl_wait; + struct file *fl_file; + char fl_flags; char fl_type; - char fl_whence; off_t fl_start; off_t fl_end; }; @@ -301,6 +303,7 @@ struct super_block { unsigned char s_lock; unsigned char s_rd_only; unsigned char s_dirt; + struct file_system_type *s_type; struct super_operations *s_op; unsigned long s_flags; unsigned long s_magic; @@ -322,11 +325,19 @@ struct super_block { } u; }; +/* + * This is the "filldir" function type, used by readdir() to let + * the kernel specify what kind of dirent layout it wants to have. + * This allows the kernel to read directories into kernel space or + * to have different dirent layouts depending on the binary type. + */ +typedef int (*filldir_t)(void *, char *, int, off_t, ino_t); + 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 (*readdir) (struct inode *, struct file *, void *, filldir_t); 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 *); @@ -364,7 +375,7 @@ struct super_operations { void (*put_inode) (struct inode *); void (*put_super) (struct super_block *); void (*write_super) (struct super_block *); - void (*statfs) (struct super_block *, struct statfs *); + void (*statfs) (struct super_block *, struct statfs *, int); int (*remount_fs) (struct super_block *, int *, char *); }; @@ -472,6 +483,7 @@ 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 int do_pipe(int *); 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); @@ -482,7 +494,7 @@ 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_page(int rw, int dev, unsigned long 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); diff --git a/include/linux/hdreg.h b/include/linux/hdreg.h index df88b8720..1640a3beb 100644 --- a/include/linux/hdreg.h +++ b/include/linux/hdreg.h @@ -1,6 +1,8 @@ #ifndef _LINUX_HDREG_H #define _LINUX_HDREG_H +#include <linux/config.h> + /* * This file contains some defines for the AT-hd-controller. * Various sources. Check out some definitions (see comments with @@ -44,7 +46,8 @@ #define WIN_SEEK 0x70 #define WIN_DIAGNOSE 0x90 #define WIN_SPECIFY 0x91 -#define WIN_SETIDLE 0x97 +#define WIN_SETIDLE1 0xE3 +#define WIN_SETIDLE2 0x97 #define WIN_PIDENTIFY 0xA1 /* identify ATA-PI device */ #define WIN_MULTREAD 0xC4 /* read multiple sectors */ @@ -72,16 +75,17 @@ struct hd_geometry { #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 */ +#define HDIO_GET_KEEPSETTINGS 0x308 /* get keep-settings-on-reset flag */ +#define HDIO_GET_CHIPSET 0x309 /* get current interface type setting */ +#define HDIO_DRIVE_CMD 0x31f /* execute a special drive command */ /* 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 */ +#define HDIO_SET_CHIPSET 0x324 /* optimise driver for interface type */ /* structure returned by HDIO_GET_IDENTITY, as per ANSI ATA2 rev.2f spec */ struct hd_driveid { @@ -133,4 +137,19 @@ struct hd_driveid { /* unsigned short vendor7 [32];*/ /* vendor unique (words 128-159) */ /* unsigned short reservedyy[96];*/ /* reserved (words 160-255) */ }; -#endif + +/* + * These routines are used for kernel command line parameters from main.c: + */ +#ifdef CONFIG_BLK_DEV_HD +void hd_setup(char *, int *); +#endif /* CONFIG_BLK_DEV_HD */ +#ifdef CONFIG_BLK_DEV_IDE +void ide_setup(char *, int *); +void hda_setup(char *, int *); +void hdb_setup(char *, int *); +void hdc_setup(char *, int *); +void hdd_setup(char *, int *); +#endif /* CONFIG_BLK_DEV_IDE */ + +#endif /* _LINUX_HDREG_H */ diff --git a/include/linux/head.h b/include/linux/head.h index ea79de8e9..3829b1c36 100644 --- a/include/linux/head.h +++ b/include/linux/head.h @@ -1,9 +1,19 @@ #ifndef _LINUX_HEAD_H #define _LINUX_HEAD_H -/* - * Include machine dependend stuff - */ -#include <asm/head.h> +typedef struct desc_struct { + unsigned long a,b; +} desc_table[256]; + +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/if.h b/include/linux/if.h index 63eeab9ed..13af3bb7e 100644 --- a/include/linux/if.h +++ b/include/linux/if.h @@ -31,13 +31,15 @@ #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_PROMISC 0x100 /* receive all packets */ +/* Not supported */ +#define IFF_ALLMULTI 0x200 /* receive all multicast packets*/ #define IFF_MASTER 0x400 /* master of a load balancer */ #define IFF_SLAVE 0x800 /* slave of a load balancer */ +#define IFF_MULTICAST 0x1000 /* Supports multicast */ + /* * The ifaddr structure contains information about one address * of an interface. They are maintained by the different address @@ -45,15 +47,18 @@ * 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 */ + +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 */ @@ -67,7 +72,8 @@ struct ifaddr { * being very small might be worth keeping for clean configuration. */ -struct ifmap { +struct ifmap +{ unsigned long mem_start; unsigned long mem_end; unsigned short base_addr; @@ -83,7 +89,9 @@ struct ifmap { * definitions which begin with ifr_name. The * remainder may be interface specific. */ -struct ifreq { + +struct ifreq +{ #define IFHWADDRLEN 6 #define IFNAMSIZ 16 union @@ -127,9 +135,12 @@ struct ifreq { * for machine (useful for programs which * must know all networks accessible). */ -struct ifconf { + +struct ifconf +{ int ifc_len; /* size of buffer */ - union { + union + { caddr_t ifcu_buf; struct ifreq *ifcu_req; } ifc_ifcu; @@ -142,4 +153,4 @@ struct ifconf { #include <linux/if_arp.h> #include <linux/route.h> -#endif /* _NET_IF_H */ +#endif /* _LINUX_IF_H */ diff --git a/include/linux/if_arp.h b/include/linux/if_arp.h index 78b09a6e2..75f86b616 100644 --- a/include/linux/if_arp.h +++ b/include/linux/if_arp.h @@ -39,6 +39,7 @@ #define ARPHRD_RSRVD 260 /* Notional KISS type */ #define ARPHRD_ADAPT 264 #define ARPHRD_PPP 512 +#define ARPHRD_TUNNEL 768 /* IPIP tunnel */ /* ARP protocol opcodes. */ #define ARPOP_REQUEST 1 /* ARP request */ diff --git a/include/linux/if_eql.h b/include/linux/if_eql.h new file mode 100644 index 000000000..5a03f21c8 --- /dev/null +++ b/include/linux/if_eql.h @@ -0,0 +1,79 @@ +/* + * Equalizer Load-balancer for serial network interfaces. + * + * (c) Copyright 1995 Simon "Guru Aleph-Null" Janes + * NCM: Network and Communications Mangement, Inc. + * + * + * This software may be used and distributed according to the terms + * of the GNU Public License, incorporated herein by reference. + * + * The author may be reached as simon@ncm.com, or C/O + * NCM + * Attn: Simon Janes + * 6803 Whittier Ave + * McLean VA 22101 + * Phone: 1-703-847-0040 ext 103 + */ + +#ifndef _LINUX_IF_EQL_H +#define _LINUX_IF_EQL_H + +#define EQL_DEFAULT_SLAVE_PRIORITY 28800 +#define EQL_DEFAULT_MAX_SLAVES 4 +#define EQL_DEFAULT_MTU 576 +#define EQL_DEFAULT_RESCHED_IVAL 100 + +#define EQL_ENSLAVE (SIOCDEVPRIVATE) +#define EQL_EMANCIPATE (SIOCDEVPRIVATE + 1) + +#define EQL_GETSLAVECFG (SIOCDEVPRIVATE + 2) +#define EQL_SETSLAVECFG (SIOCDEVPRIVATE + 3) + +#define EQL_GETMASTRCFG (SIOCDEVPRIVATE + 4) +#define EQL_SETMASTRCFG (SIOCDEVPRIVATE + 5) + +typedef struct slave { + struct device *dev; + long priority; + long priority_bps; + long priority_Bps; + long bytes_queued; + struct slave *next; +} slave_t; + +typedef struct slave_queue { + slave_t *head; + slave_t *best_slave; + int num_slaves; + struct device *master_dev; + char lock; +} slave_queue_t; + +typedef struct equalizer { + slave_queue_t *queue; + int min_slaves; + int max_slaves; + struct enet_statistics *stats; + struct timer_list timer; + char timer_on; +} equalizer_t; + +typedef struct master_config { + char master_name[16]; + int max_slaves; + int min_slaves; +} master_config_t; + +typedef struct slave_config { + char slave_name[16]; + long priority; +} slave_config_t; + +typedef struct slaving_request { + char slave_name[16]; + long priority; +} slaving_request_t; + + +#endif /* _LINUX_EQL_H */ diff --git a/include/linux/if_ether.h b/include/linux/if_ether.h index 336184fcb..eb6a07cce 100644 --- a/include/linux/if_ether.h +++ b/include/linux/if_ether.h @@ -36,13 +36,14 @@ #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_ATALK 0x809B /* Appletalk DDP */ +#define ETH_P_AARP 0x80F3 /* Appletalk AARP */ #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 */ - +#define ETH_P_SNAP 0x0005 /* Internal only */ /* This is an Ethernet frame header. */ struct ethhdr { unsigned char h_dest[ETH_ALEN]; /* destination eth addr */ diff --git a/include/linux/if_plip.h b/include/linux/if_plip.h index 7e483ad4a..153a64991 100644 --- a/include/linux/if_plip.h +++ b/include/linux/if_plip.h @@ -20,7 +20,6 @@ struct plipconf unsigned short pcmd; unsigned long nibble; unsigned long trigger; - unsigned long unit; }; #define PLIP_GET_TIMEOUT 0x1 diff --git a/include/linux/if_ppp.h b/include/linux/if_ppp.h new file mode 100644 index 000000000..51389df71 --- /dev/null +++ b/include/linux/if_ppp.h @@ -0,0 +1,237 @@ +#ifndef _LINUX_IF_PPP_H +#define _LINUX_IF_PPP_H + +/* definitions for kernel PPP module + Michael Callahan <callahan@maths.ox.ac.uk> + Nov. 4 1993 */ + +/* how many PPP units? */ +#ifdef CONFIG_PPP_LOTS +#define PPP_NRUNIT 16 +#else +#define PPP_NRUNIT 4 +#endif + +#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/if_tr.h b/include/linux/if_tr.h new file mode 100644 index 000000000..61629332b --- /dev/null +++ b/include/linux/if_tr.h @@ -0,0 +1,104 @@ +/* + * 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 Token-Ring IEEE 802.5 interface. + * + * Version: @(#)if_tr.h 0.0 07/11/94 + * + * Author: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> + * Donald Becker, <becker@super.org> + * Peter De Schrijver, <stud11@cc4.kuleuven.ac.be> + * + * 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_TR_H +#define _LINUX_IF_TR_H + + +/* IEEE 802.5 Token-Ring magic constants. The frame sizes omit the preamble + and FCS/CRC (frame check sequence). */ +#define TR_ALEN 6 /* Octets in one ethernet addr */ +#define TR_HLEN (sizeof(struct trh_hdr)+sizeof(struct trllc)) +#define AC 0x10 +#define LLC_FRAME 0x40 +#if 0 +#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 */ +#endif + + +/* These are some defined Ethernet Protocol ID's. */ +#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 */ + +/* LLC and SNAP constants */ +#define EXTENDED_SAP 0xAA +#define UI_CMD 0x03 + +/* This is an Token-Ring frame header. */ +struct trh_hdr { + unsigned char ac; /* access control field */ + unsigned char fc; /* frame control field */ + unsigned char daddr[TR_ALEN]; /* destination address */ + unsigned char saddr[TR_ALEN]; /* source address */ + unsigned short rcf; /* route control field */ + unsigned short rseg[8];/* routing registers */ +}; + +/* This is an Token-Ring LLC structure */ +struct trllc { + unsigned char dsap; /* destination SAP */ + unsigned char ssap; /* source SAP */ + unsigned char llc; /* LLC control field */ + unsigned char protid[3]; /* protocol id */ + unsigned short ethertype; /* ether type field */ +}; + + +/* Token-Ring statistics collection data. */ +struct tr_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 transmit_collision; + + /* detailed Token-Ring errors. See IBM Token-Ring Network Architecture + for more info */ + + int line_errors; + int internal_errors; + int burst_errors; + int A_C_errors; + int abort_delimiters; + int lost_frames; + int recv_congest_count; + int frame_copied_errors; + int frequency_errors; + int token_errors; + int dummy1; + +}; + +/* source routing stuff */ + +#define TR_RII 0x80 +#define TR_RCF_DIR_BIT 0x80 +#define TR_RCF_LEN_MASK 0x1f00 +#define TR_RCF_BROADCAST 0x8000 +#define TR_RCF_LIMITED_BROADCAST 0xA000 +#define TR_RCF_FRAME2K 0x20 +#define TR_RCF_BROADCAST_MASK 0xC000 + +#endif /* _LINUX_IF_TR_H */ diff --git a/include/linux/igmp.h b/include/linux/igmp.h new file mode 100644 index 000000000..b8ee985aa --- /dev/null +++ b/include/linux/igmp.h @@ -0,0 +1,84 @@ +/* + * Linux NET3: Internet Gateway Management Protocol [IGMP] + * + * Authors: + * Alan Cox <Alan.Cox@linux.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_IGMP_H +#define _LINUX_IGMP_H + +/* + * IGMP protocol structures + */ + +/* + * Header in on cable format + */ + +struct igmphdr +{ + unsigned char type; + unsigned char unused; + unsigned short csum; + unsigned long group; +}; + +/* + * Header in host convenient format + */ + +struct igmp_header +{ + unsigned char type; + unsigned char unused; + unsigned short csum; + unsigned long group; +}; + + +#define IGMP_HOST_MEMBERSHIP_QUERY 0x11 /* From RFC1112 */ +#define IGMP_HOST_MEMBERSHIP_REPORT 0x12 /* Ditto */ +#define IGMP_HOST_LEAVE_MESSAGE 0x17 /* An extra BSD seems to send */ + + /* 224.0.0.1 */ +#define IGMP_ALL_HOSTS htonl(0xE0000001L) + +/* + * struct for keeping the multicast list in + */ + +#ifdef __KERNEL__ +struct ip_mc_socklist +{ + unsigned long multiaddr[IP_MAX_MEMBERSHIPS]; /* This is a speed trade off */ + struct device *multidev[IP_MAX_MEMBERSHIPS]; +}; + +struct ip_mc_list +{ + struct device *interface; + unsigned long multiaddr; + struct ip_mc_list *next; + struct timer_list timer; + int tm_running; + int users; +}; + +extern struct ip_mc_list *ip_mc_head; + + +extern int igmp_rcv(struct sk_buff *, struct device *, struct options *, unsigned long, unsigned short, + unsigned long, int , struct inet_protocol *); +extern void ip_mc_drop_device(struct device *dev); +extern int ip_mc_join_group(struct sock *sk, struct device *dev, unsigned long addr); +extern int ip_mc_leave_group(struct sock *sk, struct device *dev,unsigned long addr); +extern void ip_mc_drop_socket(struct sock *sk); +#endif +#endif diff --git a/include/linux/in.h b/include/linux/in.h index bb26749a9..d811239d6 100644 --- a/include/linux/in.h +++ b/include/linux/in.h @@ -23,7 +23,8 @@ enum { IPPROTO_IP = 0, /* Dummy protocol for TCP */ IPPROTO_ICMP = 1, /* Internet Control Message Protocol */ - IPPROTO_GGP = 2, /* Gateway Protocol (deprecated) */ + IPPROTO_IGMP = 2, /* Internet Gateway Management Protocol */ + IPPROTO_IPIP = 4, /* IPIP tunnels (older KA9Q tunnels use 94) */ IPPROTO_TCP = 6, /* Transmission Control Protocol */ IPPROTO_EGP = 8, /* Exterior Gateway Protocol */ IPPROTO_PUP = 12, /* PUP protocol */ @@ -40,6 +41,14 @@ struct in_addr { unsigned long int s_addr; }; +/* Request struct for multicast socket ops */ + +struct ip_mreq +{ + struct in_addr imr_multiaddr; /* IP multicast address of group */ + struct in_addr imr_interface; /* local IP address of interface */ +}; + /* Structure describing an Internet (IP) socket address. */ #define __SOCK_SIZE__ 16 /* sizeof(struct sockaddr) */ @@ -72,13 +81,14 @@ struct sockaddr_in { #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(a) ((((long int) (a)) & 0xe0000000) == 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_MULTICAST_NET 0xF0000000 #define IN_EXPERIMENTAL(a) ((((long int) (a)) & 0xe0000000) == 0xe0000000) #define IN_BADCLASS(a) ((((long int) (a)) & 0xf0000000) == 0xf0000000) @@ -96,34 +106,15 @@ struct sockaddr_in { #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 */ - +#define INADDR_LOOPBACK 0x7f000001 /* 127.0.0.1 */ -/* Linux Internet number representation function declarations. */ -#undef ntohl -#undef ntohs -#undef htonl -#undef htons +/* Defines for Multicast INADDR */ +#define INADDR_UNSPEC_GROUP 0xe0000000 /* 224.0.0.0 */ +#define INADDR_ALLHOSTS_GROUP 0xe0000001 /* 224.0.0.1 */ +#define INADDR_MAX_LOCAL_GROUP 0xe00000ff /* 224.0.0.255 */ -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); +/* <asm/byteorder.h> contains the htonl type stuff.. */ -/* - * include machine dependencies - */ -#include <asm/in.h> +#include <asm/byteorder.h> #endif /* _LINUX_IN_H */ diff --git a/include/linux/inet.h b/include/linux/inet.h index fbddc4e1f..4a7a9f654 100644 --- a/include/linux/inet.h +++ b/include/linux/inet.h @@ -42,19 +42,8 @@ #ifndef _LINUX_INET_H #define _LINUX_INET_H -#if defined (__i386__) || defined (__MIPSEL__) -#define NET16(x) ((((x) >> 8) & 0x00FF) | (((x) << 8) & 0xFF00)) -#elif #if defined (__mc680x0__) || defined (__MIPSEB__) -#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); diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h index 6ef2710e8..4c4edc82c 100644 --- a/include/linux/interrupt.h +++ b/include/linux/interrupt.h @@ -2,6 +2,9 @@ #ifndef _LINUX_INTERRUPT_H #define _LINUX_INTERRUPT_H +#include <linux/linkage.h> +#include <asm/bitops.h> + struct bh_struct { void (*routine)(void *); void *data; @@ -11,6 +14,8 @@ extern unsigned long bh_active; extern unsigned long bh_mask; extern struct bh_struct bh_base[32]; +asmlinkage void do_bottom_half(void); + /* 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! */ @@ -21,12 +26,65 @@ enum { SERIAL_BH, NET_BH, IMMEDIATE_BH, - KEYBOARD_BH + KEYBOARD_BH, + CYCLADES_BH }; +extern inline void mark_bh(int nr) +{ + set_bit(nr, &bh_active); +} + +extern inline void disable_bh(int nr) +{ + clear_bit(nr, &bh_mask); +} + +extern inline void enable_bh(int nr) +{ + set_bit(nr, &bh_mask); +} + +extern inline void start_bh_atomic(void) +{ + intr_count++; +} + +extern inline void end_bh_atomic(void) +{ + if (intr_count == 1 && (bh_active & bh_mask)) + do_bottom_half(); + intr_count--; +} + /* - * Include machine depended stuff + * Autoprobing for irqs: + * + * probe_irq_on() and probe_irq_off() provide robust primitives + * for accurate IRQ probing during kernel initialization. They are + * reasonably simple to use, are not "fooled" by spurious interrupts, + * and, unlike other attempts at IRQ probing, they do not get hung on + * stuck interrupts (such as unused PS2 mouse interfaces on ASUS boards). + * + * For reasonably foolproof probing, use them as follows: + * + * 1. clear and/or mask the device's internal interrupt. + * 2. sti(); + * 3. irqs = probe_irq_on(); // "take over" all unassigned idle IRQs + * 4. enable the device and cause it to trigger an interrupt. + * 5. wait for the device to interrupt, using non-intrusive polling or a delay. + * 6. irq = probe_irq_off(irqs); // get IRQ number, 0=none, negative=multiple + * 7. service the device to clear its pending interrupt. + * 8. loop again if paranoia is required. + * + * probe_irq_on() returns a mask of snarfed irq's. + * + * probe_irq_off() takes the mask as a parameter, + * and returns the irq number which occurred, + * or zero if none occurred, or a negative irq number + * if more than one irq occurred. */ -#include <asm/interrupt.h> +extern unsigned int probe_irq_on(void); /* returns 0 on failure */ +extern int probe_irq_off(unsigned int); /* returns 0 or negative on failure */ #endif diff --git a/include/linux/ioport.h b/include/linux/ioport.h index e5923f6ed..8a019adb6 100644 --- a/include/linux/ioport.h +++ b/include/linux/ioport.h @@ -19,7 +19,9 @@ 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 request_region(unsigned int from, unsigned int extent,const char *name); extern void release_region(unsigned int from, unsigned int extent); +extern int get_ioport_list(char *); #define HAVE_AUTOIRQ diff --git a/include/linux/ip.h b/include/linux/ip.h index 75a40a2c9..d12b92b1e 100644 --- a/include/linux/ip.h +++ b/include/linux/ip.h @@ -16,7 +16,7 @@ */ #ifndef _LINUX_IP_H #define _LINUX_IP_H - +#include <asm/byteorder.h> #define IPOPT_END 0 #define IPOPT_NOOP 1 @@ -28,25 +28,24 @@ #define IPOPT_TIMESTAMP 68 +#define MAXTTL 255 + struct timestamp { - u8 len; - u8 ptr; + __u8 len; + __u8 ptr; union { -#if defined(__i386__) || defined(__MIPSEL__) - u8 flags:4, - overflow:4; -#elif defined(__mc68000__) || defined(__MIPSEB__) - unsigned char overflow:4, - flags:4; -#elif defined(__alpha__) - u8 flags:4, +#if defined(LITTLE_ENDIAN_BITFIELD) + __u8 flags:4, overflow:4; +#elif defined(BIG_ENDIAN_BITFIELD) + __u8 overflow:4, + flags:4; #else -#error "Adjust this structure to match your CPU" +#error "Please fix <asm/byteorder.h>" #endif - u8 full_char; + __u8 full_char; } x; - u32 data[9]; + __u32 data[9]; }; @@ -73,27 +72,24 @@ struct options { struct iphdr { -#if defined(__i386__) || defined(__MIPSEL__) - u8 ihl:4, +#if defined(LITTLE_ENDIAN_BITFIELD) + __u8 ihl:4, version:4; -#elif defined (__mc68000__) || defined(__MIPSEB__) - u8 version:4, +#elif defined (BIG_ENDIAN_BITFIELD) + __u8 version:4, ihl:4; -#elif defined(__alpha__) - u8 ihl:4, - version:4; #else -#error "Adjust this structure to match your CPU" +#error "Please fix <asm/byteorder.h>" #endif - u8 tos; - u16 tot_len; - u16 id; - u16 frag_off; - u8 ttl; - u8 protocol; - u16 check; - u32 saddr; - u32 daddr; + __u8 tos; + __u16 tot_len; + __u16 id; + __u16 frag_off; + __u8 ttl; + __u8 protocol; + __u16 check; + __u32 saddr; + __u32 daddr; /*The options start here. */ }; diff --git a/include/linux/ip_fw.h b/include/linux/ip_fw.h new file mode 100644 index 000000000..29bafa34f --- /dev/null +++ b/include/linux/ip_fw.h @@ -0,0 +1,183 @@ +/* + * IP firewalling code. This is taken from 4.4BSD. Please note the + * copyright message below. As per the GPL it must be maintained + * and the licenses thus do not conflict. While this port is subject + * to the GPL I also place my modifications under the original + * license in recognition of the original copyright. + * + * Ported from BSD to Linux, + * Alan Cox 22/Nov/1994. + * Merged and included the FreeBSD-Current changes at Ugen's request + * (but hey it's a lot cleaner now). Ugen would prefer in some ways + * we waited for his final product but since Linux 1.2.0 is about to + * appear it's not practical - Read: It works, it's not clean but please + * don't consider it to be his standard of finished work. + * Alan. + * + * Fixes: + * Pauline Middelink : Added masquerading. + * + * All the real work was done by ..... + */ + +/* + * Copyright (c) 1993 Daniel Boulet + * Copyright (c) 1994 Ugen J.S.Antsilevich + * + * Redistribution and use in source forms, with and without modification, + * are permitted provided that this entire comment appears intact. + * + * Redistribution in binary form may occur without any restrictions. + * Obviously, it would be nice if you gave credit where credit is due + * but requiring it would be too onerous. + * + * This software is provided ``AS IS'' without any warranties of any kind. + */ + +/* + * Format of an IP firewall descriptor + * + * src, dst, src_mask, dst_mask are always stored in network byte order. + * flags and num_*_ports are stored in host byte order (of course). + * Port numbers are stored in HOST byte order. + */ + +#ifndef _IP_FW_H +#define _IP_FW_H + +struct ip_fw +{ + struct ip_fw *fw_next; /* Next firewall on chain */ + struct in_addr fw_src, fw_dst; /* Source and destination IP addr */ + struct in_addr fw_smsk, fw_dmsk; /* Mask for src and dest IP addr */ + struct in_addr fw_via; /* IP address of interface "via" */ + unsigned short fw_flg; /* Flags word */ + unsigned short fw_nsp, fw_ndp; /* N'of src ports and # of dst ports */ + /* in ports array (dst ports follow */ + /* src ports; max of 10 ports in all; */ + /* count of 0 means match all ports) */ +#define IP_FW_MAX_PORTS 10 /* A reasonable maximum */ + unsigned short fw_pts[IP_FW_MAX_PORTS]; /* Array of port numbers to match */ + unsigned long fw_pcnt,fw_bcnt; /* Packet and byte counters */ +}; + +/* + * Values for "flags" field . + */ + +#define IP_FW_F_ALL 0x000 /* This is a universal packet firewall*/ +#define IP_FW_F_TCP 0x001 /* This is a TCP packet firewall */ +#define IP_FW_F_UDP 0x002 /* This is a UDP packet firewall */ +#define IP_FW_F_ICMP 0x003 /* This is a ICMP packet firewall */ +#define IP_FW_F_KIND 0x003 /* Mask to isolate firewall kind */ +#define IP_FW_F_ACCEPT 0x004 /* This is an accept firewall (as * + * opposed to a deny firewall)* + * */ +#define IP_FW_F_SRNG 0x008 /* The first two src ports are a min * + * and max range (stored in host byte * + * order). * + * */ +#define IP_FW_F_DRNG 0x010 /* The first two dst ports are a min * + * and max range (stored in host byte * + * order). * + * (ports[0] <= port <= ports[1]) * + * */ +#define IP_FW_F_PRN 0x020 /* In verbose mode print this firewall*/ +#define IP_FW_F_BIDIR 0x040 /* For bidirectional firewalls */ +#define IP_FW_F_TCPSYN 0x080 /* For tcp packets-check SYN only */ +#define IP_FW_F_ICMPRPL 0x100 /* Send back icmp unreachable packet */ +#define IP_FW_F_MASQ 0x200 /* Masquerading */ +#define IP_FW_F_MASK 0x3FF /* All possible flag bits mask */ + +/* + * New IP firewall options for [gs]etsockopt at the RAW IP level. + * Unlike BSD Linux inherits IP options so you don't have to use + * a raw socket for this. Instead we check rights in the calls. + */ + +#define IP_FW_BASE_CTL 64 + +#define IP_FW_ADD_BLK (IP_FW_BASE_CTL) +#define IP_FW_ADD_FWD (IP_FW_BASE_CTL+1) +#define IP_FW_CHK_BLK (IP_FW_BASE_CTL+2) +#define IP_FW_CHK_FWD (IP_FW_BASE_CTL+3) +#define IP_FW_DEL_BLK (IP_FW_BASE_CTL+4) +#define IP_FW_DEL_FWD (IP_FW_BASE_CTL+5) +#define IP_FW_FLUSH_BLK (IP_FW_BASE_CTL+6) +#define IP_FW_FLUSH_FWD (IP_FW_BASE_CTL+7) +#define IP_FW_ZERO_BLK (IP_FW_BASE_CTL+8) +#define IP_FW_ZERO_FWD (IP_FW_BASE_CTL+9) +#define IP_FW_POLICY_BLK (IP_FW_BASE_CTL+10) +#define IP_FW_POLICY_FWD (IP_FW_BASE_CTL+11) + +#define IP_ACCT_ADD (IP_FW_BASE_CTL+16) +#define IP_ACCT_DEL (IP_FW_BASE_CTL+17) +#define IP_ACCT_FLUSH (IP_FW_BASE_CTL+18) +#define IP_ACCT_ZERO (IP_FW_BASE_CTL+19) + +struct ip_fwpkt +{ + struct iphdr fwp_iph; /* IP header */ + union { + struct tcphdr fwp_tcph; /* TCP header or */ + struct udphdr fwp_udph; /* UDP header */ + } fwp_protoh; + struct in_addr fwp_via; /* interface address */ +}; + +/* + * Main firewall chains definitions and global var's definitions. + */ + +#ifdef __KERNEL__ + +#include <linux/config.h> + +#ifdef CONFIG_IP_MASQUERADE +struct ip_masq { + struct ip_masq *next; /* next member in list */ + struct timer_list timer; /* Expiration timer */ + __u16 protocol; /* Which protocol are we talking? */ + __u32 src, dst; /* Source and destination IP addresses */ + __u16 sport,dport; /* Source and destoination ports */ + __u16 mport; /* Masquaraded port */ + __u32 init_seq; /* Add delta from this seq. on */ + short delta; /* Delta in sequence numbers */ + char sawfin; /* Did we saw an FIN packet? */ +}; +extern struct ip_masq *ip_msq_hosts; +extern void ip_fw_masquerade(struct sk_buff **, struct device *); +extern int ip_fw_demasquerade(struct sk_buff *); +#endif +#ifdef CONFIG_IP_FIREWALL +extern struct ip_fw *ip_fw_blk_chain; +extern struct ip_fw *ip_fw_fwd_chain; +extern int ip_fw_blk_policy; +extern int ip_fw_fwd_policy; +extern int ip_fw_ctl(int, void *, int); +#endif +#ifdef CONFIG_IP_ACCT +extern struct ip_fw *ip_acct_chain; +extern void ip_acct_cnt(struct iphdr *, struct device *, struct ip_fw *); +extern int ip_acct_ctl(int, void *, int); +#endif +extern int ip_fw_chk(struct iphdr *, struct device *rif,struct ip_fw *, int, int); +#endif /* KERNEL */ + +#ifdef CONFIG_IP_MASQUERADE + +#undef DEBUG_MASQ + +#define MASQUERADE_EXPIRE_TCP 15*60*HZ +#define MASQUERADE_EXPIRE_TCP_FIN 2*60*HZ +#define MASQUERADE_EXPIRE_UDP 5*60*HZ + +/* + * Linux ports don't normally get allocated above 32K. I used an extra 4K port-space + */ + +#define PORT_MASQ_BEGIN 60000 +#define PORT_MASQ_END (PORT_MASQ_BEGIN+4096) +#endif + +#endif /* _IP_FW_H */ diff --git a/include/linux/ipc.h b/include/linux/ipc.h index a7a841724..3878e0203 100644 --- a/include/linux/ipc.h +++ b/include/linux/ipc.h @@ -58,6 +58,8 @@ struct ipc_kludge { #define SHMGET 23 #define SHMCTL 24 +#define IPCCALL(version,op) ((version)<<16 | (op)) + #endif /* __KERNEL__ */ #endif /* _LINUX_IPC_H */ diff --git a/include/linux/ipx.h b/include/linux/ipx.h index 1b4b882c1..d3bff83b6 100644 --- a/include/linux/ipx.h +++ b/include/linux/ipx.h @@ -1,21 +1,68 @@ #ifndef _IPX_H_ #define _IPX_H_ +#include <linux/sockios.h> +#define IPX_NODE_LEN 6 +#define IPX_MTU 576 struct sockaddr_ipx { short sipx_family; - unsigned long sipx_network; - unsigned char sipx_node[6]; short sipx_port; + unsigned long sipx_network; + unsigned char sipx_node[IPX_NODE_LEN]; unsigned char sipx_type; + unsigned char sipx_zero; /* 16 byte fill */ }; +/* + * So we can fit the extra info for SIOCSIFADDR into the address nicely + */ + +#define sipx_special sipx_port +#define sipx_action sipx_zero +#define IPX_DLTITF 0 +#define IPX_CRTITF 1 + +typedef struct ipx_route_definition +{ + unsigned long ipx_network; + unsigned long ipx_router_network; + unsigned char ipx_router_node[IPX_NODE_LEN]; +} ipx_route_definition; + +typedef struct ipx_interface_definition +{ + unsigned long ipx_network; + unsigned char ipx_device[16]; + unsigned char ipx_dlink_type; +#define IPX_FRAME_NONE 0 +#define IPX_FRAME_SNAP 1 +#define IPX_FRAME_8022 2 +#define IPX_FRAME_ETHERII 3 +#define IPX_FRAME_8023 4 + unsigned char ipx_special; +#define IPX_SPECIAL_NONE 0 +#define IPX_PRIMARY 1 +#define IPX_INTERNAL 2 + unsigned char ipx_node[IPX_NODE_LEN]; +} ipx_interface_definition; + +typedef struct ipx_config_data +{ + unsigned char ipxcfg_auto_select_primary; + unsigned char ipxcfg_auto_create_interfaces; +} ipx_config_data; + +/* + * OLD Route Definition for backward compatibility. + */ + 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_router_node[IPX_NODE_LEN]; unsigned char ipx_device[16]; unsigned short ipx_flags; #define IPX_RT_SNAP 8 @@ -24,7 +71,8 @@ struct ipx_route_def #define IPX_RT_ROUTED 1 }; -#define IPX_MTU 576 - +#define SIOCAIPXITFCRT (SIOCPROTOPRIVATE) +#define SIOCAIPXPRISLT (SIOCPROTOPRIVATE+1) +#define SIOCIPXCFGDATA (SIOCPROTOPRIVATE+2) #endif diff --git a/include/linux/iso_fs.h b/include/linux/iso_fs.h index 99b032e5e..82a49a3c6 100644 --- a/include/linux/iso_fs.h +++ b/include/linux/iso_fs.h @@ -177,7 +177,7 @@ 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 void isofs_statfs(struct super_block *, struct statfs *, int); extern int isofs_lseek(struct inode *, struct file *, off_t, int); extern int isofs_read(struct inode *, struct file *, char *, int); diff --git a/include/linux/iso_fs_sb.h b/include/linux/iso_fs_sb.h index 1a7e8e517..14f929921 100644 --- a/include/linux/iso_fs_sb.h +++ b/include/linux/iso_fs_sb.h @@ -18,8 +18,10 @@ struct isofs_sb_info { unsigned char s_cruft; /* Broken disks with high byte of length containing junk */ + unsigned char s_unhide; unsigned char s_nosuid; unsigned char s_nodev; + mode_t s_mode; gid_t s_gid; uid_t s_uid; }; diff --git a/include/linux/kd.h b/include/linux/kd.h index 3a343fd32..8ba56a1f9 100644 --- a/include/linux/kd.h +++ b/include/linux/kd.h @@ -112,7 +112,9 @@ struct kbkeycode { #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; +#define KDSIGACCEPT 0x4B4E /* accept kbd generated signals */ + +/* note: 0x4B00-0x4B4E all have had a value at some time; don't reuse for the time being */ /* note: 0x4B60-0x4B68 used above */ diff --git a/include/linux/kernel.h b/include/linux/kernel.h index f4d1d4963..26dd68ef4 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -67,7 +67,6 @@ asmlinkage int printk(const char * fmt, ...) #define suser() (current->euid == 0) #define fsuser() (current->fsuid == 0) -extern int splx (int new_ipl); #endif /* __KERNEL__ */ #define SI_LOAD_SHIFT 16 diff --git a/include/linux/keyboard.h b/include/linux/keyboard.h index a10422b54..d9f671f98 100644 --- a/include/linux/keyboard.h +++ b/include/linux/keyboard.h @@ -319,6 +319,8 @@ extern unsigned short plain_map[NR_KEYS]; #define K_SAK K(KT_SPEC,15) #define K_DECRCONSOLE K(KT_SPEC,16) #define K_INCRCONSOLE K(KT_SPEC,17) +#define K_SPAWNCONSOLE K(KT_SPEC,18) +#define K_BARENUMLOCK K(KT_SPEC,19) #define K_ALLOCATED K(KT_SPEC,126) /* dynamically allocated keymap */ #define K_NOSUCHMAP K(KT_SPEC,127) /* returned by KDGKBENT */ diff --git a/include/linux/lp.h b/include/linux/lp.h index b8a1c03fc..1d3caa28f 100644 --- a/include/linux/lp.h +++ b/include/linux/lp.h @@ -18,6 +18,8 @@ #define LP_NOPA 0x0010 #define LP_ERR 0x0020 #define LP_ABORT 0x0040 +#define LP_CAREFUL 0x0080 +#define LP_ABORTOPEN 0x0100 /* 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 @@ -51,14 +53,21 @@ #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, +#define LPCHAR 0x0601 /* corresponds to LP_INIT_CHAR */ +#define LPTIME 0x0602 /* corresponds to LP_INIT_TIME */ +#define LPABORT 0x0604 /* call with TRUE arg to abort on error, FALSE to retry. Default is retry. */ -#define LPSETIRQ 0x0005 /* call with new IRQ number, +#define LPSETIRQ 0x0605 /* 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 */ +#define LPGETIRQ 0x0606 /* get the current IRQ number */ +#define LPWAIT 0x0608 /* corresponds to LP_INIT_WAIT */ +#define LPCAREFUL 0x0609 /* call with TRUE arg to require out-of-paper, off- + line, and error indicators good on all writes, + FALSE to ignore them. Default is ignore. */ +#define LPABORTOPEN 0x060a /* call with TRUE arg to abort open() on error, + FALSE to ignore error. Default is ignore. */ +#define LPGETSTATUS 0x060b /* return LP_S(minor) */ +#define LPRESET 0x060c /* reset printer */ /* 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 @@ -69,7 +78,7 @@ #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_S(minor) lp_in(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 */ @@ -80,7 +89,7 @@ #define LP_BUFFER_SIZE 256 struct lp_struct { - int base; + unsigned int base; unsigned int irq; int flags; unsigned int chars; @@ -90,16 +99,24 @@ struct lp_struct { char *lp_buffer; }; +/* + * The following constants describe the various signals of the printer port + * hardware. Note that the hardware inverts some signals and that some + * signals are active low. An example is LP_STROBE, which must be programmed + * with 1 for being active and 0 for being inactive, because the strobe signal + * gets inverted, but it is also active low. + */ + /* * 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*/ +#define LP_PBUSY 0x80 /* inverted input, active high */ +#define LP_PACK 0x40 /* unchanged input, active low */ +#define LP_POUTPA 0x20 /* unchanged input, active high */ +#define LP_PSELECD 0x10 /* unchanged input, active high */ +#define LP_PERRORP 0x08 /* unchanged input, active low */ /* * defines for 8255 control port @@ -107,10 +124,10 @@ struct lp_struct { * 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 +#define LP_PSELECP 0x08 /* inverted output, active low */ +#define LP_PINITP 0x04 /* unchanged output, active low */ +#define LP_PAUTOLF 0x02 /* inverted output, active low */ +#define LP_PSTROBE 0x01 /* inverted output, active low */ /* * the value written to ports to test existence. PC-style ports will diff --git a/include/linux/major.h b/include/linux/major.h index da3eaf941..68edd3614 100644 --- a/include/linux/major.h +++ b/include/linux/major.h @@ -7,8 +7,8 @@ /* limits */ -#define MAX_CHRDEV 32 -#define MAX_BLKDEV 32 +#define MAX_CHRDEV 64 +#define MAX_BLKDEV 64 /* * assignments @@ -24,7 +24,7 @@ * 4 - /dev/tty* * 5 - /dev/tty; /dev/cua* * 6 - lp - * 7 - UNUSED + * 7 - /dev/vcs* * 8 - scsi disk * 9 - scsi tape * 10 - mice @@ -36,8 +36,8 @@ * 16 - sockets * 17 - af_unix * 18 - af_inet - * 19 - UNUSED - * 20 - UNUSED + * 19 - cyclades /dev/ttyC* + * 20 - cyclades /dev/cub* * 21 - scsi generic * 22 - (at2disk) * 23 - mitsumi cdrom @@ -46,16 +46,18 @@ * 26 - matsushita cdrom 2 minors 0..3 * 27 - qic117 tape matsushita cdrom 3 minors 0..3 * 28 - matsushita cdrom 4 minors 0..3 + * 29 - aztech/orchid/okano/wearnes cdrom */ #define UNNAMED_MAJOR 0 #define MEM_MAJOR 1 #define FLOPPY_MAJOR 2 -#define HD_MAJOR 3 +#define IDE0_MAJOR 3 +#define HD_MAJOR IDE0_MAJOR #define TTY_MAJOR 4 #define TTYAUX_MAJOR 5 #define LP_MAJOR 6 -/* unused: 7 */ +#define VCS_MAJOR 7 #define SCSI_DISK_MAJOR 8 #define SCSI_TAPE_MAJOR 9 #define MOUSE_MAJOR 10 @@ -67,9 +69,10 @@ #define SOCKET_MAJOR 16 #define AF_UNIX_MAJOR 17 #define AF_INET_MAJOR 18 -/* unused: 19, 20 */ +#define CYCLADES_MAJOR 19 +#define CYCLADESAUX_MAJOR 20 #define SCSI_GENERIC_MAJOR 21 -/* unused: 22 */ +#define IDE1_MAJOR 22 #define MITSUMI_CDROM_MAJOR 23 #define CDU535_CDROM_MAJOR 24 #define MATSUSHITA_CDROM_MAJOR 25 @@ -77,6 +80,7 @@ #define MATSUSHITA_CDROM3_MAJOR 27 #define MATSUSHITA_CDROM4_MAJOR 28 #define QIC117_TAPE_MAJOR 27 +#define AZTECH_CDROM_MAJOR 29 /* * Tests for SCSI devices. diff --git a/include/linux/malloc.h b/include/linux/malloc.h index b803b8b8d..b0105150c 100644 --- a/include/linux/malloc.h +++ b/include/linux/malloc.h @@ -2,6 +2,7 @@ #define _LINUX_MALLOC_H #include <linux/config.h> +#include <linux/mm.h> #ifdef CONFIG_DEBUG_MALLOC #define kmalloc(a,b) deb_kmalloc(__FILE__,__LINE__,a,b) diff --git a/include/linux/mc146818rtc.h b/include/linux/mc146818rtc.h index 741aa2dc5..5f22761fd 100644 --- a/include/linux/mc146818rtc.h +++ b/include/linux/mc146818rtc.h @@ -12,13 +12,19 @@ #define _MC146818RTC_H #include <asm/io.h> +#ifndef RTC_PORT +#define RTC_PORT(x) (0x70 + (x)) +#define RTC_ADDR(x) (0x80 | (x)) +#define RTC_ALWAYS_BCD 1 +#endif + #define CMOS_READ(addr) ({ \ -outb_p(addr|0x80,0x70); \ -inb_p(0x71); \ +outb_p(RTC_ADDR(addr),RTC_PORT(0)); \ +inb_p(RTC_PORT(1)); \ }) #define CMOS_WRITE(val, addr) ({ \ -outb_p(addr|0x80,0x70); \ -outb_p(val,0x71); \ +outb_p(RTC_ADDR(addr),RTC_PORT(0)); \ +outb_p(val,RTC_PORT(1)); \ }) /********************************************************************** diff --git a/include/linux/minix_fs.h b/include/linux/minix_fs.h index 971a50d8a..33fd9c1d9 100644 --- a/include/linux/minix_fs.h +++ b/include/linux/minix_fs.h @@ -27,14 +27,18 @@ #define MINIX_INODES_PER_BLOCK ((BLOCK_SIZE)/(sizeof (struct minix_inode))) +/* + * This is the original minix inode layout on disk. + * Note the 8-bit gid and atime and ctime. + */ 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]; + __u16 i_mode; + __u16 i_uid; + __u32 i_size; + __u32 i_time; + __u8 i_gid; + __u8 i_nlinks; + __u16 i_zone[9]; }; /* @@ -44,34 +48,34 @@ struct minix_inode { * 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]; + __u16 i_mode; + __u16 i_nlinks; + __u16 i_uid; + __u16 i_gid; + __u32 i_size; + __u32 i_atime; + __u32 i_mtime; + __u32 i_ctime; + __u32 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; + __u16 s_ninodes; + __u16 s_nzones; + __u16 s_imap_blocks; + __u16 s_zmap_blocks; + __u16 s_firstdatazone; + __u16 s_log_zone_size; + __u32 s_max_size; + __u16 s_magic; + __u16 s_state; }; struct minix_dir_entry { - unsigned short inode; + __u16 inode; char name[0]; }; @@ -110,7 +114,7 @@ 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 void minix_statfs(struct super_block *, struct statfs *, int); extern int minix_sync_inode(struct inode *); extern int minix_sync_file(struct inode *, struct file *); diff --git a/include/linux/minix_fs_i.h b/include/linux/minix_fs_i.h index 6478627bc..c8677b4b9 100644 --- a/include/linux/minix_fs_i.h +++ b/include/linux/minix_fs_i.h @@ -5,7 +5,7 @@ * minix fs inode data in memory */ struct minix_inode_info { - unsigned short i_data[16]; + __u16 i_data[16]; }; #endif diff --git a/include/linux/mm.h b/include/linux/mm.h index d1f1b3a98..c59651f38 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1,13 +1,17 @@ #ifndef _LINUX_MM_H #define _LINUX_MM_H -#include <asm/page.h> - #include <linux/sched.h> #include <linux/errno.h> #include <linux/kernel.h> #include <linux/string.h> +extern unsigned long high_memory; + +#include <asm/page.h> + +#ifdef __KERNEL__ + #define VERIFY_READ 0 #define VERIFY_WRITE 1 @@ -32,10 +36,20 @@ 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; + pgprot_t vm_page_prot; unsigned short vm_flags; - struct vm_area_struct * vm_next; /* linked list */ - struct vm_area_struct * vm_share; /* linked list */ +/* AVL tree of VM areas per task, sorted by address */ + short vm_avl_height; + struct vm_area_struct * vm_avl_left; + struct vm_area_struct * vm_avl_right; +/* linked list of VM areas per task, sorted by address */ + struct vm_area_struct * vm_next; +/* for areas with inode, the circular list inode->i_mmap */ +/* for shm areas, the circular list of attaches */ +/* otherwise unused */ + struct vm_area_struct * vm_next_share; + struct vm_area_struct * vm_prev_share; +/* more */ struct vm_operations_struct * vm_ops; unsigned long vm_offset; struct inode * vm_inode; @@ -65,31 +79,33 @@ struct vm_area_struct { #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. + * mapping from the currently active vm_flags protection bits (the + * low four bits) to a page protection mask.. + */ +extern pgprot_t protection_map[16]; + + +/* + * These are the virtual MM functions - opening of an area, closing and + * unmapping 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. */ struct vm_operations_struct { void (*open)(struct vm_area_struct * area); void (*close)(struct vm_area_struct * area); + void (*unmap)(struct vm_area_struct *area, unsigned long, size_t); + void (*protect)(struct vm_area_struct *area, unsigned long, size_t, unsigned int newprot); + void (*sync)(struct vm_area_struct *area, unsigned long, size_t, unsigned int flags); + void (*advise)(struct vm_area_struct *area, unsigned long, size_t, unsigned int advise); unsigned long (*nopage)(struct vm_area_struct * area, unsigned long address, - unsigned long page, int error_code); + unsigned long page, int write_access); 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); + void (*swapout)(struct vm_area_struct *, unsigned long, pte_t *); + pte_t (*swapin)(struct vm_area_struct *, unsigned long, 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() +extern mem_map_t * mem_map; /* planning stage.. */ #define P_DIRTY 0x0001 @@ -110,8 +126,6 @@ struct page_info { }; /* end of planning stage */ -#ifdef __KERNEL__ - /* * Free area management */ @@ -137,14 +151,14 @@ extern unsigned char * free_area_map[NR_MEM_LISTS]; */ #define __get_free_page(priority) __get_free_pages((priority),0) extern unsigned long __get_free_pages(int priority, unsigned long gfporder); +extern unsigned long __get_dma_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) - memset((void *)page, 0, 4096); - + memset((void *) page, 0, PAGE_SIZE); return page; } @@ -162,17 +176,17 @@ 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 int remap_page_range(unsigned long from, unsigned long to, unsigned long size, pgprot_t prot); +extern int zeromap_page_range(unsigned long from, unsigned long size, pgprot_t prot); -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 void handle_mm_fault(struct vm_area_struct *vma, unsigned long address, int write_access); +extern void do_wp_page(struct vm_area_struct * vma, unsigned long address, int write_access); +extern void do_no_page(struct vm_area_struct * vma, unsigned long address, int write_access); extern unsigned long paging_init(unsigned long start_mem, unsigned long end_mem); +extern void mem_init(unsigned long start_mem, unsigned long end_mem); extern void show_mem(void); -extern void oom(struct task_struct * task); +extern void oom(struct task_struct * tsk); extern void si_meminfo(struct sysinfo * val); /* vmalloc.c */ @@ -183,32 +197,31 @@ 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 swap_free(unsigned long); +extern void swap_duplicate(unsigned long); +extern void swap_in(struct vm_area_struct *, pte_t *, unsigned long id, int write_access); + 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, +extern unsigned long 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 struct vm_area_struct * find_vma (struct task_struct *, unsigned long); +extern struct vm_area_struct * find_vma_intersection (struct task_struct *, unsigned long, unsigned long); +extern void merge_segments(struct task_struct *, unsigned long, unsigned long); extern void insert_vm_struct(struct task_struct *, struct vm_area_struct *); +extern void remove_shared_vm_struct(struct vm_area_struct *); +extern void build_mmap_avl(struct task_struct *); +extern void exit_mmap(struct task_struct *); extern int do_munmap(unsigned long, size_t); -extern unsigned long get_unmapped_area(unsigned long); +extern unsigned long get_unmapped_area(unsigned long, 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 GFP_BUFFER 0x00 #define GFP_ATOMIC 0x01 #define GFP_USER 0x02 @@ -247,13 +260,41 @@ extern unsigned long swap_cache_find_success; extern inline unsigned long in_swap_cache(unsigned long addr) { - return swap_cache[addr >> PAGE_SHIFT]; + return swap_cache[MAP_NR(addr)]; } -/* - * Include machine dependend stuff - */ -#include <asm/mm.h> +extern inline long find_in_swap_cache (unsigned long addr) +{ + unsigned long entry; + +#ifdef SWAP_CACHE_INFO + swap_cache_find_total++; +#endif + entry = (unsigned long) xchg_ptr(swap_cache + MAP_NR(addr), NULL); +#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 + entry= (unsigned long) xchg_ptr(swap_cache + MAP_NR(addr), NULL); + if (entry) { +#ifdef SWAP_CACHE_INFO + swap_cache_del_success++; +#endif + swap_free(entry); + return 1; + } + return 0; +} #endif /* __KERNEL__ */ diff --git a/include/linux/mman.h b/include/linux/mman.h index 082fd88b7..f9419b2f9 100644 --- a/include/linux/mman.h +++ b/include/linux/mman.h @@ -12,8 +12,12 @@ #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_GROWSDOWN 0x0100 /* stack-like segment */ #define MAP_DENYWRITE 0x0800 /* ETXTBSY */ #define MAP_EXECUTABLE 0x1000 /* mark it as a executable */ +#define MS_ASYNC 1 /* sync memory asynchronously */ +#define MS_INVALIDATE 2 /* invalidate the caches */ +#define MS_SYNC 4 /* synchronous memory sync */ + #endif /* _LINUX_MMAN_H */ diff --git a/include/linux/module.h b/include/linux/module.h index b82fa281b..699c13ccf 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -7,6 +7,22 @@ #ifndef _LINUX_MODULE_H #define _LINUX_MODULE_H +#ifdef CONFIG_MODVERSIONS +# ifndef __GENKSYMS__ +# ifdef MODULE +# define _set_ver(sym,vers) sym ## _R ## vers +# include <linux/modversions.h> +# else /* MODULE */ +# ifdef EXPORT_SYMTAB +# define _set_ver(sym,vers) sym +# include <linux/modversions.h> +# endif /* EXPORT_SYMTAB */ +# endif /* MODULE */ +# else /* __GENKSYMS__ */ +# define _set_ver(sym,vers) sym +# endif /* __GENKSYMS__ */ +#endif /* CONFIG_MODVERSIONS */ + /* values of module.state */ #define MOD_UNINITIALIZED 0 #define MOD_RUNNING 1 @@ -63,6 +79,8 @@ struct mod_routines { /* rename_module_symbol(old_name, new_name) WOW! */ extern int rename_module_symbol(char *, char *); +/* insert new symbol table */ +extern int register_symtab(struct symbol_table *); /* * The first word of the module contains the use count. @@ -73,6 +91,9 @@ extern int rename_module_symbol(char *, char *); */ extern int mod_use_count_; +#if defined(CONFIG_MODVERSIONS) && defined(MODULE) && !defined(__GENKSYMS__) +int Using_Versions; /* gcc will handle this global (used as a flag) correctly */ +#endif #define MOD_INC_USE_COUNT mod_use_count_++ #define MOD_DEC_USE_COUNT mod_use_count_-- diff --git a/include/linux/modules/ksyms.ver b/include/linux/modules/ksyms.ver new file mode 100644 index 000000000..76537cd4c --- /dev/null +++ b/include/linux/modules/ksyms.ver @@ -0,0 +1,194 @@ +/**** This file is generated by genksyms DO NOT EDIT! ****/ +#if defined(CONFIG_MODVERSIONS) && !defined(__GENKSYMS__) +#ifndef _KSYMS_VER_ +#define _KSYMS_VER_ +#define rename_module_symbol _set_ver(rename_module_symbol, b81c73c1) +#define register_symtab _set_ver(register_symtab, e910ea66) +#define EISA_bus _set_ver(EISA_bus, 7e37737c) +#define wp_works_ok _set_ver(wp_works_ok, f37f99e9) +#define verify_area _set_ver(verify_area, 4cfda560) +#define do_mmap _set_ver(do_mmap, 677e7ee1) +#define do_munmap _set_ver(do_munmap, 6221f117) +#define zeromap_page_range _set_ver(zeromap_page_range, 7c395a26) +#define unmap_page_range _set_ver(unmap_page_range, 0110085f) +#define insert_vm_struct _set_ver(insert_vm_struct, 1f4e4882) +#define merge_segments _set_ver(merge_segments, 6854be5a) +#define __get_free_pages _set_ver(__get_free_pages, 5243d78b) +#define free_pages _set_ver(free_pages, 96448859) +#define kmalloc _set_ver(kmalloc, d31fb2cb) +#define kfree_s _set_ver(kfree_s, 1e72eb79) +#define vmalloc _set_ver(vmalloc, 667f3e25) +#define vfree _set_ver(vfree, 6df52add) +#define getname _set_ver(getname, 81487159) +#define putname _set_ver(putname, b19e8126) +#define __iget _set_ver(__iget, ee2b6320) +#define iput _set_ver(iput, 59241ced) +#define namei _set_ver(namei, 00478bcd) +#define lnamei _set_ver(lnamei, fcfddbb1) +#define open_namei _set_ver(open_namei, 414b2b0f) +#define close_fp _set_ver(close_fp, 1d4c15d8) +#define check_disk_change _set_ver(check_disk_change, b66ed457) +#define invalidate_buffers _set_ver(invalidate_buffers, c65255f1) +#define fsync_dev _set_ver(fsync_dev, a221190d) +#define permission _set_ver(permission, 0ebf7474) +#define inode_setattr _set_ver(inode_setattr, 0c80a3c1) +#define inode_change_ok _set_ver(inode_change_ok, 5d1cb326) +#define generic_mmap _set_ver(generic_mmap, d4ff59f3) +#define set_blocksize _set_ver(set_blocksize, f45fda38) +#define getblk _set_ver(getblk, d40228ac) +#define bread _set_ver(bread, c73bf0f0) +#define breada _set_ver(breada, eb8e858c) +#define brelse _set_ver(brelse, 4c27ac3d) +#define ll_rw_block _set_ver(ll_rw_block, f3aa4dd3) +#define __wait_on_buffer _set_ver(__wait_on_buffer, e8fcc968) +#define dcache_lookup _set_ver(dcache_lookup, 83336566) +#define dcache_add _set_ver(dcache_add, fe71f11e) +#define register_chrdev _set_ver(register_chrdev, da99513f) +#define unregister_chrdev _set_ver(unregister_chrdev, 61ea5ee8) +#define register_blkdev _set_ver(register_blkdev, 4699a621) +#define unregister_blkdev _set_ver(unregister_blkdev, d39bbca9) +#define tty_register_driver _set_ver(tty_register_driver, fcc8591c) +#define tty_unregister_driver _set_ver(tty_unregister_driver, c78132a8) +#define tty_std_termios _set_ver(tty_std_termios, cf350678) +#define block_read _set_ver(block_read, a7fe4f51) +#define block_write _set_ver(block_write, 902674c9) +#define block_fsync _set_ver(block_fsync, 182888d8) +#define wait_for_request _set_ver(wait_for_request, 9ca2932e) +#define blksize_size _set_ver(blksize_size, dea1eb55) +#define hardsect_size _set_ver(hardsect_size, ed1ee14f) +#define blk_size _set_ver(blk_size, f60b5398) +#define blk_dev _set_ver(blk_dev, dbf5fdd4) +#define is_read_only _set_ver(is_read_only, b0c5f83e) +#define set_device_ro _set_ver(set_device_ro, 8fb69e13) +#define bmap _set_ver(bmap, 73bb8bdd) +#define sync_dev _set_ver(sync_dev, 9bca536d) +#define get_blkfops _set_ver(get_blkfops, 83827791) +#define register_serial _set_ver(register_serial, 3425f38c) +#define unregister_serial _set_ver(unregister_serial, c013d717) +#define tty_hangup _set_ver(tty_hangup, e3487df0) +#define tty_wait_until_sent _set_ver(tty_wait_until_sent, da85d428) +#define tty_check_change _set_ver(tty_check_change, 705eaab0) +#define tty_hung_up_p _set_ver(tty_hung_up_p, f99ac1e4) +#define register_filesystem _set_ver(register_filesystem, 1c7110ef) +#define unregister_filesystem _set_ver(unregister_filesystem, 5e353af7) +#define register_binfmt _set_ver(register_binfmt, 66ece706) +#define unregister_binfmt _set_ver(unregister_binfmt, 41822618) +#define lookup_exec_domain _set_ver(lookup_exec_domain, 32f10d48) +#define register_exec_domain _set_ver(register_exec_domain, eda4711f) +#define unregister_exec_domain _set_ver(unregister_exec_domain, 78ea447c) +#define request_irq _set_ver(request_irq, 9e81629c) +#define free_irq _set_ver(free_irq, f487dc0c) +#define enable_irq _set_ver(enable_irq, 54e09f5f) +#define disable_irq _set_ver(disable_irq, b4449c1f) +#define bh_active _set_ver(bh_active, 98fb5ca1) +#define bh_mask _set_ver(bh_mask, 1abf3d3f) +#define add_timer _set_ver(add_timer, f13cb728) +#define del_timer _set_ver(del_timer, c7aff713) +#define tq_timer _set_ver(tq_timer, 46cf583e) +#define tq_immediate _set_ver(tq_immediate, 46cf583e) +#define tq_scheduler _set_ver(tq_scheduler, 46cf583e) +#define tq_last _set_ver(tq_last, 457cf547) +#define timer_active _set_ver(timer_active, 5a6747ee) +#define timer_table _set_ver(timer_table, 9e03b650) +#define request_dma _set_ver(request_dma, 2a687646) +#define free_dma _set_ver(free_dma, 5d4b914c) +#define disable_hlt _set_ver(disable_hlt, 794487ee) +#define enable_hlt _set_ver(enable_hlt, 9c7077bd) +#define check_region _set_ver(check_region, b91154fb) +#define request_region _set_ver(request_region, 138b0a1e) +#define release_region _set_ver(release_region, f41d6d31) +#define wake_up _set_ver(wake_up, e8d71419) +#define wake_up_interruptible _set_ver(wake_up_interruptible, 64c8cb92) +#define sleep_on _set_ver(sleep_on, 67a00cee) +#define interruptible_sleep_on _set_ver(interruptible_sleep_on, 6a5fc80d) +#define schedule _set_ver(schedule, 01000e51) +#define current _set_ver(current, fc1cb29b) +#define jiffies _set_ver(jiffies, 2f7c7437) +#define xtime _set_ver(xtime, e70c0be0) +#define loops_per_sec _set_ver(loops_per_sec, 40a14192) +#define need_resched _set_ver(need_resched, dfc016ea) +#define kill_proc _set_ver(kill_proc, 911f760a) +#define kill_pg _set_ver(kill_pg, 0a758a45) +#define kill_sl _set_ver(kill_sl, 49625e94) +#define panic _set_ver(panic, 400c0de3) +#define printk _set_ver(printk, ad1148ba) +#define sprintf _set_ver(sprintf, f9003107) +#define vsprintf _set_ver(vsprintf, e605cb6b) +#define simple_strtoul _set_ver(simple_strtoul, bdb8c1e3) +#define system_utsname _set_ver(system_utsname, 066845bc) +#define sys_call_table _set_ver(sys_call_table, 79fa4011) +#define do_signal _set_ver(do_signal, 86f9bc59) +#define send_sig _set_ver(send_sig, 5cddd8d9) +#define setup_arg_pages _set_ver(setup_arg_pages, fe68d94a) +#define copy_strings _set_ver(copy_strings, 232aee96) +#define create_tables _set_ver(create_tables, ba788fa2) +#define do_execve _set_ver(do_execve, 8c99dc0a) +#define flush_old_exec _set_ver(flush_old_exec, c737e178) +#define open_inode _set_ver(open_inode, 27302cb6) +#define read_exec _set_ver(read_exec, a80a2dd0) +#define si_meminfo _set_ver(si_meminfo, bb05fc9a) +#define sock_register _set_ver(sock_register, d68e1649) +#define sock_unregister _set_ver(sock_unregister, 72c332bd) +#define inet_add_protocol _set_ver(inet_add_protocol, 55292121) +#define inet_del_protocol _set_ver(inet_del_protocol, 73908a1b) +#define slhc_init _set_ver(slhc_init, e490a4b8) +#define slhc_free _set_ver(slhc_free, 39ab902b) +#define slhc_remember _set_ver(slhc_remember, db333be6) +#define slhc_compress _set_ver(slhc_compress, e753e2d2) +#define slhc_uncompress _set_ver(slhc_uncompress, 81cc1144) +#define register_netdevice_notifier _set_ver(register_netdevice_notifier, e7aace7c) +#define unregister_netdevice_notifier _set_ver(unregister_netdevice_notifier, be114416) +#define floppy_track_buffer _set_ver(floppy_track_buffer, c6e3f7c2) +#define register_netdev _set_ver(register_netdev, 0d8d1bb4) +#define unregister_netdev _set_ver(unregister_netdev, 25a99579) +#define ether_setup _set_ver(ether_setup, 4eafef91) +#define alloc_skb _set_ver(alloc_skb, b6b523ba) +#define kfree_skb _set_ver(kfree_skb, 0b938572) +#define dev_kfree_skb _set_ver(dev_kfree_skb, aa1fe7f4) +#define netif_rx _set_ver(netif_rx, d8051cb2) +#define dev_rint _set_ver(dev_rint, 040d3f4b) +#define dev_tint _set_ver(dev_tint, 860b350b) +#define irq2dev_map _set_ver(irq2dev_map, 10bdcd8a) +#define dev_add_pack _set_ver(dev_add_pack, 6d7d9be4) +#define dev_remove_pack _set_ver(dev_remove_pack, 784fa59f) +#define dev_get _set_ver(dev_get, 72ed90fd) +#define dev_ioctl _set_ver(dev_ioctl, 08760203) +#define dev_queue_xmit _set_ver(dev_queue_xmit, 4a478225) +#define dev_base _set_ver(dev_base, 0a8809f0) +#define dev_close _set_ver(dev_close, 9bdad56d) +#define arp_find _set_ver(arp_find, a141bd11) +#define n_tty_ioctl _set_ver(n_tty_ioctl, 538e5fa6) +#define tty_register_ldisc _set_ver(tty_register_ldisc, 8fdde939) +#define kill_fasync _set_ver(kill_fasync, 890501b6) +#define in_scan_scsis _set_ver(in_scan_scsis, 21874a88) +#define scsi_register_module _set_ver(scsi_register_module, 8eff1010) +#define scsi_unregister_module _set_ver(scsi_unregister_module, d913b8f0) +#define scsi_free _set_ver(scsi_free, 475dddfa) +#define scsi_malloc _set_ver(scsi_malloc, 1cce3f92) +#define scsi_register _set_ver(scsi_register, d6e77069) +#define scsi_unregister _set_ver(scsi_unregister, 3b0b616b) +#define scsicam_bios_param _set_ver(scsicam_bios_param, 3d965248) +#define scsi_init_malloc _set_ver(scsi_init_malloc, e5167cbc) +#define scsi_init_free _set_ver(scsi_init_free, 8b2721f8) +#define print_command _set_ver(print_command, 6f14cd75) +#define print_msg _set_ver(print_msg, 0465f877) +#define print_status _set_ver(print_status, 32f84646) +#define set_writetime _set_ver(set_writetime, 52131916) +#define sys_tz _set_ver(sys_tz, aa3c9782) +#define __wait_on_super _set_ver(__wait_on_super, 61a5c00a) +#define file_fsync _set_ver(file_fsync, d30a190f) +#define clear_inode _set_ver(clear_inode, da2b0e9f) +#define refile_buffer _set_ver(refile_buffer, 8c69e123) +#define ___strtok _set_ver(___strtok, 8b55d69c) +#define init_fifo _set_ver(init_fifo, 082629c7) +#define super_blocks _set_ver(super_blocks, e1f1ee99) +#define chrdev_inode_operations _set_ver(chrdev_inode_operations, 6ba1faa3) +#define blkdev_inode_operations _set_ver(blkdev_inode_operations, ed443696) +#define read_ahead _set_ver(read_ahead, bbcd3768) +#define get_hash_table _set_ver(get_hash_table, 3b5f3c55) +#define get_empty_inode _set_ver(get_empty_inode, 554bdc75) +#define insert_inode_hash _set_ver(insert_inode_hash, 59b8c371) +#define event _set_ver(event, a6aac9c1) +#define __down _set_ver(__down, 75aa9e96) +#endif /* _KSYMS_VER_ */ +#endif /* CONFIG_MODVERSIONS !__GENKSYMS__ */ diff --git a/include/linux/modversions.h b/include/linux/modversions.h new file mode 100644 index 000000000..25079e40b --- /dev/null +++ b/include/linux/modversions.h @@ -0,0 +1 @@ +#include <linux/modules/ksyms.ver> diff --git a/include/linux/msdos_fs.h b/include/linux/msdos_fs.h index dd6699a0d..fa2dd9fa9 100644 --- a/include/linux/msdos_fs.h +++ b/include/linux/msdos_fs.h @@ -62,29 +62,29 @@ 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) */ + __s8 ignored[3]; /* Boot strap short or near jump */ + __s8 system_id[8]; /* Name - can be used to special case + partition manager volumes */ + __u8 sector_size[2]; /* bytes per logical sector */ + __u8 cluster_size; /* sectors/cluster */ + __u16 reserved; /* reserved sectors */ + __u8 fats; /* number of FATs */ + __u8 dir_entries[2]; /* root directory entries */ + __u8 sectors[2]; /* number of sectors */ + __u8 media; /* media code (unused) */ + __u16 fat_length; /* sectors/FAT */ + __u16 secs_track; /* sectors per track */ + __u16 heads; /* number of heads */ + __u32 hidden; /* hidden sectors (unused) */ + __u32 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) */ + __s8 name[8],ext[3]; /* name and extension */ + __u8 attr; /* attribute bits */ + __u8 unused[10]; + __u16 time,date,start;/* time, date and first cluster */ + __u32 size; /* file size (in bytes) */ }; struct fat_cache { @@ -110,12 +110,6 @@ struct fat_cache { #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); @@ -125,9 +119,8 @@ 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 date_dos2unix(__u16 time, __u16 date); +extern void date_unix2dos(int unix_date,__u16 *time, __u16 *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, @@ -166,7 +159,7 @@ 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 void msdos_statfs(struct super_block *sb,struct statfs *buf, int); 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); @@ -176,10 +169,11 @@ extern int msdos_notify_change(struct inode *,struct iattr *); extern struct inode_operations msdos_dir_inode_operations; extern int msdos_readdir (struct inode *inode, struct file *filp, - struct dirent *dirent, int count); + void *dirent, filldir_t); /* file.c */ extern struct inode_operations msdos_file_inode_operations; +extern struct inode_operations msdos_file_inode_operations_1024; 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; diff --git a/include/linux/msdos_fs_i.h b/include/linux/msdos_fs_i.h index f74cd2ba4..b11e22483 100644 --- a/include/linux/msdos_fs_i.h +++ b/include/linux/msdos_fs_i.h @@ -1,9 +1,6 @@ #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 diff --git a/include/linux/mtio.h b/include/linux/mtio.h index cee9ac026..f995bd2f9 100644 --- a/include/linux/mtio.h +++ b/include/linux/mtio.h @@ -1,4 +1,4 @@ -/* $Id: mtio.h,v 1.13 1994/07/19 19:35:52 root Exp $ +/* $Id: /usr/src/linux-1.1.64/include/linux/mtio.h at Tue Jan 10 21:02:51 1995 by root@kai.home$ * * linux/mtio.h header file for Linux. Written by H. Bergman */ @@ -220,5 +220,6 @@ struct mtpos { #define MT_ST_READ_AHEAD 0x4 #define MT_ST_DEBUGGING 0x8 #define MT_ST_TWO_FM 0x10 +#define MT_ST_FAST_MTEOM 0x20 #endif /* _LINUX_MTIO_H */ diff --git a/include/linux/ncp.h b/include/linux/ncp.h deleted file mode 100644 index bd6daf29d..000000000 --- a/include/linux/ncp.h +++ /dev/null @@ -1,106 +0,0 @@ -#ifndef _LINUX_NCP_H_ -#define _LINUX_NCP_H_ - -#define NCP_OPEN 0x1111 -#define NCP_CLOSE 0x5555 -#define NCP_REQUEST 0x2222 -#define NCP_REPLY 0x3333 - -struct ncp_request -{ - unsigned short p_type __attribute__ ((packed)); - unsigned char seq __attribute__ ((packed)); - unsigned char c_low __attribute__ ((packed)); - unsigned char task __attribute__ ((packed)); - unsigned char c_high __attribute__ ((packed)); - unsigned char func __attribute__ ((packed)); -}; - -struct ncp_request_sf -{ - unsigned short p_type __attribute__ ((packed)); - unsigned char seq __attribute__ ((packed)); - unsigned char c_low __attribute__ ((packed)); - unsigned char task __attribute__ ((packed)); - unsigned char c_high __attribute__ ((packed)); - unsigned char func __attribute__ ((packed)); - unsigned short s_len __attribute__ ((packed)); - unsigned char s_func __attribute__ ((packed)); -}; - -struct ncp_reply -{ - unsigned short p_type __attribute__ ((packed)); - unsigned char seq __attribute__ ((packed)); - unsigned char c_low __attribute__ ((packed)); - unsigned char task __attribute__ ((packed)); - unsigned char c_high __attribute__ ((packed)); - unsigned char f_stat __attribute__ ((packed)); - unsigned char c_stat __attribute__ ((packed)); -}; - -#define OTYPE_USER 0x0001 -#define OTYPE_GROUP 0x0002 -#define OTYPE_PQUEUE 0x0003 -#define OTYPE_FSERVER 0x0004 -#define OTYPE_JSERVER 0x0005 -#define OTYPE_PSERVER 0x0007 -#define OTYPE_UNKNOWN_1 0x002E -#define OTYPE_ADV_PSERVER 0x0047 -#define OTYPE_AFSERVER 0x0107 -#define OTYPE_UNKNOWN_2 0x0143 -#define OTYPE_UNKNOWN_3 0x01F5 -#define OTYPE_UNKNOWN_4 0x023F - -#define LIMIT_OBJNAME 47 - -struct bind_obj -{ - unsigned long id __attribute__ ((packed)); - unsigned short type __attribute__ ((packed)); - char name[LIMIT_OBJNAME+1] __attribute__ ((packed)); -}; - -struct get_bind_obj -{ - unsigned short type __attribute__ ((packed)); - unsigned char n_len __attribute__ ((packed)); - char name[0] __attribute__ ((packed)); -}; - -struct scan_bind_obj -{ - unsigned long id __attribute__ ((packed)); - unsigned short type __attribute__ ((packed)); - unsigned char n_len __attribute__ ((packed)); - char name[0] __attribute__ ((packed)); -}; - -struct login_req -{ - unsigned char password[8] __attribute__ ((packed)); - unsigned short type __attribute__ ((packed)); - unsigned char n_len __attribute__ ((packed)); - char name[0] __attribute__ ((packed)); -}; - -struct ncp_time -{ - unsigned char year __attribute__ ((packed)); - unsigned char month __attribute__ ((packed)); - unsigned char day __attribute__ ((packed)); - unsigned char hours __attribute__ ((packed)); - unsigned char mins __attribute__ ((packed)); - unsigned char secs __attribute__ ((packed)); - unsigned char c_secs __attribute__ ((packed)); -}; - -struct login_info -{ - unsigned long id __attribute__ ((packed)); - unsigned short un1 __attribute__ ((packed)); - char name[LIMIT_OBJNAME+1] __attribute__ ((packed)); - struct ncp_time time __attribute__ ((packed)); -}; -#endif - diff --git a/include/linux/net.h b/include/linux/net.h index a19f619cb..bad60518f 100644 --- a/include/linux/net.h +++ b/include/linux/net.h @@ -23,7 +23,8 @@ #include <linux/socket.h> -#define NSOCKETS 128 /* should be dynamic, later... */ +#define NSOCKETS 2000 /* Dynamic, this is MAX LIMIT */ +#define NSOCKETS_UNIX 128 /* unix domain static limit */ #define NPROTO 16 /* should be enough for now.. */ @@ -53,6 +54,8 @@ typedef enum { } socket_state; #define SO_ACCEPTCON (1<<16) /* performed a listen */ +#define SO_WAITDATA (1<<17) /* wait data to read */ +#define SO_NOSPACE (1<<18) /* no space to write */ #ifdef __KERNEL__ /* @@ -128,10 +131,11 @@ struct net_proto { 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_awaitconn(struct socket *mysock, struct socket *servsock, int flags); +extern int sock_wake_async(struct socket *sock, int how); extern int sock_register(int family, struct proto_ops *ops); extern int sock_unregister(int family); - +extern struct socket *sock_alloc(void); +extern void sock_release(struct socket *sock); #endif /* __KERNEL__ */ #endif /* _LINUX_NET_H */ diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 0c66a3e5e..8800f647b 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -31,7 +31,7 @@ /* for future expansion when we will have different priorities. */ #define DEV_NUMBUFFS 3 #define MAX_ADDR_LEN 7 -#define MAX_HEADER 18 +#define MAX_HEADER 38 #define IS_MYADDR 1 /* address is (one of) our own */ #define IS_LOOPBACK 2 /* address is for LOOPBACK */ @@ -40,6 +40,18 @@ #define IS_MULTICAST 5 /* Multicast IP address */ /* + * We tag these structures with multicasts. + */ + +struct dev_mc_list +{ + struct dev_mc_list *next; + char dmi_addr[MAX_ADDR_LEN]; + unsigned short dmi_addrlen; + unsigned short dmi_users; +}; + +/* * 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 @@ -60,12 +72,12 @@ struct device 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 long base_addr; /* device I/O address */ unsigned char irq; /* device IRQ number */ /* Low-level status flags. */ + volatile unsigned int tbusy; /* transmitter busy */ volatile unsigned char start, /* start an operation */ - tbusy, /* transmitter busy */ interrupt; /* interrupt arrived */ struct device *next; @@ -107,7 +119,12 @@ struct device unsigned long pa_dstaddr; /* protocol P-P other side addr */ unsigned long pa_mask; /* protocol netmask */ unsigned short pa_alen; /* protocol address length */ + + struct dev_mc_list *mc_list; /* Multicast mac addresses */ + int mc_count; /* Number of installed mcasts */ + struct ip_mc_list *ip_mc_list; /* IP multicast filter chain */ + /* For load balancing driver pair support */ unsigned long pkt_queue; /* Packets queued */ @@ -131,8 +148,6 @@ struct device 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); @@ -142,13 +157,13 @@ struct device int (*do_ioctl)(struct device *dev, struct ifreq *ifr, int cmd); #define HAVE_SET_CONFIG int (*set_config)(struct device *dev, struct ifmap *map); - + int (*header_cache)(struct device *dev, struct sock *sk, unsigned long saddr, unsigned long daddr); }; struct packet_type { unsigned short type; /* This is really htons(ether_type). */ - unsigned short copy:1; + struct device * dev; int (*func) (struct sk_buff *, struct device *, struct packet_type *); void *data; @@ -158,13 +173,16 @@ struct packet_type { #ifdef __KERNEL__ +#include <linux/notifier.h> + /* Used by dev_rint */ #define IN_SKBUFF 1 -extern volatile char in_bh; +extern volatile int in_bh; +extern struct device loopback_dev; extern struct device *dev_base; -extern struct packet_type *ptype_base; +extern struct packet_type *ptype_base[16]; extern int ip_addr_match(unsigned long addr1, unsigned long addr2); @@ -197,11 +215,20 @@ extern void dev_init(void); /* These functions live elsewhere (drivers/net/net_init.c, but related) */ extern void ether_setup(struct device *dev); +extern void tr_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); - +extern int register_netdevice_notifier(struct notifier_block *nb); +extern int unregister_netdevice_notifier(struct notifier_block *nb); +/* Functions used for multicast support */ +extern void dev_mc_upload(struct device *dev); +extern void dev_mc_delete(struct device *dev, void *addr, int alen, int all); +extern void dev_mc_add(struct device *dev, void *addr, int alen, int newonly); +extern void dev_mc_discard(struct device *dev); +/* This is the wrong place but it'll do for the moment */ +extern void ip_mc_allhost(struct device *dev); #endif /* __KERNEL__ */ #endif /* _LINUX_DEV_H */ diff --git a/include/linux/netrom.h b/include/linux/netrom.h new file mode 100644 index 000000000..935deb2b8 --- /dev/null +++ b/include/linux/netrom.h @@ -0,0 +1,40 @@ +#define PF_NETROM AF_NETROM +#define NETROM_MTU 236 + +#define NETROM_T1 1 +#define NETROM_T2 2 +#define NETROM_N2 3 + +#define SIOCNRADDNODE (SIOCPROTOPRIVATE) +#define SIOCNRDELNODE (SIOCPROTOPRIVATE+1) +#define SIOCNRADDNEIGH (SIOCPROTOPRIVATE+2) +#define SIOCNRDELNEIGH (SIOCPROTOPRIVATE+3) +#define SIOCNRGETPARMS (SIOCPROTOPRIVATE+4) +#define SIOCNRSETPARMS (SIOCPROTOPRIVATE+5) +#define SIOCNRDECOBS (SIOCPROTOPRIVATE+6) + +struct nr_node_struct { + ax25_address callsign; + char mnemonic[7]; + ax25_address neighbour; + char device[16]; + unsigned int quality; + unsigned int obs_count; +}; + +struct nr_neigh_struct { + ax25_address callsign; + char device[16]; + unsigned int quality; +}; + +struct nr_parms_struct { + unsigned int quality; + unsigned int obs_count; + unsigned int ttl; + unsigned int timeout; + unsigned int ack_delay; + unsigned int busy_delay; + unsigned int tries; + unsigned int window; +}; diff --git a/include/linux/nfs.h b/include/linux/nfs.h index 3cfbd1d12..95a93e457 100644 --- a/include/linux/nfs.h +++ b/include/linux/nfs.h @@ -67,6 +67,7 @@ enum nfs_stat { NFSERR_NOENT = 2, NFSERR_IO = 5, NFSERR_NXIO = 6, + NFSERR_EAGAIN = 11, NFSERR_ACCES = 13, NFSERR_EXIST = 17, NFSERR_NODEV = 19, diff --git a/include/linux/notifier.h b/include/linux/notifier.h new file mode 100644 index 000000000..78a446496 --- /dev/null +++ b/include/linux/notifier.h @@ -0,0 +1,96 @@ +/* + * Routines to manage notifier chains for passing status changes to any + * interested routines. We need this instead of hard coded call lists so + * that modules can poke their nose into the innards. The network devices + * needed them so here they are for the rest of you. + * + * Alan Cox <Alan.Cox@linux.org> + */ + +#ifndef _LINUX_NOTIFIER_H +#define _LINUX_NOTIFIER_H +#include <linux/errno.h> + +struct notifier_block +{ + int (*notifier_call)(unsigned long, void *); + struct notifier_block *next; + int priority; +}; + + +#ifdef __KERNEL__ + +#define NOTIFY_DONE 0x0000 /* Don't care */ +#define NOTIFY_OK 0x0001 /* Suits me */ +#define NOTIFY_STOP_MASK 0x8000 /* Don't call further */ +#define NOTIFY_BAD (NOTIFY_STOP_MASK|0x0002) /* Bad/Veto action */ + +extern __inline__ int notifier_chain_register(struct notifier_block **list, struct notifier_block *n) +{ + while(*list) + { + if(n->priority > (*list)->priority) + break; + list= &((*list)->next); + } + n->next = *list; + *list=n; + return 0; +} + +/* + * Warning to any non GPL module writers out there.. these functions are + * GPL'd + */ + +extern __inline__ int notifier_chain_unregister(struct notifier_block **nl, struct notifier_block *n) +{ + while((*nl)!=NULL) + { + if((*nl)==n) + { + *nl=n->next; + return 0; + } + nl=&((*nl)->next); + } + return -ENOENT; +} + +/* + * This is one of these things that is generally shorter inline + */ + +extern __inline__ int notifier_call_chain(struct notifier_block **n, unsigned long val, void *v) +{ + int ret=NOTIFY_DONE; + struct notifier_block *nb = *n; + while(nb) + { + ret=nb->notifier_call(val,v); + if(ret&NOTIFY_STOP_MASK) + return ret; + nb=nb->next; + } + return ret; +} + + +/* + * Declared notifiers so far. I can imagine quite a few more chains + * over time (eg laptop power reset chains, reboot chain (to clean + * device units up), device [un]mount chain, module load/unload chain, + * low memory chain, screenblank chain (for plug in modular screenblankers) + * VC switch chains (for loadable kernel svgalib VC switch helpers) etc... + */ + +/* netdevice notifier chain */ +#define NETDEV_UP 0x0001 /* For now you can't veto a device up/down */ +#define NETDEV_DOWN 0x0002 +#define NETDEV_REBOOT 0x0003 /* Tell a protocol stack a network interface + detected a hardware crash and restarted + - we can use this eg to kick tcp sessions + once done */ +#endif +#endif diff --git a/include/linux/param.h b/include/linux/param.h index c634b1ea3..092e92f67 100644 --- a/include/linux/param.h +++ b/include/linux/param.h @@ -1,20 +1,6 @@ #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 */ +#include <asm/param.h> #endif diff --git a/include/linux/pci.h b/include/linux/pci.h index 9b112ab80..0be42eadc 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -19,30 +19,30 @@ * within the United States, $35 abroad. */ + + +/* PROCEDURE TO REPORT NEW PCI DEVICES + * We are trying to collect informations on new PCI devices, using + * the standart PCI identification procedure. If some warning is + * displayed at boot time, please report + * - /proc/pci + * - your exact hardware description. Try to find out + * which device is unknown. It may be you mainboard chipset. + * PCI-CPU bridge or PCI-ISA bridge. + * - Send all that to frederic@cao-vlsi.ibp.fr, and I'll add + * your device to the list as soon as possible + * fred. + */ + + + #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 : + * of which the first 64 bytes are standardized as follows: */ - #define PCI_VENDOR_ID 0x00 /* 16 bits */ #define PCI_DEVICE_ID 0x02 /* 16 bits */ #define PCI_COMMAND 0x04 /* 16 bits */ @@ -51,7 +51,7 @@ #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_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 */ @@ -63,7 +63,7 @@ #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_DEVSEL_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 */ @@ -72,6 +72,10 @@ #define PCI_CLASS_REVISION 0x08 /* High 24 bits are class, low 8 revision */ +#define PCI_REVISION_ID 0x08 /* Revision ID */ +#define PCI_CLASS_PROG 0x09 /* Reg. Level Programming Interface */ +#define PCI_CLASS_DEVICE 0x0a /* Device class */ + #define PCI_CACHE_LINE_SIZE 0x0c /* 8 bits */ #define PCI_LATENCY_TIMER 0x0d /* 8 bits */ #define PCI_HEADER_TYPE 0x0e /* 8 bits */ @@ -86,7 +90,6 @@ * 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 */ @@ -100,8 +103,9 @@ #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 +#define PCI_BASE_ADDRESS_MEM_PREFETCH 0x08 /* prefetchable? */ +#define PCI_BASE_ADDRESS_MEM_MASK (~0x0f) +#define PCI_BASE_ADDRESS_IO_MASK (~0x03) /* bit 1 is reserved if address_space = 1 */ /* 0x28-0x2f are reserved */ @@ -115,45 +119,310 @@ #define PCI_MIN_GNT 0x3e /* 8 bits */ #define PCI_MAX_LAT 0x3f /* 8 bits */ +#define PCI_CLASS_NOT_DEFINED 0x0000 +#define PCI_CLASS_NOT_DEFINED_VGA 0x0001 + +#define PCI_BASE_CLASS_STORAGE 0x01 +#define PCI_CLASS_STORAGE_SCSI 0x0100 +#define PCI_CLASS_STORAGE_IDE 0x0101 +#define PCI_CLASS_STORAGE_FLOPPY 0x0102 +#define PCI_CLASS_STORAGE_IPI 0x0103 +#define PCI_CLASS_STORAGE_OTHER 0x0180 + +#define PCI_BASE_CLASS_NETWORK 0x02 +#define PCI_CLASS_NETWORK_ETHERNET 0x0200 +#define PCI_CLASS_NETWORK_TOKEN_RING 0x0201 +#define PCI_CLASS_NETWORK_FDDI 0x0202 +#define PCI_CLASS_NETWORK_OTHER 0x0280 + +#define PCI_BASE_CLASS_DISPLAY 0x03 +#define PCI_CLASS_DISPLAY_VGA 0x0300 +#define PCI_CLASS_DISPLAY_XGA 0x0301 +#define PCI_CLASS_DISPLAY_OTHER 0x0380 + +#define PCI_BASE_CLASS_MULTIMEDIA 0x04 +#define PCI_CLASS_MULTIMEDIA_VIDEO 0x0400 +#define PCI_CLASS_MULTIMEDIA_AUDIO 0x0401 +#define PCI_CLASS_MULTIMEDIA_OTHER 0x0480 + +#define PCI_BASE_CLASS_MEMORY 0x05 +#define PCI_CLASS_MEMORY_RAM 0x0500 +#define PCI_CLASS_MEMORY_FLASH 0x0501 +#define PCI_CLASS_MEMORY_OTHER 0x0580 + +#define PCI_BASE_CLASS_BRIDGE 0x06 +#define PCI_CLASS_BRIDGE_HOST 0x0600 +#define PCI_CLASS_BRIDGE_ISA 0x0601 +#define PCI_CLASS_BRIDGE_EISA 0x0602 +#define PCI_CLASS_BRIDGE_MC 0x0603 +#define PCI_CLASS_BRIDGE_PCI 0x0604 +#define PCI_CLASS_BRIDGE_PCMCIA 0x0605 +#define PCI_CLASS_BRIDGE_OTHER 0x0680 + +#define PCI_CLASS_OTHERS 0xff + + #define PCI_VENDOR_ID_NCR 0x1000 #define PCI_DEVICE_ID_NCR_53C810 0x0001 +#define PCI_DEVICE_ID_NCR_53C815 0x0004 #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 +#define PCI_DEVICE_ID_ADAPTEC_294x 0x7078 + +#define PCI_VENDOR_ID_DPT 0x1044 +#define PCI_DEVICE_ID_DPT 0xa400 + +#define PCI_VENDOR_ID_S3 0x5333 +#define PCI_DEVICE_ID_S3_864_1 0x88c0 +#define PCI_DEVICE_ID_S3_864_2 0x88c1 +#define PCI_DEVICE_ID_S3_868 0x8880 +#define PCI_DEVICE_ID_S3_928 0x88b0 +#define PCI_DEVICE_ID_S3_964_1 0x88d0 +#define PCI_DEVICE_ID_S3_964_2 0x88d1 +#define PCI_DEVICE_ID_S3_811 0x8811 +#define PCI_DEVICE_ID_S3_968 0x88f0 + +#define PCI_VENDOR_ID_OPTI 0x1045 +#define PCI_DEVICE_ID_OPTI_82C822 0xc822 +#define PCI_DEVICE_ID_OPTI_82C621 0xc621 +#define PCI_DEVICE_ID_OPTI_82C557 0xc557 +#define PCI_DEVICE_ID_OPTI_82C558 0xc558 + +#define PCI_VENDOR_ID_UMC 0x1060 +#define PCI_DEVICE_ID_UMC_UM8881F 0x8881 +#define PCI_DEVICE_ID_UMC_UM8891A 0x0891 +#define PCI_DEVICE_ID_UMC_UM8886F 0x8886 +#define PCI_DEVICE_ID_UMC_UM8673F 0x0101 + +#define PCI_VENDOR_ID_DEC 0x1011 +#define PCI_DEVICE_ID_DEC_TULIP 0x0002 +#define PCI_DEVICE_ID_DEC_TULIP_FAST 0x0009 +#define PCI_DEVICE_ID_DEC_FDDI 0x000F +#define PCI_DEVICE_ID_DEC_BRD 0x0001 + +#define PCI_VENDOR_ID_MATROX 0x102B +#define PCI_DEVICE_ID_MATROX_MGA_2 0x0518 +#define PCI_DEVICE_ID_MATROX_MGA_IMP 0x0d10 + +#define PCI_VENDOR_ID_INTEL 0x8086 +#define PCI_DEVICE_ID_INTEL_82378 0x0484 +#define PCI_DEVICE_ID_INTEL_82424 0x0483 +#define PCI_DEVICE_ID_INTEL_82375 0x0482 +#define PCI_DEVICE_ID_INTEL_82434 0x04a3 +#define PCI_DEVICE_ID_INTEL_82430 0x0486 +#define PCI_DEVICE_ID_INTEL_82437 0x122d +#define PCI_DEVICE_ID_INTEL_82371 0x122e + +#define PCI_VENDOR_ID_SMC 0x1042 +#define PCI_DEVICE_ID_SMC_37C665 0x1000 + +#define PCI_VENDOR_ID_ATI 0x1002 +#define PCI_DEVICE_ID_ATI_M32 0x4158 +#define PCI_DEVICE_ID_ATI_M64 0x4758 + +#define PCI_VENDOR_ID_WEITEK 0x100e +#define PCI_DEVICE_ID_WEITEK_P9000 0x9001 +#define PCI_DEVICE_ID_WEITEK_P9100 0x9100 + +#define PCI_VENDOR_ID_CIRRUS 0x1013 +#define PCI_DEVICE_ID_CIRRUS_5430 0x00A0 +#define PCI_DEVICE_ID_CIRRUS_5434_4 0x00A4 +#define PCI_DEVICE_ID_CIRRUS_5434_8 0x00A8 +#define PCI_DEVICE_ID_CIRRUS_6729 0x1100 + +#define PCI_VENDOR_ID_BUSLOGIC 0x104B +#define PCI_DEVICE_ID_BUSLOGIC_946C 0x1040 +#define PCI_DEVICE_ID_BUSLOGIC_946C_2 0x0140 + +#define PCI_VENDOR_ID_N9 0x105D +#define PCI_DEVICE_ID_N9_I128 0x2309 + +#define PCI_VENDOR_ID_AI 0x1025 +#define PCI_DEVICE_ID_AI_M1435 0x1435 + +#define PCI_VENDOR_ID_AL 0x10b9 +#define PCI_DEVICE_ID_AL_M1445 0x1445 +#define PCI_DEVICE_ID_AL_M1449 0x1449 +#define PCI_DEVICE_ID_AL_M1451 0x1451 +#define PCI_DEVICE_ID_AL_M4803 0x5215 + +#define PCI_VENDOR_ID_TSENG 0x100c +#define PCI_DEVICE_ID_TSENG_W32P_2 0x3202 +#define PCI_DEVICE_ID_TSENG_W32P_b 0x3205 +#define PCI_DEVICE_ID_TSENG_W32P_c 0x3206 +#define PCI_DEVICE_ID_TSENG_W32P_d 0x3207 + +#define PCI_VENDOR_ID_CMD 0x1095 +#define PCI_DEVICE_ID_CMD_640 0x0640 + +#define PCI_VENDOR_ID_VISION 0x1098 +#define PCI_DEVICE_ID_VISION_QD8500 0x0001 +#define PCI_DEVICE_ID_VISION_QD8580 0x0002 + +#define PCI_VENDOR_ID_AMD 0x1022 +#define PCI_DEVICE_ID_AMD_LANCE 0x2000 +#define PCI_DEVICE_ID_AMD_SCSI 0x2020 -/* PCI BIOS */ +#define PCI_VENDOR_ID_VLSI 0x1004 +#define PCI_DEVICE_ID_VLSI_82C593 0x0006 +#define PCI_DEVICE_ID_VLSI_82C592 0x0005 -extern int pcibios_present (void); +#define PCI_VENDOR_ID_ADL 0x1005 +#define PCI_DEVICE_ID_ADL_2301 0x2301 -#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 +#define PCI_VENDOR_ID_SYMPHONY 0x1c1c +#define PCI_DEVICE_ID_SYMPHONY_101 0x0001 + +#define PCI_VENDOR_ID_TRIDENT 0x1023 +#define PCI_DEVICE_ID_TRIDENT_9420 0x9420 +#define PCI_DEVICE_ID_TRIDENT_9440 0x9440 + +#define PCI_VENDOR_ID_CONTAQ 0x1080 +#define PCI_DEVICE_ID_CONTAQ_82C599 0x0600 + +#define PCI_VENDOR_ID_NS 0x100b +#define PCI_DEVICE_ID_NS_87410 0xd001 + +#define PCI_VENDOR_ID_VIA 0x1106 +#define PCI_DEVICE_ID_VIA_82C505 0x0505 +#define PCI_DEVICE_ID_VIA_82C576 0x0576 +#define PCI_DEVICE_ID_VIA_82C561 0x0561 + +#define PCI_VENDOR_ID_SI 0x1039 +#define PCI_DEVICE_ID_SI_496 0x0496 +#define PCI_DEVICE_ID_SI_501 0x0406 +#define PCI_DEVICE_ID_SI_503 0x0008 +#define PCI_DEVICE_ID_SI_601 0x0601 + +#define PCI_VENDOR_ID_LEADTEK 0x107d +#define PCI_DEVICE_ID_LEADTEK_805 0x0000 + +#define PCI_VENDOR_ID_IMS 0x10e0 +#define PCI_DEVICE_ID_IMS_8849 0x8849 + +#define PCI_VENDOR_ID_ZEINET 0x1193 +#define PCI_DEVICE_ID_ZEINET_1221 0x0001 + +#define PCI_VENDOR_ID_EF 0x111a +#define PCI_DEVICE_ID_EF_ATM 0x0000 + +#define PCI_VENDOR_ID_HER 0xedd8 +#define PCI_DEVICE_ID_HER_STING 0xa091 + +#define PCI_VENDOR_ID_ATRONICS 0x907f +#define PCI_DEVICE_ID_ATRONICS_2015 0x2015 + +#define PCI_VENDOR_ID_CT 0x102c +#define PCI_DEVICE_ID_CT_65545 0x00d8 + +#define PCI_VENDOR_ID_FD 0x1036 +#define PCI_DEVICE_ID_FD_36C70 0x0000 + +#define PCI_VENDOR_ID_WINBOND 0x10ad +#define PCI_DEVICE_ID_WINBOND_83769 0x0001 + +#define PCI_VENDOR_ID_3COM 0x10b7 +#define PCI_DEVICE_ID_3COM_3C590 0x5900 +#define PCI_DEVICE_ID_3COM_3C595TX 0x5950 +#define PCI_DEVICE_ID_3COM_3C595T4 0x5951 +#define PCI_DEVICE_ID_3COM_3C595MII 0x5952 + +#define PCI_VENDOR_ID_PROMISE 0x105a +#define PCI_DEVICE_ID_PROMISE_5300 0x5300 + +#define PCI_VENDOR_ID_QLOGIC 0x1077 +#define PCI_DEVICE_ID_QLOGIC_ISP1020 0x1020 +#define PCI_DEVICE_ID_QLOGIC_ISP1022 0x1022 + +#define PCI_VENDOR_ID_X 0x1061 +#define PCI_DEVICE_ID_X_AGX016 0x0001 /* - * 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. + * The PCI interface treats multi-function devices as independent + * devices. The slot/function address of each device is encoded + * in a single byte as follows: + * + * 7:4 = slot + * 3:0 = function */ +#define PCI_DEVFN(slot,func) ((((slot) & 0x1f) << 3) | ((func) & 0x07)) +#define PCI_SLOT(devfn) (((devfn) >> 3) & 0x1f) +#define PCI_FUNC(devfn) ((devfn) & 0x07) + +/* + * There is one pci_dev structure for each slot-number/function-number + * combination: + */ +struct pci_dev { + struct pci_bus *bus; /* bus this device is on */ + struct pci_dev *sibling; /* next device on this bus */ + struct pci_dev *next; /* chain of all devices */ + + void *sysdata; /* hook for sys-specific extension */ + + unsigned int devfn; /* encoded device & function index */ + unsigned short vendor; + unsigned short device; + unsigned int class; /* 3 bytes: (base,sub,prog-if) */ + unsigned int master : 1; /* set if device is master capable */ + /* + * In theory, the irq level can be read from configuration + * space and all would be fine. However, old PCI chips don't + * support these registers and return 0 instead. For example, + * the Vision864-P rev 0 chip can uses INTA, but returns 0 in + * the interrupt line and pin registers. pci_init() + * initializes this field with the value at PCI_INTERRUPT_LINE + * and it is the job of pcibios_fixup() to change it if + * necessary. The field must not be 0 unless the device + * cannot generate interrupts at all. + */ + unsigned char irq; /* irq generated by this device */ +}; + +struct pci_bus { + struct pci_bus *parent; /* parent bus this bridge is on */ + struct pci_bus *children; /* chain of P2P bridges on this bus */ + struct pci_bus *next; /* chain of all PCI buses */ + + struct pci_dev *self; /* bridge device as seen by parent */ + struct pci_dev *devices; /* devices behind this bridge */ + + void *sysdata; /* hook for sys-specific extension */ + + unsigned char number; /* bus number */ + unsigned char primary; /* number of primary bridge */ + unsigned char secondary; /* number of secondary bridge */ + unsigned char subordinate; /* max number of subordinate buses */ +}; + +/* + * This is used to map a vendor-id/device-id pair into device-specific + * information. + */ +struct pci_dev_info { + unsigned short vendor; /* vendor id */ + unsigned short device; /* device id */ + + const char *name; /* device name */ + unsigned char bridge_type; /* bridge type or 0xff */ +}; + +extern struct pci_bus pci_root; /* root bus */ +extern struct pci_dev *pci_devices; /* list of all devices */ + + +extern unsigned long pci_init (unsigned long mem_start, unsigned long mem_end); + +extern struct pci_dev_info *pci_lookup_dev (unsigned int vendor, + unsigned int dev); +extern char *pci_strbioserr (int error); +extern const char *pci_strclass (unsigned int class); +extern const char *pci_strvendor (unsigned int vendor); +extern const char *pci_strdev (unsigned int vendor, unsigned int device); + +extern int get_pci_list (char *buf); -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 */ +#endif /* PCI_H */ diff --git a/include/linux/personality.h b/include/linux/personality.h index 4f292251a..47aa02c35 100644 --- a/include/linux/personality.h +++ b/include/linux/personality.h @@ -20,7 +20,7 @@ #define PER_WYSEV386 (0x0004 | STICKY_TIMEOUTS) #define PER_ISCR4 (0x0005 | STICKY_TIMEOUTS) #define PER_BSD (0x0006) - +#define PER_XENIX (0x0007 | STICKY_TIMEOUTS) /* Prototype for an lcall7 syscall handler. */ typedef asmlinkage void (*lcall7_func)(struct pt_regs *); diff --git a/include/linux/ppp.h b/include/linux/ppp.h index eaa15f933..233f961ec 100644 --- a/include/linux/ppp.h +++ b/include/linux/ppp.h @@ -1,233 +1,4 @@ -#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. + * Back compatibility for a while. */ - -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 */ - - +#include <linux/if_ppp.h> diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h index 70e25bf42..c70aa162a 100644 --- a/include/linux/proc_fs.h +++ b/include/linux/proc_fs.h @@ -1,6 +1,8 @@ #ifndef _LINUX_PROC_FS_H #define _LINUX_PROC_FS_H +#include <linux/config.h> + /* * The proc filesystem constants/structures */ @@ -12,6 +14,8 @@ enum root_directory_inos { PROC_MEMINFO, PROC_KMSG, PROC_VERSION, + PROC_CPUINFO, + PROC_PCI, PROC_SELF, /* will change inode # */ PROC_NET, #ifdef CONFIG_DEBUG_MALLOC @@ -24,7 +28,9 @@ enum root_directory_inos { PROC_INTERRUPTS, PROC_FILESYSTEMS, PROC_KSYMS, - PROC_DMA + PROC_DMA, + PROC_IOPORTS, + PROC_PROFILE /* whether enabled or not */ }; enum pid_directory_inos { @@ -58,11 +64,33 @@ enum net_directory_inos { #ifdef CONFIG_INET_RARP PROC_NET_RARP, #endif +#ifdef CONFIG_IP_MULTICAST + PROC_NET_IGMP, +#endif +#ifdef CONFIG_IP_FIREWALL + PROC_NET_IPFWFWD, + PROC_NET_IPFWBLK, +#endif +#ifdef CONFIG_IP_ACCT + PROC_NET_IPACCT, +#endif +#ifdef CONFIG_IP_MASQUERADE + PROC_NET_IPMSQHST, +#endif +#if defined(CONFIG_WAVELAN) + PROC_NET_WAVELAN, +#endif /* defined(CONFIG_WAVELAN) */ #endif #ifdef CONFIG_IPX + PROC_NET_IPX_INTERFACE, PROC_NET_IPX_ROUTE, PROC_NET_IPX, #endif +#ifdef CONFIG_ATALK + PROC_NET_ATALK, + PROC_NET_AT_ROUTE, + PROC_NET_ATIF, +#endif #ifdef CONFIG_AX25 PROC_NET_AX25_ROUTE, PROC_NET_AX25, @@ -72,6 +100,7 @@ enum net_directory_inos { PROC_NET_NR, #endif #endif + PROC_NET_SOCKSTAT, PROC_NET_LAST }; @@ -86,7 +115,7 @@ struct proc_dir_entry { 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_statfs(struct super_block *, struct statfs *, int); 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 *); @@ -96,7 +125,9 @@ 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_arraylong_inode_operations; extern struct inode_operations proc_kcore_inode_operations; +extern struct inode_operations proc_profile_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; diff --git a/include/linux/ptrace.h b/include/linux/ptrace.h index c98e66a68..0a02879d5 100644 --- a/include/linux/ptrace.h +++ b/include/linux/ptrace.h @@ -1,11 +1,9 @@ #ifndef _LINUX_PTRACE_H #define _LINUX_PTRACE_H +/* ptrace.h */ +/* structs and defines to help the user use the ptrace system call. */ -/* - * linux/include/linux/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 @@ -23,9 +21,6 @@ #define PTRACE_SYSCALL 24 -/* - * include machine dependend stuff - */ #include <asm/ptrace.h> #endif diff --git a/include/linux/resource.h b/include/linux/resource.h index 93db09bc9..ebbbcfa4e 100644 --- a/include/linux/resource.h +++ b/include/linux/resource.h @@ -35,30 +35,11 @@ struct rusage { 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; + long rlim_cur; + long rlim_max; }; #define PRIO_MIN (-99) @@ -68,4 +49,10 @@ struct rlimit { #define PRIO_PGRP 1 #define PRIO_USER 2 +/* + * Due to binary compatibility, the actual resource numbers + * may be different for different linux versions.. + */ +#include <asm/resource.h> + #endif diff --git a/include/linux/route.h b/include/linux/route.h index 3cadd206d..0f11ea2eb 100644 --- a/include/linux/route.h +++ b/include/linux/route.h @@ -21,18 +21,6 @@ #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 */ @@ -45,12 +33,13 @@ struct rtentry { 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 */ + unsigned long rt_mss; /* per route MTU/Window */ + unsigned long rt_window; /* Window clamping */ + unsigned short rt_irtt; /* Initial RTT */ }; -#define RTF_UP 0x0001 /* route usable */ +#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 */ @@ -58,6 +47,8 @@ struct rtentry { #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 */ +#define RTF_IRTT 0x0100 /* Initial round trip time */ +#define RTF_REJECT 0x0200 /* Reject route */ /* * REMOVE THESE BY 1.2.0 !!!!!!!!!!!!!!!!! diff --git a/include/linux/sbpcd.h b/include/linux/sbpcd.h index 1095175ae..ee7ec8d4c 100644 --- a/include/linux/sbpcd.h +++ b/include/linux/sbpcd.h @@ -3,7 +3,10 @@ */ /* - * the definitions for the first controller can get overridden by + * Attention! This file contains user-serviceable parts! + * I recommend to make use of it... + * + * The definitions for the first controller can get overridden by * the kernel command line ("lilo boot option"). * Examples: * sbpcd=0x230,SoundBlaster @@ -12,65 +15,102 @@ * or * sbpcd=0x330,SPEA * - * These strings are case sensitive !!! + * If sbpcd gets used as a module, you can load it with + * insmod /usr/src/linux/modules/sbpcd.o sbpcd=0x230,1 + * or + * insmod /usr/src/linux/modules/sbpcd.o sbpcd=0x300,0 + * or + * insmod /usr/src/linux/modules/sbpcd.o sbpcd=0x330,2 + * respective to override the configured address and type. */ /* - * put your CDROM port base address into CDROM_PORT - * and specify the type of your interface in SBPRO. + * define your CDROM port base address as CDROM_PORT + * and specify the type of your interface card as 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, ... + * Read linux/drivers/block/README.sbpcd if you are in doubt about the + * type of your interface card (you should do that anyway). * - * example: if your SBPRO audio address is 0x220, specify 0x230. + * address: + * ======== + * SBPRO type addresses typically are 0x0230 (=0x220+0x10), 0x0250, ... + * LASERMATE type (CI-101P, WDH-7001C) addresses typically are 0x0300, ... + * SPEA addresses are from the LASERMATE type and range. + * There are some soundcards on the market with 0x0630, 0x0650, ...; their + * type is not obvious (both types are possible). * + * example: if your SBPRO audio address is 0x220, specify 0x230 and SBPRO 1. + * if your soundcard has its CDROM port above 0x300, specify + * that address and try SBPRO 0 first. * + * interface type: + * =============== * 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 0 for "compatible" soundcards and + * for "poor" (no sound) interface cards. * 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 + * Almost all "compatible" sound boards need to set SBPRO to 0. + * If SBPRO is set wrong, the drives will get found - but any * data access will give errors (audio access will work). - * The OmniCD interface card from CreativeLabs needs SBPRO 1. + * The "OmniCD" no-sound 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. + * mail to emoenke@gwdg.de if you have a "compatible" sound card which + * in fact needs to set SBPRO to 1 (not any known at time). + * + * sound base: + * =========== + * The SOUND_BASE definition tells if we should try to turn the CD sound + * channels on. It will only be of use regarding soundcards with a SbPro + * compatible mixer. * * 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 +#if !(SBPCD_ISSUE-1) /* first (or if you have only one) interface board: */ +#define CDROM_PORT 0x340 /* <-----------<< port address */ +#define SBPRO 0 /* <-----------<< interface type */ +#define MAX_DRIVES 4 /* set to 1 if the card does not use "drive select" */ +#define SOUND_BASE 0x220 /* <-----------<< sound address of this card or 0 */ +#endif +#if !(SBPCD_ISSUE-2) /* ==================== second interface board: === */ +#define CDROM_PORT 0x344 /* <-----------<< port address */ +#define SBPRO 0 /* <-----------<< interface type */ +#define MAX_DRIVES 4 /* set to 1 if the card does not use "drive select" */ +#define SOUND_BASE 0x000 /* <-----------<< sound address of this card or 0 */ #endif -#if !(SBPCD_ISSUE-3) /* third interface board: */ -#define CDROM_PORT 0x0330 -#define SBPRO 0 +#if !(SBPCD_ISSUE-3) /* ===================== third interface board: === */ +#define CDROM_PORT 0x634 /* <-----------<< port address */ +#define SBPRO 1 /* <-----------<< interface type */ +#define MAX_DRIVES 4 /* set to 1 if the card does not use "drive select" */ +#define SOUND_BASE 0x240 /* <-----------<< sound address of this card or 0 */ #endif -#if !(SBPCD_ISSUE-4) /* fourth interface board: */ -#define CDROM_PORT 0x0340 -#define SBPRO 0 +#if !(SBPCD_ISSUE-4) /* ==================== fourth interface board: === */ +#define CDROM_PORT 0x634 /* <-----------<< port address */ +#define SBPRO 0 /* <-----------<< interface type */ +#define MAX_DRIVES 4 /* set to 1 if the card does not use "drive select" */ +#define SOUND_BASE 0x000 /* <-----------<< sound address of this card or 0 */ #endif +/* + * some more or less user dependent definitions - service them! + */ + +/* Set this to 0 after you have configured your interface definitions right. */ +#define DISTRIBUTION 1 + +/* max. number of audio frames to read with one */ +/* request (allocates n* 2352 bytes kernel memory!) */ +/* may be freely adjusted, f.e. 75 (= 1 sec.), at */ +/* runtime by use of the CDROMAUDIOBUFSIZ ioctl. */ +#define READ_AUDIO 0 + +/* tray control: eject tray if no disk is in (0 or 1) */ +#define JUKEBOX 1 + +/* tray control: eject tray after last use (0 or 1) */ +#define EJECT 1 + /*==========================================================================*/ /*==========================================================================*/ /* @@ -79,39 +119,65 @@ #ifndef _LINUX_SBPCD_H #define _LINUX_SBPCD_H +/*==========================================================================*/ +/*==========================================================================*/ +#define LONG_TIMING 0 /* test against timeouts with "gold" CDs on CR-521 */ +#undef FUTURE + +#define TEST_UPC 0 +#define SPEA_TEST 0 +#define TEST_STI 0 +#undef PATH_CHECK +/*==========================================================================*/ +/* + * DDI interface definitions + * "invented" by Fred N. van Kempen.. + */ +#define DDIOCSDBG 0x9000 /*==========================================================================*/ +/* + * "private" IOCTL functions + */ +#define CDROMRESET 0x5380 /* hard-rest the drive */ +#define CDROMVOLREAD 0x5381 /* let the drive tell its volume settings */ +#define CDROMAUDIOBUFSIZ 0x5382 /* set the audio buffer size */ + /*==========================================================================*/ /* * 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 */ +#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 /* cc_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_IDX 14 /* test code for drive_id !=0 */ +#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 functions */ +#define DBG_IO2 20 /* ioctl trace: general */ +#define DBG_UPC 21 /* show UPC information */ +#define DBG_XA1 22 /* XA mode debugging */ +#define DBG_LCK 23 /* door (un)lock info */ +#define DBG_SQ1 24 /* dump SubQ frame */ +#define DBG_AUD 25 /* READ AUDIO debugging */ +#define DBG_SEQ 26 /* Sequoia interface configuration trace */ +#define DBG_LCS 27 /* Longshine LCS-7260 debugging trace */ +#define DBG_CD2 28 /* MKE CD200 debugging trace */ +#define DBG_TEA 29 /* TEAC CD-55A debugging trace */ +#define DBG_TE2 30 /* TEAC CD-55A 2nd debugging level */ +#define DBG_000 31 /* unnecessary information */ /*==========================================================================*/ /*==========================================================================*/ @@ -119,130 +185,188 @@ /* * 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 +#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 +#define x80_bit 0x80 +#define upc_bit 0x40 +#define volume_bit 0x20 +#define toc_bit 0x10 +#define multisession_bit 0x08 +#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) +#define upc_valid (D_S[d].diskstate_flags&upc_bit) +#define volume_valid (D_S[d].diskstate_flags&volume_bit) +#define toc_valid (D_S[d].diskstate_flags&toc_bit) +#define cd_size_valid (D_S[d].diskstate_flags&cd_size_bit) +#define subq_valid (D_S[d].diskstate_flags&subq_bit) +#define frame_size_valid (D_S[d].diskstate_flags&frame_size_bit) +/* + * the status_bits variable + */ +#define p_success 0x100 +#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_disk_ok 0x01 /* - * bits of the status_byte (result of xx_ReadStatus): + * LCS-7260 special status result bits: */ -#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 +#define p_lcs_door_locked 0x02 +#define p_lcs_door_closed 0x01 + /* - * "old" drives status result bits: + * CR-52x special status result bits: */ -#define p_caddin_old 0x40 -#define p_success_old 0x08 -#define p_busy_old 0x04 +#define p_caddin_old 0x40 +#define p_success_old 0x08 +#define p_busy_old 0x04 +#define p_bit_1 0x02 /* hopefully unused now */ + +/* + * "generation specific" defs of the status result bits: + */ +#define p0_door_closed 0x80 +#define p0_caddy_in 0x40 +#define p0_spinning 0x20 +#define p0_check 0x10 +#define p0_success 0x08 /* unused */ +#define p0_busy 0x04 +#define p0_bit_1 0x02 /* unused */ +#define p0_disk_ok 0x01 + +#define pL_disk_in 0x40 +#define pL_spinning 0x20 +#define pL_check 0x10 +#define pL_success 0x08 /* unused ?? */ +#define pL_busy 0x04 +#define pL_door_locked 0x02 +#define pL_door_closed 0x01 + +#define p1_door_closed 0x80 +#define p1_disk_in 0x40 +#define p1_spinning 0x20 +#define p1_check 0x10 +#define p1_busy 0x08 +#define p1_door_locked 0x04 +#define p1_bit_1 0x02 /* unused */ +#define p1_disk_ok 0x01 + +#define p2_disk_ok 0x80 +#define p2_door_locked 0x40 +#define p2_spinning 0x20 +#define p2_busy2 0x10 +#define p2_busy1 0x08 +#define p2_door_closed 0x04 +#define p2_disk_in 0x02 +#define p2_check 0x01 /* * 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) +#define st_door_closed (D_S[d].status_bits&p_door_closed) +#define st_caddy_in (D_S[d].status_bits&p_caddy_in) +#define st_spinning (D_S[d].status_bits&p_spinning) +#define st_check (D_S[d].status_bits&p_check) +#define st_busy (D_S[d].status_bits&p_busy_new) +#define st_door_locked (D_S[d].status_bits&p_door_locked) +#define st_diskok (D_S[d].status_bits&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" */ +#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) +#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) +#define drv_fam0 0x08 /* CR-52x family */ +#define drv_199 (drv_fam0+0x01) /* <200 */ +#define drv_200 (drv_fam0+0x02) /* <201 */ +#define drv_201 (drv_fam0+0x03) /* <210 */ +#define drv_210 (drv_fam0+0x04) /* <211 */ +#define drv_211 (drv_fam0+0x05) /* <300 */ +#define drv_300 (drv_fam0+0x06) /* >=300 */ + +#define drv_famL 0x10 /* Longshine family */ +#define drv_260 (drv_famL+0x01) /* LCS-7260 */ +#define drv_e1 (drv_famL+0x01) /* LCS-7260, firmware "A E1" */ +#define drv_f4 (drv_famL+0x02) /* LCS-7260, firmware "A4F4" */ + +#define drv_fam1 0x20 /* CR-56x family */ +#define drv_099 (drv_fam1+0x01) /* <100 */ +#define drv_100 (drv_fam1+0x02) /* >=100, only 5.00 known here */ + +#define drv_famT 0x40 /* TEAC CD-55A */ +#define drv_fam2 0x80 /* CD200 family */ + +#define fam0_drive (D_S[d].drv_type&drv_fam0) +#define famL_drive (D_S[d].drv_type&drv_famL) +#define fam1_drive (D_S[d].drv_type&drv_fam1) +#define fam2_drive (D_S[d].drv_type&drv_fam2) +#define famT_drive (D_S[d].drv_type&drv_famT) +#define fam0L_drive (D_S[d].drv_type&(drv_fam0|drv_famL)) +#define fam1L_drive (D_S[d].drv_type&(drv_fam1|drv_famL)) +#define fam01_drive (D_S[d].drv_type&(drv_fam0|drv_fam1)) +#define fam12_drive (D_S[d].drv_type&(drv_fam1|drv_fam2)) +#define fam2T_drive (D_S[d].drv_type&(drv_fam2|drv_famT)) /* * audio states: */ -#define audio_playing 2 -#define audio_pausing 1 +#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 +#define speed_auto 0x80 +#define speed_300 0x40 +#define speed_150 0x20 +#define audio_mono 0x04 /* * 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 */ +#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 + * sense_byte: * * values: 00 + * 01 + * 81 * 82 "raw audio" mode * xx from infobuf[0] after 85 00 00 00 00 00 00 */ @@ -262,6 +386,50 @@ #define aud_14 0x14 /* Audio play operation stopped due to error */ #define aud_15 0x15 /* No current audio status to return */ + +/* + * 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) + +/*==========================================================================*/ + +#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; + +/*==========================================================================*/ + /*============================================================================ ============================================================================== @@ -413,56 +581,186 @@ Read XA Parameter: ============================================================================== ============================================================================*/ -/*==========================================================================*/ -/*==========================================================================*/ - -/* - * 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: + * commands + * + * CR-52x: CMD0_ + * CR-56x: CMD1_ + * CD200: CMD2_ + * LCS-7260: CMDL_ + * TEAC CD-55A: CMDT_ */ -#define READ_DATA(port, buf, nr) insb(port, buf, nr) +#define CMD1_RESET 0x0a +#define CMD2_RESET 0x01 +#define CMDT_RESET 0xc0 + +#define CMD1_LOCK_CTL 0x0c +#define CMD2_LOCK_CTL 0x1e +#define CMDT_LOCK_CTL CMD2_LOCK_CTL +#define CMDL_LOCK_CTL 0x0e + +#define CMD1_TRAY_CTL 0x07 +#define CMD2_TRAY_CTL 0x1b +#define CMDT_TRAY_CTL CMD2_TRAY_CTL +#define CMDL_TRAY_CTL 0x0d + +#define CMD1_MULTISESS 0x8d +#define CMDL_MULTISESS 0x8c + +#define CMD1_SUBCHANINF 0x11 +#define CMD2_SUBCHANINF 0x?? + +#define CMD1_ABORT 0x08 +#define CMD2_ABORT 0x08 +#define CMDT_ABORT 0x08 + +#define CMD2_x02 0x02 + +#define CMD2_SETSPEED 0xda + +#define CMD0_PATH_CHECK 0x00 +#define CMD1_PATH_CHECK 0x??? +#define CMD2_PATH_CHECK 0x??? +#define CMDT_PATH_CHECK 0x??? +#define CMDL_PATH_CHECK CMD0_PATH_CHECK + +#define CMD0_SEEK 0x01 +#define CMD1_SEEK CMD0_SEEK +#define CMD2_SEEK 0x2b +#define CMDT_SEEK CMD2_SEEK +#define CMDL_SEEK CMD0_SEEK + +#define CMD0_READ 0x02 +#define CMD1_READ 0x10 +#define CMD2_READ 0x28 +#define CMDT_READ CMD2_READ +#define CMDL_READ CMD0_READ + +#define CMD0_READ_XA 0x03 +#define CMD2_READ_XA 0xd4 +#define CMDL_READ_XA CMD0_READ_XA /* really ?? */ + +#define CMD0_READ_HEAD 0x04 + +#define CMD0_SPINUP 0x05 +#define CMD1_SPINUP 0x02 +#define CMD2_SPINUP CMD2_TRAY_CTL +#define CMDL_SPINUP CMD0_SPINUP + +#define CMD0_SPINDOWN 0x06 /* really??? */ +#define CMD1_SPINDOWN 0x06 +#define CMD2_SPINDOWN CMD2_TRAY_CTL +#define CMDL_SPINDOWN 0x0d + +#define CMD0_DIAG 0x07 + +#define CMD0_READ_UPC 0x08 +#define CMD1_READ_UPC 0x88 +#define CMD2_READ_UPC 0x??? +#define CMDL_READ_UPC CMD0_READ_UPC + +#define CMD0_READ_ISRC 0x09 + +#define CMD0_PLAY 0x0a +#define CMD1_PLAY 0x??? +#define CMD2_PLAY 0x??? +#define CMDL_PLAY CMD0_PLAY + +#define CMD0_PLAY_MSF 0x0b +#define CMD1_PLAY_MSF 0x0e +#define CMD2_PLAY_MSF 0x47 +#define CMDT_PLAY_MSF CMD2_PLAY_MSF +#define CMDL_PLAY_MSF 0x??? + +#define CMD0_PLAY_TI 0x0c +#define CMD1_PLAY_TI 0x0f + +#define CMD0_STATUS 0x81 +#define CMD1_STATUS 0x05 +#define CMD2_STATUS 0x00 +#define CMDT_STATUS CMD2_STATUS +#define CMDL_STATUS CMD0_STATUS + +#define CMD0_READ_ERR 0x82 +#define CMD1_READ_ERR CMD0_READ_ERR +#define CMD2_READ_ERR 0x03 +#define CMDT_READ_ERR CMD2_READ_ERR /* get audio status */ +#define CMDL_READ_ERR CMD0_READ_ERR + +#define CMD0_READ_VER 0x83 +#define CMD1_READ_VER CMD0_READ_VER +#define CMD2_READ_VER 0x12 +#define CMDT_READ_VER CMD2_READ_VER /* really ?? */ +#define CMDL_READ_VER CMD0_READ_VER + +#define CMD0_SETMODE 0x84 +#define CMD1_SETMODE 0x09 +#define CMD2_SETMODE 0x55 +#define CMDT_SETMODE CMD2_SETMODE +#define CMDL_SETMODE CMD0_SETMODE + +#define CMD0_GETMODE 0x85 +#define CMD1_GETMODE 0x84 +#define CMD2_GETMODE 0x5a +#define CMDT_GETMODE CMD2_GETMODE +#define CMDL_GETMODE CMD0_GETMODE + +#define CMD0_SET_XA 0x86 + +#define CMD0_GET_XA 0x87 + +#define CMD0_CAPACITY 0x88 +#define CMD1_CAPACITY 0x85 +#define CMD2_CAPACITY 0x25 +#define CMDL_CAPACITY CMD0_CAPACITY /* missing in some firmware versions */ + +#define CMD0_READSUBQ 0x89 +#define CMD1_READSUBQ 0x87 +#define CMD2_READSUBQ 0x42 +#define CMDT_READSUBQ CMD2_READSUBQ +#define CMDL_READSUBQ CMD0_READSUBQ + +#define CMD0_DISKCODE 0x8a + +#define CMD0_DISKINFO 0x8b +#define CMD1_DISKINFO CMD0_DISKINFO +#define CMD2_DISKINFO 0x43 +#define CMDT_DISKINFO CMD2_DISKINFO +#define CMDL_DISKINFO CMD0_DISKINFO + +#define CMD0_READTOC 0x8c +#define CMD1_READTOC CMD0_READTOC +#define CMD2_READTOC 0x??? +#define CMDL_READTOC CMD0_READTOC + +#define CMD0_PAU_RES 0x8d +#define CMD1_PAU_RES 0x0d +#define CMD2_PAU_RES 0x4b +#define CMDT_PAUSE CMD2_PAU_RES +#define CMDL_PAU_RES CMD0_PAU_RES + +#define CMD0_PACKET 0x8e +#define CMD1_PACKET CMD0_PACKET +#define CMD2_PACKET 0x??? +#define CMDL_PACKET CMD0_PACKET /*==========================================================================*/ - -#define MIXER_CD_Volume 0x28 /* internal SB Pro register address */ - /*==========================================================================*/ -/* - * Creative Labs Programmers did this: - */ -#define MAX_TRACKS 120 /* why more than 99? */ - +#endif _LINUX_SBPCD_H /*==========================================================================*/ /* - * To make conversions easier (machine dependent!) + * Overrides for Emacs so that we follow Linus's tabbing style. + * Emacs will notice this stuff at the end of the file and automatically + * adjust the settings for this buffer only. This must remain at the end + * of the file. + * --------------------------------------------------------------------------- + * Local variables: + * c-indent-level: 8 + * c-brace-imaginary-offset: 0 + * c-brace-offset: -8 + * c-argdecl-indent: 8 + * c-label-offset: -8 + * c-continued-statement-offset: 8 + * c-continued-brace-offset: 0 + * End: */ -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/scc.h b/include/linux/scc.h new file mode 100644 index 000000000..696eb4b12 --- /dev/null +++ b/include/linux/scc.h @@ -0,0 +1,553 @@ +/* $Id: scc.h,v 1.9 1995/01/12 18:24:40 JReuter Exp JReuter $ */ + +#ifndef _SCC_H +#define _SCC_H + +/* selection of hardware types */ + +#define PA0HZP 0x00 /* hardware type for PA0HZP SCC card and compatible */ +#define EAGLE 0x01 /* hardware type for EAGLE card */ +#define PC100 0x02 /* hardware type for PC100 card */ +#define PRIMUS 0x04 /* hardware type for PRIMUS-PC (DG9BL) card */ +#define DRSI 0x08 /* hardware type for DRSI PC*Packet card */ +#define BAYCOM 0x10 /* hardware type for BayCom (U)SCC */ + +/* Constants */ + +#define MAXSCC 4 /* number of max. supported chips */ +#define MAX_IBUFS 200 /* change this if you run out of memory */ +#define BUFSIZE 128 /* must not exceed 4096 */ +#define TPS 25 /* scc_timer(): Ticks Per Second */ + +#define SCC_TIMER 3 + +#define SCC_PARANOIA_CHECK /* tell the user if something is going wrong */ + +/* ioctl() commands */ + +/* !!! NEW VALUES !!! */ + +#define TIOCSCCINI 0x5470 /* init driver */ +#define TIOCCHANINI 0x5471 /* init channel */ + +#define TIOCGKISS 0x5472 /* get kiss parameter */ +#define TIOCSKISS 0x5473 /* set kiss parameter */ + +#define TIOCSCCSTAT 0x5474 /* get scc status */ + + +/* magic number */ + +#define SCC_MAGIC 0x8530 /* ;-) */ + +/* KISS protocol flags */ +#define FEND 192 +#define FESC 219 +#define TFEND 220 +#define TFESC 221 + +/* KISS state machine */ + +#define KISS_IDLE 0 +#define KISS_DATA 1 +#define KISS_ESCAPE 2 +#define KISS_RXFRAME 3 + +/* Device parameter control (from WAMPES) */ + +#define PARAM_TXDELAY 1 +#define PARAM_PERSIST 2 +#define PARAM_SLOTTIME 3 +#define PARAM_TXTAIL 4 +#define PARAM_FULLDUP 5 +#define PARAM_SOFTDCD 6 /* was: PARAM_HW */ +#define PARAM_MUTE 7 /* ??? */ +#define PARAM_DTR 8 +#define PARAM_RTS 9 +#define PARAM_SPEED 10 +#define PARAM_ENDDELAY 11 /* ??? */ +#define PARAM_GROUP 12 +#define PARAM_IDLE 13 +#define PARAM_MIN 14 +#define PARAM_MAXKEY 15 +#define PARAM_WAIT 16 +#define PARAM_MAXDEFER 17 +#define PARAM_TX 18 +#define PARAM_SLIP 19 +#define PARAM_RETURN 255 /* reset kiss mode */ + +#define TIMER_OFF 65535U /* to switch off timers */ +#define NO_SUCH_PARAM 65534U /* param not implemented */ + +/* channel grouping */ + +#define RXGROUP 0x100 /* if set, only tx when all channels clear */ +#define TXGROUP 0x200 /* if set, don't transmit simultaneously */ + +/* Tx/Rx clock sources */ + +#define CLK_DPLL 0 /* normal halfduplex operation */ +#define CLK_EXTERNAL 1 /* external clocking (G3RUH/DF9IC modems) */ +#define CLK_DIVIDER 2 /* Rx = DPLL, Tx = divider (fullduplex with */ + /* modems without clock regeneration */ + +/* Tx state */ + +#define TXS_IDLE 0 /* Transmitter off, no data pending */ +#define TXS_BUSY 1 /* waiting for permission to send / tailtime */ +#define TXS_ACTIVE 2 /* Transmitter on, sending data */ +#define TXS_NEWFRAME 3 /* reset CRC and send (next) frame */ + +#define TX_ON 1 /* command for scc_key_trx() */ +#define TX_OFF 0 /* dto */ + +/* Buffer management */ + +#define BT_RECEIVE 1 /* buffer allocated by receive */ +#define BT_TRANSMIT 2 /* buffer allocated by transmit */ + +#define QUEUE_THRES MAX_IBUFS/20 /* maximum amount of packets being queued */ +#define QUEUE_HYST 3 /* leave QUEUE_HYST packets untouched */ + +#define NULLBUF (struct mbuf *)0 +#define NULLBUFP (struct mbuf **)0 + + +typedef unsigned short io_port; /* type definition for an 'io port address' */ +typedef unsigned short ioaddr; /* old def */ + +#ifdef SCC_DELAY +#define Inb(port) inb_p(port) +#define Outb(port, val) outb_p(val, port) +#else +#define Inb(port) inb(port) +#define Outb(port, val) outb(val, port) +#endif + +/* some nasty macros (esp. Expired) */ + +#define TIMER_STOPPED 65535U +#define Running(k) (scc->k != TIMER_STOPPED) +#define Expired(k) (scc->k != TIMER_STOPPED) && (!(scc->k) || (--(scc->k) == 0)) +#define Stop_Timer(k) scc->k = TIMER_STOPPED + + +/* Basic message buffer structure */ + +/* looks familiar? Hmm, yes... */ + +struct mbuf { + struct mbuf *next; /* Links mbufs belonging to single packets */ + struct mbuf *anext; /* Links packets on queues */ + + char type; /* who allocated this buffer? */ + int time_out; /* unimplemented yet */ + + int size; /* Size of associated data buffer */ + int refcnt; /* Reference count */ + struct mbuf *dup; /* Pointer to duplicated mbuf */ + char data[BUFSIZE]; /* Active working pointers */ + int cnt; + int in_use; +}; + + +struct sccbuf { + struct mbuf *bp; + int inuse; +}; + + +/* SCC channel control structure for KISS */ + +struct scc_kiss { + unsigned char txdelay; /* Transmit Delay 10 ms/cnt */ + unsigned char persist; /* Persistence (0-255) as a % */ + unsigned char slottime; /* Delay to wait on persistence hit */ + unsigned char tailtime; /* Delay after XMTR OFF */ + unsigned char fulldup; /* Full Duplex mode 0=CSMA 1=DUP 2=ALWAYS KEYED */ + unsigned char waittime; /* Waittime before any transmit attempt */ + unsigned int maxkeyup; /* Maximum time to transmit (seconds) */ + unsigned char mintime; /* Minimal offtime after MAXKEYUP timeout */ + unsigned int idletime; /* Maximum idle time in ALWAYS KEYED mode (seconds) */ + unsigned int maxdefer; /* Timer for CSMA channel busy limit */ + unsigned char tx_inhibit; /* Transmit is not allowed when set */ + unsigned char group; /* group ID for AX.25 TX interlocking */ + unsigned char not_slip; /* set to zero: use SLIP instead of KISS */ + unsigned char softdcd; /* use DPLL instead of DCD pin for carrier detect */ +}; + + +/* SCC statistical information */ + +struct scc_stat { + long rxints; /* Receiver interrupts */ + long txints; /* Transmitter interrupts */ + long exints; /* External/status interrupts */ + long spints; /* Special receiver interrupts */ + + long txframes; /* Packets sent */ + long rxframes; /* Number of Frames Actally Received */ + long rxerrs; /* CRC Errors */ + long txerrs; /* KISS errors */ + + unsigned int nospace; /* "Out of buffers" */ + unsigned int rx_over; /* Receiver Overruns */ + unsigned int tx_under; /* Transmitter Underruns */ + + unsigned int tx_state; /* Transmitter state */ + + char tx_kiss_state; /* state of the kiss interpreter */ + char rx_kiss_state; /* state of the kiss encoder */ + + int tx_queued; /* tx frames enqueued */ + int rx_queued; /* rx frames enqueued */ + + unsigned int rx_alloc; /* allocated rx_buffers */ + unsigned int tx_alloc; /* allocated tx_buffers */ + unsigned int used_buf; /* used buffers (should be rx_alloc+tx_alloc) */ +}; + + +struct scc_modem{ + long speed; /* Line speed, bps */ + char clocksrc; /* 0 = DPLL, 1 = external, 2 = divider */ + char nrz; /* NRZ instead of NRZI */ +}; + +struct ioctl_command { + int command; /* one of the KISS-Commands devined above */ + unsigned param; /* KISS-Param */ +}; + +/* SCC channel structure */ + +struct scc_channel { + int magic; /* magic word */ + + int init; /* channel exists? */ + struct tty_struct *tty; /* link to tty control structure */ + unsigned char tty_opened; + + io_port ctrl; /* I/O address of CONTROL register */ + io_port data; /* I/O address of DATA register */ + char enhanced; /* Enhanced SCC support */ + + unsigned char wreg[16]; /* Copy of last written value in WRx */ + unsigned char status; /* Copy of R0 at last external interrupt */ + + struct scc_kiss kiss; /* control structure for KISS params */ + struct scc_stat stat; /* statistical information */ + struct scc_modem modem; /* modem information */ + + struct mbuf *rbp; /* rx: Head of mbuf chain being filled */ + struct mbuf *rbp1; /* rx: Pointer to mbuf currently being written */ + struct mbuf *rcvq; /* Pointer to mbuf packets currently received */ + + struct mbuf *sndq; /* tx: Packets awaiting transmission */ + struct mbuf *tbp; /* tx: Transmit mbuf being sent */ + + struct mbuf *sndq1; /* Pointer to mbuf currently under construction */ + struct mbuf *sndq2; /* Pointer to mbuf currently under construction */ + + + /* Timer */ + + unsigned int t_dwait; /* wait time (DWAIT) */ + unsigned int t_slot; /* channel sample frequency */ + unsigned int t_txdel; /* TX delay */ + unsigned int t_tail; /* tail time */ + unsigned int t_maxk; /* max. key up */ + unsigned int t_min; /* minimal key up */ + unsigned int t_idle; /* */ + unsigned int t_mbusy; /* time until defer if channel busy */ +}; + + + +/* 8530 Serial Communications Controller Register definitions */ +#define FLAG 0x7e + +/* Write Register 0 */ +#define R0 0 /* Register selects */ +#define R1 1 +#define R2 2 +#define R3 3 +#define R4 4 +#define R5 5 +#define R6 6 +#define R7 7 +#define R8 8 +#define R9 9 +#define R10 10 +#define R11 11 +#define R12 12 +#define R13 13 +#define R14 14 +#define R15 15 + +#define NULLCODE 0 /* Null Code */ +#define POINT_HIGH 0x8 /* Select upper half of registers */ +#define RES_EXT_INT 0x10 /* Reset Ext. Status Interrupts */ +#define SEND_ABORT 0x18 /* HDLC Abort */ +#define RES_RxINT_FC 0x20 /* Reset RxINT on First Character */ +#define RES_Tx_P 0x28 /* Reset TxINT Pending */ +#define ERR_RES 0x30 /* Error Reset */ +#define RES_H_IUS 0x38 /* Reset highest IUS */ + +#define RES_Rx_CRC 0x40 /* Reset Rx CRC Checker */ +#define RES_Tx_CRC 0x80 /* Reset Tx CRC Checker */ +#define RES_EOM_L 0xC0 /* Reset EOM latch */ + +/* Write Register 1 */ + +#define EXT_INT_ENAB 0x1 /* Ext Int Enable */ +#define TxINT_ENAB 0x2 /* Tx Int Enable */ +#define PAR_SPEC 0x4 /* Parity is special condition */ + +#define RxINT_DISAB 0 /* Rx Int Disable */ +#define RxINT_FCERR 0x8 /* Rx Int on First Character Only or Error */ +#define INT_ALL_Rx 0x10 /* Int on all Rx Characters or error */ +#define INT_ERR_Rx 0x18 /* Int on error only */ + +#define WT_RDY_RT 0x20 /* Wait/Ready on R/T */ +#define WT_FN_RDYFN 0x40 /* Wait/FN/Ready FN */ +#define WT_RDY_ENAB 0x80 /* Wait/Ready Enable */ + +/* Write Register 2 (Interrupt Vector) */ + +/* Write Register 3 */ + +#define RxENABLE 0x1 /* Rx Enable */ +#define SYNC_L_INH 0x2 /* Sync Character Load Inhibit */ +#define ADD_SM 0x4 /* Address Search Mode (SDLC) */ +#define RxCRC_ENAB 0x8 /* Rx CRC Enable */ +#define ENT_HM 0x10 /* Enter Hunt Mode */ +#define AUTO_ENAB 0x20 /* Auto Enables */ +#define Rx5 0x0 /* Rx 5 Bits/Character */ +#define Rx7 0x40 /* Rx 7 Bits/Character */ +#define Rx6 0x80 /* Rx 6 Bits/Character */ +#define Rx8 0xc0 /* Rx 8 Bits/Character */ + +/* Write Register 4 */ + +#define PAR_ENA 0x1 /* Parity Enable */ +#define PAR_EVEN 0x2 /* Parity Even/Odd* */ + +#define SYNC_ENAB 0 /* Sync Modes Enable */ +#define SB1 0x4 /* 1 stop bit/char */ +#define SB15 0x8 /* 1.5 stop bits/char */ +#define SB2 0xc /* 2 stop bits/char */ + +#define MONSYNC 0 /* 8 Bit Sync character */ +#define BISYNC 0x10 /* 16 bit sync character */ +#define SDLC 0x20 /* SDLC Mode (01111110 Sync Flag) */ +#define EXTSYNC 0x30 /* External Sync Mode */ + +#define X1CLK 0x0 /* x1 clock mode */ +#define X16CLK 0x40 /* x16 clock mode */ +#define X32CLK 0x80 /* x32 clock mode */ +#define X64CLK 0xC0 /* x64 clock mode */ + +/* Write Register 5 */ + +#define TxCRC_ENAB 0x1 /* Tx CRC Enable */ +#define RTS 0x2 /* RTS */ +#define SDLC_CRC 0x4 /* SDLC/CRC-16 */ +#define TxENAB 0x8 /* Tx Enable */ +#define SND_BRK 0x10 /* Send Break */ +#define Tx5 0x0 /* Tx 5 bits (or less)/character */ +#define Tx7 0x20 /* Tx 7 bits/character */ +#define Tx6 0x40 /* Tx 6 bits/character */ +#define Tx8 0x60 /* Tx 8 bits/character */ +#define DTR 0x80 /* DTR */ + +/* Write Register 6 (Sync bits 0-7/SDLC Address Field) */ + +/* Write Register 7 (Sync bits 8-15/SDLC 01111110) */ + +/* Write Register 8 (transmit buffer) */ + +/* Write Register 9 (Master interrupt control) */ +#define VIS 1 /* Vector Includes Status */ +#define NV 2 /* No Vector */ +#define DLC 4 /* Disable Lower Chain */ +#define MIE 8 /* Master Interrupt Enable */ +#define STATHI 0x10 /* Status high */ +#define NORESET 0 /* No reset on write to R9 */ +#define CHRB 0x40 /* Reset channel B */ +#define CHRA 0x80 /* Reset channel A */ +#define FHWRES 0xc0 /* Force hardware reset */ + +/* Write Register 10 (misc control bits) */ +#define BIT6 1 /* 6 bit/8bit sync */ +#define LOOPMODE 2 /* SDLC Loop mode */ +#define ABUNDER 4 /* Abort/flag on SDLC xmit underrun */ +#define MARKIDLE 8 /* Mark/flag on idle */ +#define GAOP 0x10 /* Go active on poll */ +#define NRZ 0 /* NRZ mode */ +#define NRZI 0x20 /* NRZI mode */ +#define FM1 0x40 /* FM1 (transition = 1) */ +#define FM0 0x60 /* FM0 (transition = 0) */ +#define CRCPS 0x80 /* CRC Preset I/O */ + +/* Write Register 11 (Clock Mode control) */ +#define TRxCXT 0 /* TRxC = Xtal output */ +#define TRxCTC 1 /* TRxC = Transmit clock */ +#define TRxCBR 2 /* TRxC = BR Generator Output */ +#define TRxCDP 3 /* TRxC = DPLL output */ +#define TRxCOI 4 /* TRxC O/I */ +#define TCRTxCP 0 /* Transmit clock = RTxC pin */ +#define TCTRxCP 8 /* Transmit clock = TRxC pin */ +#define TCBR 0x10 /* Transmit clock = BR Generator output */ +#define TCDPLL 0x18 /* Transmit clock = DPLL output */ +#define RCRTxCP 0 /* Receive clock = RTxC pin */ +#define RCTRxCP 0x20 /* Receive clock = TRxC pin */ +#define RCBR 0x40 /* Receive clock = BR Generator output */ +#define RCDPLL 0x60 /* Receive clock = DPLL output */ +#define RTxCX 0x80 /* RTxC Xtal/No Xtal */ + +/* Write Register 12 (lower byte of baud rate generator time constant) */ + +/* Write Register 13 (upper byte of baud rate generator time constant) */ + +/* Write Register 14 (Misc control bits) */ +#define BRENABL 1 /* Baud rate generator enable */ +#define BRSRC 2 /* Baud rate generator source */ +#define DTRREQ 4 /* DTR/Request function */ +#define AUTOECHO 8 /* Auto Echo */ +#define LOOPBAK 0x10 /* Local loopback */ +#define SEARCH 0x20 /* Enter search mode */ +#define RMC 0x40 /* Reset missing clock */ +#define DISDPLL 0x60 /* Disable DPLL */ +#define SSBR 0x80 /* Set DPLL source = BR generator */ +#define SSRTxC 0xa0 /* Set DPLL source = RTxC */ +#define SFMM 0xc0 /* Set FM mode */ +#define SNRZI 0xe0 /* Set NRZI mode */ + +/* Write Register 15 (external/status interrupt control) */ +#define ZCIE 2 /* Zero count IE */ +#define DCDIE 8 /* DCD IE */ +#define SYNCIE 0x10 /* Sync/hunt IE */ +#define CTSIE 0x20 /* CTS IE */ +#define TxUIE 0x40 /* Tx Underrun/EOM IE */ +#define BRKIE 0x80 /* Break/Abort IE */ + + +/* Read Register 0 */ +#define Rx_CH_AV 0x1 /* Rx Character Available */ +#define ZCOUNT 0x2 /* Zero count */ +#define Tx_BUF_EMP 0x4 /* Tx Buffer empty */ +#define DCD 0x8 /* DCD */ +#define SYNC_HUNT 0x10 /* Sync/hunt */ +#define CTS 0x20 /* CTS */ +#define TxEOM 0x40 /* Tx underrun */ +#define BRK_ABRT 0x80 /* Break/Abort */ + +/* Read Register 1 */ +#define ALL_SNT 0x1 /* All sent */ +/* Residue Data for 8 Rx bits/char programmed */ +#define RES3 0x8 /* 0/3 */ +#define RES4 0x4 /* 0/4 */ +#define RES5 0xc /* 0/5 */ +#define RES6 0x2 /* 0/6 */ +#define RES7 0xa /* 0/7 */ +#define RES8 0x6 /* 0/8 */ +#define RES18 0xe /* 1/8 */ +#define RES28 0x0 /* 2/8 */ +/* Special Rx Condition Interrupts */ +#define PAR_ERR 0x10 /* Parity error */ +#define Rx_OVR 0x20 /* Rx Overrun Error */ +#define CRC_ERR 0x40 /* CRC/Framing Error */ +#define END_FR 0x80 /* End of Frame (SDLC) */ + +/* Read Register 2 (channel B only) - Interrupt vector */ + +#define VECTOR_MASK 0x06 + +#define TXINT 0x00 +#define EXINT 0x02 +#define RXINT 0x04 +#define SPINT 0x06 + + +/* Read Register 3 (interrupt pending register) ch a only */ +#define CHBEXT 0x1 /* Channel B Ext/Stat IP */ +#define CHBTxIP 0x2 /* Channel B Tx IP */ +#define CHBRxIP 0x4 /* Channel B Rx IP */ +#define CHAEXT 0x8 /* Channel A Ext/Stat IP */ +#define CHATxIP 0x10 /* Channel A Tx IP */ +#define CHARxIP 0x20 /* Channel A Rx IP */ + +/* Read Register 8 (receive data register) */ + +/* Read Register 10 (misc status bits) */ +#define ONLOOP 2 /* On loop */ +#define LOOPSEND 0x10 /* Loop sending */ +#define CLK2MIS 0x40 /* Two clocks missing */ +#define CLK1MIS 0x80 /* One clock missing */ + +/* Read Register 12 (lower byte of baud rate generator constant) */ + +/* Read Register 13 (upper byte of baud rate generator constant) */ + +/* Read Register 15 (value of WR 15) */ + + +/* 8536 register definitions */ + +#define CIO_MICR 0x00 /* Master interrupt control register */ +#define CIO_MCCR 0x01 /* Master configuration control register */ +#define CIO_CTMS1 0x1c /* Counter/timer mode specification #1 */ +#define CIO_CTMS2 0x1d /* Counter/timer mode specification #2 */ +#define CIO_CTMS3 0x1e /* Counter/timer mode specification #3 */ +#define CIO_IVR 0x04 /* Interrupt vector register */ + +#define CIO_CSR1 0x0a /* Command and status register CTC #1 */ +#define CIO_CSR2 0x0b /* Command and status register CTC #2 */ +#define CIO_CSR3 0x0c /* Command and status register CTC #3 */ + +#define CIO_CT1MSB 0x16 /* CTC #1 Timer constant - MSB */ +#define CIO_CT1LSB 0x17 /* CTC #1 Timer constant - LSB */ +#define CIO_CT2MSB 0x18 /* CTC #2 Timer constant - MSB */ +#define CIO_CT2LSB 0x19 /* CTC #2 Timer constant - LSB */ +#define CIO_CT3MSB 0x1a /* CTC #3 Timer constant - MSB */ +#define CIO_CT3LSB 0x1b /* CTC #3 Timer constant - LSB */ +#define CIO_PDCA 0x23 /* Port A data direction control */ +#define CIO_PDCB 0x2b /* Port B data direction control */ + +#define CIO_GCB 0x04 /* CTC Gate command bit */ +#define CIO_TCB 0x02 /* CTC Trigger command bit */ +#define CIO_IE 0xc0 /* CTC Interrupt enable (set) */ +#define CIO_CIP 0x20 /* CTC Clear interrupt pending */ +#define CIO_IP 0x20 /* CTC Interrupt pending */ + + +/* 8580/85180/85280 Enhanced SCC register definitions */ + +/* Write Register 7' (SDLC/HDLC Programmable Enhancements) */ +#define AUTOTXF 0x01 /* Auto Tx Flag */ +#define AUTOEOM 0x02 /* Auto EOM Latch Reset */ +#define AUTORTS 0x04 /* Auto RTS */ +#define TXDNRZI 0x08 /* TxD Pulled High in SDLC NRZI mode */ +#define FASTDTR 0x10 /* Fast DTR/REQ Mode */ +#define CRCCBCR 0x20 /* CRC Check Bytes Completely Received */ +#define EXTRDEN 0x40 /* Extended Read Enabled */ + +/* Write Register 15 (external/status interrupt control) */ +#define SHDLCE 1 /* SDLC/HDLC Enhancements Enable */ +#define FIFOE 4 /* FIFO Enable */ + +/* Read Register 6 (frame status FIFO) */ +#define BCLSB 0xff /* LSB of 14 bits count */ + +/* Read Register 7 (frame status FIFO) */ +#define BCMSB 0x3f /* MSB of 14 bits count */ +#define FDA 0x40 /* FIFO Data Available Status */ +#define FOY 0x80 /* FIFO Overflow Status */ + +#endif /* _SCC_H */ + +/* global functions */ + +extern long scc_init(long kmem_start); diff --git a/include/linux/sched.h b/include/linux/sched.h index 76519a8b9..42bd0dcad 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -9,16 +9,15 @@ * #define DEBUG */ -#define HZ 100 +#include <asm/param.h> /* for HZ */ -/* - * System setup and hardware bug flags.. - */ -extern int hard_math; +extern unsigned long intr_count; +extern unsigned long event; #include <linux/binfmts.h> #include <linux/personality.h> #include <linux/tasks.h> +#include <linux/kernel.h> #include <asm/system.h> /* @@ -31,43 +30,46 @@ extern int hard_math; * the EXP_n values would be 1981, 2034 and 2043 if still using only * 11 bit fractions. */ -extern unsigned long avenrun[]; /* Load averages */ +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 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 CT_TO_SECS(x) ((x) / HZ) +#define CT_TO_USECS(x) (((x) % HZ) * 1000000/HZ) + +extern int nr_running, nr_tasks; #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/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 +#include <asm/processor.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) @@ -75,6 +77,8 @@ extern unsigned long avenrun[]; /* Load averages */ #ifdef __KERNEL__ +#define barrier() __asm__("": : :"memory") + extern void sched_init(void); extern void show_state(void); extern void trap_init(void); @@ -116,15 +120,13 @@ struct mm_struct { 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 -*/ + 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; + struct vm_area_struct * mmap_avl; }; -#define INIT_MMAP { &init_task, 0, 0x40000000, PAGE_SHARED, } - #define INIT_MM { \ 0, \ 0, 0, 0, \ @@ -134,24 +136,116 @@ struct mm_struct { /* ?_flt */ 0, 0, 0, 0, \ 0, \ /* swap */ 0, 0, 0, 0, \ - &init_mmap } + &init_mmap, &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 task_struct *next_run, *prev_run; + 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,tty_old_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]; +/* file system info */ + int link_count; + struct tty_struct *tty; /* NULL if no tty */ +/* ipc stuff */ + struct sem_undo *semundo; + struct sem_queue *semsleeping; +/* ldt for this task - used by Wine. If NULL, default_ldt is used */ + struct desc_struct *ldt; +/* tss for this task */ + struct thread_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 */ +#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 */ +#define PF_PTRACED 0x00000010 /* set if ptrace (0) has been called. */ +#define PF_TRACESYS 0x00000020 /* tracing system calls */ + +#define PF_STARTING 0x00000100 /* being created */ +#define PF_EXITING 0x00000200 /* getting shut down */ /* * cloning flags: */ #define CSIGNAL 0x000000ff /* signal mask to be sent at exit */ -#define COPYVM 0x00000100 /* set if VM copy desired (like normal f -ork()) */ -#define COPYFD 0x00000200 /* set if fd's should be copied, not sha -red (NI) */ +#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, &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,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}, \ + {MAX_TASKS_PER_USER, MAX_TASKS_PER_USER}, {NR_OPEN, NR_OPEN}}, \ +/* math */ 0, \ +/* comm */ "swapper", \ +/* fs info */ 0,NULL, \ +/* ipc */ NULL, NULL, \ +/* ldt */ NULL, \ +/* tss */ INIT_TSS, \ +/* fs */ { INIT_FS }, \ +/* files */ { INIT_FILES }, \ +/* mm */ { INIT_MM } \ +} #ifdef __KERNEL__ @@ -176,31 +270,34 @@ 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 int request_irq(unsigned int irq,void (*handler)(int, struct pt_regs *), + unsigned long flags, const char *device); extern void free_irq(unsigned int irq); +extern void copy_thread(int, unsigned long, unsigned long, struct task_struct *, struct pt_regs *); +extern void flush_thread(void); +extern void exit_thread(void); + +extern int do_execve(char *, char **, char **, struct pt_regs *); +extern int do_fork(unsigned long, unsigned long, struct pt_regs *); +asmlinkage int do_signal(unsigned long, struct pt_regs *); + /* * 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) +extern inline void add_wait_queue(struct wait_queue ** p, struct wait_queue * wait) { - unsigned long flags; + unsigned long flags; -#if defined (DEBUG) && defined (__mips__) - /* - * FIXME: I don't work for MIPS yet - */ +#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); - } + printk("add_wait_queue (%08x): wait->next = %08x\n",pc,(unsigned long) wait->next); + } #endif save_flags(flags); cli(); @@ -214,37 +311,27 @@ extern inline void add_wait_queue(struct wait_queue ** p, restore_flags(flags); } -extern inline void remove_wait_queue(struct wait_queue ** p, - struct wait_queue *wait) +extern inline void remove_wait_queue(struct wait_queue ** p, struct wait_queue * wait) { unsigned long flags; struct wait_queue * tmp; -#if defined (DEBUG) && !defined(__mips__) - /* - * FIXME: I don't work for MIPS yet - */ +#ifdef DEBUG unsigned long ok = 0; #endif save_flags(flags); cli(); if ((*p == wait) && -#if defined (DEBUG) && !defined(__mips__) - /* - * FIXME: I don't work for MIPS yet - */ +#ifdef DEBUG (ok = 1) && #endif ((*p = wait->next) == wait)) { *p = NULL; - } else { + } else { tmp = wait; while (tmp->next != wait) { tmp = tmp->next; -#if defined (DEBUG) && !defined(__mips__) - /* - * FIXME: I don't work for MIPS yet - */ +#ifdef DEBUG if (tmp == *p) ok = 1; #endif @@ -253,22 +340,17 @@ extern inline void remove_wait_queue(struct wait_queue ** p, } wait->next = NULL; restore_flags(flags); -#if defined (DEBUG) && !defined(__mips__) - /* - * FIXME: I don't work for MIPS yet - */ +#ifdef DEBUG if (!ok) { printk("removed wait_queue not on list.\n"); - printk("list = %08x, queue = %08x\n",(unsigned long) p, (unsigne -d long) wait); + 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) +extern inline void select_wait(struct wait_queue ** wait_address, select_table * p) { struct select_table_entry * entry; @@ -276,7 +358,7 @@ extern inline void select_wait(struct wait_queue ** wait_address, return; if (p->nr >= __MAX_SELECT_TABLE_ENTRIES) return; - entry = p->entry + p->nr; + entry = p->entry + p->nr; entry->wait_address = wait_address; entry->wait.task = current; entry->wait.next = NULL; @@ -300,7 +382,7 @@ extern inline void up(struct semaphore * sem) { sem->count++; wake_up(&sem->wait); -} +} #define REMOVE_LINKS(p) do { unsigned long flags; \ save_flags(flags) ; cli(); \ @@ -333,9 +415,4 @@ extern inline void up(struct semaphore * sem) #endif /* __KERNEL__ */ -/* - * Include machine dependent stuff - */ -#include <asm/sched.h> - #endif diff --git a/include/linux/sem.h b/include/linux/sem.h index 52189879b..9484d233e 100644 --- a/include/linux/sem.h +++ b/include/linux/sem.h @@ -3,7 +3,7 @@ #include <linux/ipc.h> /* semop flags */ -#define SEM_UNDO 010000 /* undo the operation on exit */ +#define SEM_UNDO 0x1000 /* undo the operation on exit */ /* semctl Command Definitions. */ #define GETPID 11 /* get sempid */ @@ -16,14 +16,14 @@ /* 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 */ + 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 sem_queue *sem_pending; /* pending operations to be processed */ + struct sem_queue **sem_pending_last; /* last pending operation */ + 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. */ @@ -43,16 +43,16 @@ union semun { }; struct seminfo { - int semmap; - int semmni; - int semmns; - int semmnu; - int semmsl; - int semopm; - int semume; - int semusz; - int semvmx; - int semaem; + 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 */ @@ -66,31 +66,42 @@ struct seminfo { #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 */ +#define SEMUSZ 20 /* sizeof struct sem_undo */ #ifdef __KERNEL__ /* One semaphore structure for each semaphore in the system. */ struct sem { + short semval; /* current value */ 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_STAT 18 #define SEM_INFO 19 -/* per process undo requests */ -/* this gets linked into the task_struct */ +/* One queue for each semaphore set in the system. */ +struct sem_queue { + struct sem_queue * next; /* next entry in the queue */ + struct sem_queue ** prev; /* previous entry in the queue, *(q->prev) == q */ + struct wait_queue * sleeper; /* sleeping process */ + struct sem_undo * undo; /* undo structure */ + int pid; /* process id of requesting process */ + int status; /* completion status of operation */ + struct semid_ds * sma; /* semaphore array for operations */ + struct sembuf * sops; /* array of pending operations */ + int nsops; /* number of operations */ +}; + +/* Each task has a list of undo requests. They are executed automatically + * when the process exits. + */ 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 */ -}; + struct sem_undo * proc_next; /* next entry on this process */ + struct sem_undo * id_next; /* next entry on this semaphore set */ + int semid; /* semaphore set identifier */ + short * semadj; /* array of adjustments, one per semaphore */ +}; #endif /* __KERNEL__ */ diff --git a/include/linux/serial.h b/include/linux/serial.h index 1877f42b2..02af4746a 100644 --- a/include/linux/serial.h +++ b/include/linux/serial.h @@ -13,7 +13,7 @@ struct serial_struct { int type; int line; - int port; + unsigned int port; int irq; int flags; int xmit_fifo_size; @@ -22,10 +22,19 @@ struct serial_struct { unsigned short close_delay; char reserved_char[2]; int hub6; - int reserved[5]; + unsigned short closing_wait; /* time to wait before closing */ + unsigned short closing_wait2; /* no longer used... */ + int reserved[4]; }; /* + * For the close wait times, 0 means wait forever for serial port to + * flush its output. 65535 means don't wait at all. + */ +#define ASYNC_CLOSING_WAIT_INF 0 +#define ASYNC_CLOSING_WAIT_NONE 65535 + +/* * These are the supported serial types. */ #define PORT_UNKNOWN 0 @@ -33,7 +42,9 @@ struct serial_struct { #define PORT_16450 2 #define PORT_16550 3 #define PORT_16550A 4 -#define PORT_MAX 4 +#define PORT_CIRRUS 5 +#define PORT_16650 6 +#define PORT_MAX 6 /* * Definitions for async_struct (and serial_struct) flags field @@ -69,6 +80,23 @@ struct serial_struct { #define ASYNC_CTS_FLOW 0x04000000 /* Do CTS flow control */ #define ASYNC_CHECK_CD 0x02000000 /* i.e., CLOCAL */ +/* + * Multiport serial configuration structure --- external structure + */ +struct serial_multiport_struct { + int irq; + int port1; + unsigned char mask1, match1; + int port2; + unsigned char mask2, match2; + int port3; + unsigned char mask3, match3; + int port4; + unsigned char mask4, match4; + int port_monitor; + int reserved[32]; +}; + #ifdef __KERNEL__ /* * This is our internal structure for each serial port's state. @@ -95,10 +123,12 @@ struct async_struct { int custom_divisor; int x_char; /* xon/xoff character */ int close_delay; + unsigned short closing_wait; + unsigned short closing_wait2; int IER; /* Interrupt Enable Register */ int MCR; /* Modem control register */ int MCR_noint; /* MCR with interrupts off */ - int event; + unsigned long event; unsigned long last_active; int line; int count; /* # of fd on device */ @@ -110,6 +140,7 @@ struct async_struct { int xmit_tail; int xmit_cnt; struct tq_struct tqueue; + struct tq_struct tqueue_hangup; struct termios normal_termios; struct termios callout_termios; struct wait_queue *open_wait; @@ -130,7 +161,21 @@ struct async_struct { * time, instead of at rs interrupt time. */ #define RS_EVENT_WRITE_WAKEUP 0 -#define RS_EVENT_HANGUP 1 + +/* + * Multiport serial configuration structure --- internal structure + */ +struct rs_multiport_struct { + int port1; + unsigned char mask1, match1; + int port2; + unsigned char mask2, match2; + int port3; + unsigned char mask3, match3; + int port4; + unsigned char mask4, match4; + int port_monitor; +}; /* Export to allow PCMCIA to use this - Dave Hinds */ extern int register_serial(struct serial_struct *req); diff --git a/include/linux/serial_reg.h b/include/linux/serial_reg.h index 5e983fc1c..19d7c0ba7 100644 --- a/include/linux/serial_reg.h +++ b/include/linux/serial_reg.h @@ -21,6 +21,8 @@ #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_EFR 2 /* I/O: Extended Features Register */ + /* (DLAB=1, 16C660 only) */ #define UART_LCR 3 /* Out: Line Control Register */ #define UART_MCR 4 /* Out: Modem Control Register */ #define UART_LSR 5 /* In: Line Status Register */ @@ -29,6 +31,7 @@ /* * These are the definitions for the FIFO Control Register + * (16650 only) */ #define UART_FCR_ENABLE_FIFO 0x01 /* Enable the FIFO */ #define UART_FCR_CLEAR_RCVR 0x02 /* Clear the RCVR FIFO */ @@ -39,6 +42,15 @@ #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 */ +/* 16650 redefinitions */ +#define UART_FCR6_R_TRIGGER_8 0x00 /* Mask for receive trigger set at 1 */ +#define UART_FCR6_R_TRIGGER_16 0x40 /* Mask for receive trigger set at 4 */ +#define UART_FCR6_R_TRIGGER_24 0x80 /* Mask for receive trigger set at 8 */ +#define UART_FCR6_R_TRIGGER_28 0xC0 /* Mask for receive trigger set at 14 */ +#define UART_FCR6_T_TRIGGER_16 0x00 /* Mask for transmit trigger set at 16 */ +#define UART_FCR6_T_TRIGGER_8 0x10 /* Mask for transmit trigger set at 8 */ +#define UART_FCR6_T_TRIGGER_24 0x20 /* Mask for transmit trigger set at 24 */ +#define UART_FCR6_T_TRIGGER_30 0x30 /* Mask for transmit trigger set at 30 */ /* * These are the definitions for the Line Control Register @@ -109,5 +121,17 @@ #define UART_MSR_DCTS 0x01 /* Delta CTS */ #define UART_MSR_ANY_DELTA 0x0F /* Any of the delta bits! */ +/* + * These are the definitions for the Extended Features Register + * (StarTech 16C660 only, when DLAB=1) + */ +#define UART_EFR_CTS 0x80 /* CTS flow control */ +#define UART_EFR_RTS 0x40 /* RTS flow control */ +#define UART_EFR_SCD 0x20 /* Special character detect */ +#define UART_EFR_ENI 0x10 /* Enhanced Interrupt */ +/* + * the low four bits control software flow control + */ + #endif /* _LINUX_SERIAL_REG_H */ diff --git a/include/linux/shm.h b/include/linux/shm.h index c8e391906..2faa4e63d 100644 --- a/include/linux/shm.h +++ b/include/linux/shm.h @@ -50,7 +50,6 @@ struct shminfo { 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 @@ -63,9 +62,7 @@ struct shminfo { #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 +/* We must have SHM_ID_SHIFT + _SHM_ID_BITS + _SHM_IDX_BITS <= 32 and SHMMAX <= (PAGE_SIZE << _SHM_IDX_BITS). */ #define SHMMAX 0x3fa000 /* max shared seg size (bytes) */ diff --git a/include/linux/signal.h b/include/linux/signal.h index 4527fae69..9d1afa91c 100644 --- a/include/linux/signal.h +++ b/include/linux/signal.h @@ -1,84 +1,6 @@ #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); -}; - -/* - * Include machine dependencies - */ #include <asm/signal.h> #endif diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index fca7ba7cd..e831eb130 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -16,8 +16,9 @@ #include <linux/malloc.h> #include <linux/wait.h> #include <linux/time.h> +#include <linux/config.h> -#define CONFIG_SKB_CHECK 1 +#undef CONFIG_SKB_CHECK #define HAVE_ALLOC_SKB /* For the drivers to know */ @@ -36,17 +37,17 @@ struct sk_buff_head { struct sk_buff { - struct sk_buff * volatile next; - struct sk_buff * volatile prev; + struct sk_buff * volatile next; /* Next buffer in list */ + struct sk_buff * volatile prev; /* Previous buffer in list */ #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; + struct sk_buff * volatile link3; /* Link for IP protocol level buffer chains */ + struct sock *sk; /* Socket we are owned by */ + volatile unsigned long when; /* used to compute rtt's */ + struct timeval stamp; /* Time we arrived */ + struct device *dev; /* Device we arrived on/are leaving by */ + struct sk_buff *mem_addr; /* Self reference (obsolete) */ union { struct tcphdr *th; struct ethhdr *eth; @@ -55,30 +56,34 @@ struct sk_buff { 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) */ + struct iphdr *ip_hdr; /* For IPPROTO_RAW */ + unsigned long mem_len; /* Length of allocated memory */ + unsigned long len; /* Length of actual data */ + unsigned long fraglen; /* Unused (yet) */ + struct sk_buff *fraglist; /* Fragment list */ + unsigned long truesize; /* True buffer size (obsolete) */ + unsigned long saddr; /* IP source address */ + unsigned long daddr; /* IP target address */ + unsigned long raddr; /* IP next hop address */ + volatile char acked, /* Are we acked ? */ + used, /* Are we in use ? */ + free, /* How to free this buffer */ + arp; /* Has IP/ARP resolution finished */ + unsigned char tries, /* Times tried */ + lock, /* Are we locked ? */ + localroute, /* Local routing asserted for this frame */ + pkt_type; /* Packet class */ +#define PACKET_HOST 0 /* To us */ +#define PACKET_BROADCAST 1 /* To all */ +#define PACKET_MULTICAST 2 /* To group */ +#define PACKET_OTHERHOST 3 /* To someone else */ + unsigned short users; /* User count - see datagram.c,tcp.c */ + unsigned short protocol; /* Packet protocol from driver. */ #ifdef CONFIG_SLAVE_BALANCING unsigned short in_dev_queue; #endif - unsigned long padding[0]; - unsigned char data[0]; + unsigned long padding[0]; /* Force long word alignment */ + unsigned char data[0]; /* Data follows */ }; #define SK_WMEM_MAX 32767 @@ -94,7 +99,9 @@ struct sk_buff { /* * Handling routines are only of interest to the kernel */ - + +#include <asm/system.h> + #if 0 extern void print_skb(struct sk_buff *); #endif @@ -131,8 +138,151 @@ 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 +#define IS_SKB(skb) +#define IS_SKB_HEAD(skb) + +extern __inline__ void skb_queue_head_init(struct sk_buff_head *list) +{ + list->prev = (struct sk_buff *)list; + list->next = (struct sk_buff *)list; +} + +/* + * Insert an sk_buff at the start of a list. + */ + +extern __inline__ void skb_queue_head(struct sk_buff_head *list_,struct sk_buff *newsk) +{ + unsigned long flags; + struct sk_buff *list = (struct sk_buff *)list_; + + save_flags(flags); + cli(); + newsk->next = list->next; + newsk->prev = list; + newsk->next->prev = newsk; + newsk->prev->next = newsk; + restore_flags(flags); +} + +/* + * Insert an sk_buff at the end of a list. + */ + +extern __inline__ void skb_queue_tail(struct sk_buff_head *list_, struct sk_buff *newsk) +{ + unsigned long flags; + struct sk_buff *list = (struct sk_buff *)list_; + + save_flags(flags); + cli(); + + newsk->next = list; + newsk->prev = list->prev; + + newsk->next->prev = newsk; + newsk->prev->next = newsk; + + restore_flags(flags); +} + +/* + * Remove an sk_buff from a list. This routine is also interrupt safe + * so you can grab read and free buffers as another process adds them. + * + * Note we now do the ful list + */ + +extern __inline__ struct sk_buff *skb_dequeue(struct sk_buff_head *list_) +{ + long flags; + struct sk_buff *result; + struct sk_buff *list = (struct sk_buff *)list_; + + save_flags(flags); + cli(); + + result = list->next; + if (result == list) + { + restore_flags(flags); + return NULL; + } + else + { + result->next->prev = list; + list->next = result->next; + + result->next = NULL; + result->prev = NULL; + + restore_flags(flags); + + return result; + } +} + +/* + * Insert a packet before another one in a list. + */ + +extern __inline__ void skb_insert(struct sk_buff *old, struct sk_buff *newsk) +{ + unsigned long flags; + + save_flags(flags); + cli(); + newsk->next = old; + newsk->prev = old->prev; + old->prev = newsk; + newsk->prev->next = newsk; + + restore_flags(flags); +} + +/* + * Place a packet after a given packet in a list. + */ + +extern __inline__ void skb_append(struct sk_buff *old, struct sk_buff *newsk) +{ + unsigned long flags; + + save_flags(flags); + cli(); + + newsk->prev = old; + newsk->next = old->next; + newsk->next->prev = newsk; + old->next = newsk; + + restore_flags(flags); +} + +/* + * Remove an sk_buff from its list. Works even without knowing the list it + * is sitting on, which can be handy at times. It also means that THE LIST + * MUST EXIST when you unlink. Thus a list must have its contents unlinked + * _FIRST_. + */ + +extern __inline__ void skb_unlink(struct sk_buff *skb) +{ + unsigned long flags; + + save_flags(flags); + cli(); + + if(skb->prev && skb->next) + { + skb->next->prev = skb->prev; + skb->prev->next = skb->next; + skb->next = NULL; + skb->prev = NULL; + } + restore_flags(flags); +} + #endif extern struct sk_buff * skb_recv_datagram(struct sock *sk,unsigned flags,int noblock, int *err); diff --git a/include/linux/socket.h b/include/linux/socket.h index 224880172..44cff1fc4 100644 --- a/include/linux/socket.h +++ b/include/linux/socket.h @@ -28,12 +28,16 @@ struct linger { /* 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.. */ +#define AF_UNIX 1 /* Unix domain sockets */ +#define AF_INET 2 /* Internet IP Protocol */ +#define AF_AX25 3 /* Amateur Radio AX.25 */ +#define AF_IPX 4 /* Novell IPX */ +#define AF_APPLETALK 5 /* Appletalk DDP */ +#define AF_NETROM 6 /* Amateur radio NetROM */ +#define AF_BRIDGE 7 /* Multiprotocol bridge */ +#define AF_AAL5 8 /* Reserved for Werner's ATM */ +#define AF_X25 9 /* Reserved for X.25 project */ +#define AF_MAX 12 /* For now.. */ /* Protocol families, same as address families. */ #define PF_UNSPEC AF_UNSPEC @@ -41,8 +45,14 @@ struct linger { #define PF_INET AF_INET #define PF_AX25 AF_AX25 #define PF_IPX AF_IPX +#define PF_APPLETALK AF_APPLETALK +#define PF_NETROM AF_NETROM +#define PF_BRIDGE AF_BRIDGE +#define PF_AAL5 AF_AAL5 +#define PF_X25 AF_X25 #define PF_MAX AF_MAX + /* Flags we can use with send/ and recv. */ #define MSG_OOB 1 #define MSG_PEEK 2 @@ -53,6 +63,8 @@ struct linger { #define SOL_IP 0 #define SOL_IPX 256 #define SOL_AX25 257 +#define SOL_ATALK 258 +#define SOL_NETROM 259 #define SOL_TCP 6 #define SOL_UDP 17 @@ -70,6 +82,7 @@ struct linger { #define SO_NO_CHECK 11 #define SO_PRIORITY 12 #define SO_LINGER 13 +/* To add :#define SO_REUSEPORT 14 */ /* IP options */ #define IP_TOS 1 @@ -77,7 +90,23 @@ struct linger { #define IPTOS_THROUGHPUT 0x08 #define IPTOS_RELIABILITY 0x04 #define IP_TTL 2 - +#ifdef V1_3_WILL_DO_THIS_FUNKY_STUFF +#define IP_HRDINCL 3 +#define IP_OPTIONS 4 +#endif + +#define IP_MULTICAST_IF 32 +#define IP_MULTICAST_TTL 33 +#define IP_MULTICAST_LOOP 34 +#define IP_ADD_MEMBERSHIP 35 +#define IP_DROP_MEMBERSHIP 36 + + +/* These need to appear somewhere around here */ +#define IP_DEFAULT_MULTICAST_TTL 1 +#define IP_DEFAULT_MULTICAST_LOOP 1 +#define IP_MAX_MEMBERSHIPS 20 + /* IPX options */ #define IPX_TYPE 1 diff --git a/include/linux/sockios.h b/include/linux/sockios.h index f4161494d..4259d9c94 100644 --- a/include/linux/sockios.h +++ b/include/linux/sockios.h @@ -59,6 +59,10 @@ #define SIOCGIFHWADDR 0x8927 /* Get hardware address */ #define SIOCGIFSLAVE 0x8929 /* Driver slaving support */ #define SIOCSIFSLAVE 0x8930 +/* begin multicast support change */ +#define SIOCADDMULTI 0x8931 +#define SIOCDELMULTI 0x8932 +/* end multicast support change */ /* Routing table calls (oldrtent - don't use) */ #define SIOCADDRTOLD 0x8940 /* add routing table entry */ @@ -90,5 +94,9 @@ #define SIOCDEVPRIVATE 0x89F0 /* to 89FF */ - +/* + * These 16 ioctl calls are protocol private + */ + +#define SIOCPROTOPRIVATE 0x89E0 /* to 89EF */ #endif /* _LINUX_SOCKIOS_H */ diff --git a/include/linux/sonycd535.h b/include/linux/sonycd535.h new file mode 100644 index 000000000..387e6f814 --- /dev/null +++ b/include/linux/sonycd535.h @@ -0,0 +1,183 @@ +#ifndef SONYCD535_H +#define SONYCD535_H + +/* + * define all the commands recognized by the CDU-531/5 + */ +#define SONY535_REQUEST_DRIVE_STATUS_1 (0x80) +#define SONY535_REQUEST_SENSE (0x82) +#define SONY535_REQUEST_DRIVE_STATUS_2 (0x84) +#define SONY535_REQUEST_ERROR_STATUS (0x86) +#define SONY535_REQUEST_AUDIO_STATUS (0x88) +#define SONY535_INQUIRY (0x8a) + +#define SONY535_SET_INACTIVITY_TIME (0x90) + +#define SONY535_SEEK_AND_READ_N_BLOCKS_1 (0xa0) +#define SONY535_SEEK_AND_READ_N_BLOCKS_2 (0xa4) +#define SONY535_PLAY_AUDIO (0xa6) + +#define SONY535_REQUEST_DISC_CAPACITY (0xb0) +#define SONY535_REQUEST_TOC_DATA (0xb2) +#define SONY535_REQUEST_SUB_Q_DATA (0xb4) +#define SONY535_REQUEST_ISRC (0xb6) +#define SONY535_REQUEST_UPC_EAN (0xb8) + +#define SONY535_SET_DRIVE_MODE (0xc0) +#define SONY535_REQUEST_DRIVE_MODE (0xc2) +#define SONY535_SET_RETRY_COUNT (0xc4) + +#define SONY535_DIAGNOSTIC_1 (0xc6) +#define SONY535_DIAGNOSTIC_4 (0xcc) +#define SONY535_DIAGNOSTIC_5 (0xce) + +#define SONY535_EJECT_CADDY (0xd0) +#define SONY535_DISABLE_EJECT_BUTTON (0xd2) +#define SONY535_ENABLE_EJECT_BUTTON (0xd4) + +#define SONY535_HOLD (0xe0) +#define SONY535_AUDIO_PAUSE_ON_OFF (0xe2) +#define SONY535_SET_VOLUME (0xe8) + +#define SONY535_STOP (0xf0) +#define SONY535_SPIN_UP (0xf2) +#define SONY535_SPIN_DOWN (0xf4) + +#define SONY535_CLEAR_PARAMETERS (0xf6) +#define SONY535_CLEAR_ENDING_ADDRESS (0xf8) + +/* + * define some masks + */ +#define SONY535_DATA_NOT_READY_BIT (0x1) +#define SONY535_RESULT_NOT_READY_BIT (0x2) + +/* + * drive status 1 + */ +#define SONY535_STATUS1_COMMAND_ERROR (0x1) +#define SONY535_STATUS1_DATA_ERROR (0x2) +#define SONY535_STATUS1_SEEK_ERROR (0x4) +#define SONY535_STATUS1_DISC_TYPE_ERROR (0x8) +#define SONY535_STATUS1_NOT_SPINNING (0x10) +#define SONY535_STATUS1_EJECT_BUTTON_PRESSED (0x20) +#define SONY535_STATUS1_CADDY_NOT_INSERTED (0x40) +#define SONY535_STATUS1_BYTE_TWO_FOLLOWS (0x80) + +/* + * drive status 2 + */ +#define SONY535_CDD_LOADING_ERROR (0x7) +#define SONY535_CDD_NO_DISC (0x8) +#define SONY535_CDD_UNLOADING_ERROR (0x9) +#define SONY535_CDD_CADDY_NOT_INSERTED (0xd) +#define SONY535_ATN_RESET_OCCURRED (0x2) +#define SONY535_ATN_DISC_CHANGED (0x4) +#define SONY535_ATN_RESET_AND_DISC_CHANGED (0x6) +#define SONY535_ATN_EJECT_IN_PROGRESS (0xe) +#define SONY535_ATN_BUSY (0xf) + +/* + * define some parameters + */ +#define SONY535_AUDIO_DRIVE_MODE (0) +#define SONY535_CDROM_DRIVE_MODE (0xe0) + +#define SONY535_PLAY_OP_PLAYBACK (0) +#define SONY535_PLAY_OP_ENTER_HOLD (1) +#define SONY535_PLAY_OP_SET_AUDIO_ENDING_ADDR (2) +#define SONY535_PLAY_OP_SCAN_FORWARD (3) +#define SONY535_PLAY_OP_SCAN_BACKWARD (4) + +/* + * convert from msf format to block number + */ +#define SONY_BLOCK_NUMBER(m,s,f) (((m)*60L+(s))*75L+(f)) +#define SONY_BLOCK_NUMBER_MSF(x) (((x)[0]*60L+(x)[1])*75L+(x)[2]) + +/* + * error return values from the doSonyCmd() routines + */ +#define TIME_OUT (-1) +#define NO_CDROM (-2) +#define BAD_STATUS (-3) +#define CD_BUSY (-4) +#define NOT_DATA_CD (-5) +#define NO_ROOM (-6) + +#define LOG_START_OFFSET 150 /* Offset of first logical sector */ + +#define SONY_JIFFIES_TIMEOUT 500 /* Maximum number of jiffies (10ms) + the drive will wait/try for an + operation */ +#define SONY_READY_RETRIES (50000) /* How many times to retry a + spin waiting for a register + to come ready */ +#define SONY535_FAST_POLLS (10000) /* how many times recheck + status waiting for a data + to become ready */ + +typedef unsigned char Byte; + +/* + * This is the complete status returned from the drive configuration request + * command. + */ +struct s535_sony_drive_config +{ + char vendor_id[8]; + char product_id[16]; + char product_rev_level[4]; +}; + +/* The following is returned from the request sub-q data command */ +struct s535_sony_subcode +{ + unsigned char address :4; + unsigned char control :4; + unsigned char track_num; + unsigned char index_num; + unsigned char rel_msf[3]; + unsigned char abs_msf[3]; +}; + +struct s535_sony_disc_capacity +{ + Byte mFirstTrack, sFirstTrack, fFirstTrack; + Byte mLeadOut, sLeadOut, fLeadOut; +}; + +/* + * 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 s535_sony_toc +{ + unsigned char reserved0 :4; + unsigned char control0 :4; + unsigned char point0; + unsigned char first_track_num; + unsigned char reserved0a; + unsigned char reserved0b; + unsigned char reserved1 :4; + unsigned char control1 :4; + unsigned char point1; + unsigned char last_track_num; + unsigned char dummy1; + unsigned char dummy2; + unsigned char reserved2 :4; + unsigned char control2 :4; + unsigned char point2; + unsigned char lead_out_start_msf[3]; + struct + { + unsigned char reserved :4; + unsigned char control :4; + unsigned char track; + unsigned char track_start_msf[3]; + } tracks[100]; + + unsigned int lead_out_start_lba; +}; + +#endif /* SONYCD535_H */ diff --git a/include/linux/soundcard.h b/include/linux/soundcard.h index 262e3f198..f839f1d89 100644 --- a/include/linux/soundcard.h +++ b/include/linux/soundcard.h @@ -348,7 +348,7 @@ struct patmgr_info { /* Note! size must be < 4k since kmalloc() is used */ * * 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). + * and its valid range is between 0 and 16383 (0x0000 to 0x3fff). * The driver sends the controller value using two messages when * necessary. */ diff --git a/include/linux/stat.h b/include/linux/stat.h index 86fbd821b..d86b1646f 100644 --- a/include/linux/stat.h +++ b/include/linux/stat.h @@ -3,42 +3,7 @@ #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; -}; +#include <asm/stat.h> #endif diff --git a/include/linux/string.h b/include/linux/string.h index 13e8da56e..3fddfdd65 100644 --- a/include/linux/string.h +++ b/include/linux/string.h @@ -11,19 +11,33 @@ extern "C" { #endif +extern char * ___strtok; +extern char * strcpy(char *,const char *); +extern char * strncpy(char *,const char *,size_t); +extern char * strcat(char *, const char *); +extern char * strncat(char *, const char *, size_t); +extern char * strchr(const char *,int); +extern char * strpbrk(const char *,const char *); +extern char * ___strtok; +extern char * strtok(char *,const char *); +extern char * strstr(const char *,const char *); +extern size_t strlen(const char *); +extern size_t strnlen(const char *,size_t); +extern size_t strspn(const char *,const char *); +extern int strcmp(const char *,const char *); +extern int strncmp(const char *,const char *,size_t); + +extern void * memset(void *,int,size_t); +extern void * memcpy(void *,const void *,size_t); +extern void * memmove(void *,const void *,size_t); +extern void * memscan(void *,int,size_t); +extern int memcmp(const void *,const void *,size_t); + /* * 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 diff --git a/include/linux/symtab_begin.h b/include/linux/symtab_begin.h new file mode 100644 index 000000000..c6f693687 --- /dev/null +++ b/include/linux/symtab_begin.h @@ -0,0 +1,16 @@ +#ifdef CONFIG_MODVERSIONS /* CONFIG_MODVERSIONS */ +#undef _set_ver +#undef X +#ifndef __GENKSYMS__ +#ifdef MODULE +#define _set_ver(sym,ver) { (void *) & sym ## _R ## ver, "_" #sym "_R" #ver } +#else /* MODULE */ +#define _set_ver(sym,ver) { (void *) & sym, "_" #sym "_R" #ver } +#endif /* MODULE */ +#define X(a) a +#endif /* __GENKSYMS__ */ +#else /* CONFIG_MODVERSIONS */ +#define X(sym) { (void *) & sym, "_" #sym } +#endif /* CONFIG_MODVERSIONS */ +#define EMPTY {0,0} + 0, 0, 0, { diff --git a/include/linux/symtab_end.h b/include/linux/symtab_end.h new file mode 100644 index 000000000..4fbd50f99 --- /dev/null +++ b/include/linux/symtab_end.h @@ -0,0 +1,15 @@ +#ifdef CONFIG_MODVERSIONS /* CONFIG_MODVERSIONS */ +#undef _set_ver +#if defined(MODULE) && !defined(__GENKSYMS__) +#define _set_ver(sym,vers) sym ## _R ## vers +#else +#define _set_ver(a,b) a +#endif +#endif /* CONFIG_MODVERSIONS */ +#undef X +#undef EMPTY + /* mark end of table, last entry above ended with a comma! */ + { (void *)0, (char *)0 } + }, + /* no module refs, insmod will take care of that instead! */ + { { (struct module *)0, (struct module_ref *)0 } } diff --git a/include/linux/sys.h b/include/linux/sys.h index 6ec269dde..40f9471d0 100644 --- a/include/linux/sys.h +++ b/include/linux/sys.h @@ -7,11 +7,6 @@ #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). @@ -32,6 +27,10 @@ * These are system calls that haven't been implemented yet * but have an entry in the table for future expansion.. */ +#ifdef __mips__ +#define sys_quotactl sys_ni_syscall +#else #define _sys_quotactl _sys_ni_syscall +#endif #endif diff --git a/include/linux/sysv_fs.h b/include/linux/sysv_fs.h index 1583e7389..984be6b1c 100644 --- a/include/linux/sysv_fs.h +++ b/include/linux/sysv_fs.h @@ -136,7 +136,7 @@ struct sysv4_super_block { 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_state; /* file system state: 0x7c269d38-s_time means clean */ long s_magic; /* version of file system */ long s_type; /* type of file system: 1 for 512 byte blocks 2 for 1024 byte blocks */ @@ -170,7 +170,7 @@ struct sysv2_super_block { 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_state; /* file system state: 0xcb096f43 means clean */ long s_magic; /* version of file system */ long s_type; /* type of file system: 1 for 512 byte blocks 2 for 1024 byte blocks */ @@ -395,7 +395,7 @@ 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 void sysv_statfs(struct super_block *, struct statfs *, int); 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 *); diff --git a/include/linux/sysv_fs_sb.h b/include/linux/sysv_fs_sb.h index c95e071b2..115b95bc6 100644 --- a/include/linux/sysv_fs_sb.h +++ b/include/linux/sysv_fs_sb.h @@ -57,6 +57,7 @@ struct sysv_sb_info { 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 */ + unsigned long *s_sb_state; /* pointer to s_sbd->s_state, only FSTYPE_SYSV */ /* 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 */ @@ -110,6 +111,7 @@ struct sysv_sb_info { #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_sb_state u.sysv_sb.s_sb_state #define sv_firstinodezone u.sysv_sb.s_firstinodezone #define sv_firstdatazone u.sysv_sb.s_firstdatazone #define sv_ninodes u.sysv_sb.s_ninodes diff --git a/include/linux/tasks.h b/include/linux/tasks.h index 12facf200..050bb3875 100644 --- a/include/linux/tasks.h +++ b/include/linux/tasks.h @@ -4,6 +4,9 @@ /* * This is the maximum nr of tasks - change it if you need to */ -#define NR_TASKS 128 +#define NR_TASKS 512 + +#define MAX_TASKS_PER_USER (NR_TASKS/2) +#define MIN_TASKS_LEFT_FOR_ROOT 4 #endif diff --git a/include/linux/tcp.h b/include/linux/tcp.h index 36fe49b53..7c95e5d02 100644 --- a/include/linux/tcp.h +++ b/include/linux/tcp.h @@ -18,16 +18,16 @@ #define _LINUX_TCP_H -#define HEADER_SIZE 64 /* maximum header size */ +#define HEADER_SIZE 128 /* maximum header size */ struct tcphdr { - u16 source; - u16 dest; - u32 seq; - u32 ack_seq; -#if defined(__i386__) || defined(__MIPSEL__) - u16 res1:4, + __u16 source; + __u16 dest; + __u32 seq; + __u32 ack_seq; +#if defined(LITTLE_ENDIAN_BITFIELD) + __u16 res1:4, doff:4, fin:1, syn:1, @@ -36,32 +36,22 @@ struct tcphdr { ack:1, urg:1, res2:2; -#elif defined(__mc68000__) || defined(__MIPSEB__) - u16 res2:2, +#elif defined(BIG_ENDIAN_BITFIELD) + __u16 doff:4, + res1:4, + 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; + fin:1; #else -#error "Adjust this structure for your cpu alignment rules" +#error "Adjust your <asm/byteorder.h> defines" #endif - u16 window; - u16 check; - u16 urg_ptr; + __u16 window; + __u16 check; + __u16 urg_ptr; }; diff --git a/include/linux/termios.h b/include/linux/termios.h index c06864acd..5a01ae381 100644 --- a/include/linux/termios.h +++ b/include/linux/termios.h @@ -43,6 +43,7 @@ #define TIOCSETD 0x5423 #define TIOCGETD 0x5424 #define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ +#define TIOCTTYGSTRUCT 0x5426 /* For debugging only */ #define FIONCLEX 0x5450 /* these numbers need to be adjusted. */ #define FIOCLEX 0x5451 #define FIOASYNC 0x5452 @@ -53,6 +54,8 @@ #define TIOCSLCKTRMIOS 0x5457 #define TIOCSERGSTRUCT 0x5458 /* For debugging only */ #define TIOCSERGETLSR 0x5459 /* Get line status register */ +#define TIOCSERGETMULTI 0x545A /* Get multiport config */ +#define TIOCSERSETMULTI 0x545B /* Set multiport config */ /* Used for packet mode */ #define TIOCPKT_DATA 0 @@ -192,6 +195,7 @@ struct termios { #define CBAUDEX 0010000 #define B57600 0010001 #define B115200 0010002 +#define B230400 0010003 #define CIBAUD 002003600000 /* input baud rate (not used) */ #define CRTSCTS 020000000000 /* flow control */ diff --git a/include/linux/time.h b/include/linux/time.h index 65891b748..a6ce36c8c 100644 --- a/include/linux/time.h +++ b/include/linux/time.h @@ -2,8 +2,8 @@ #define _LINUX_TIME_H struct timeval { - long tv_sec; /* seconds */ - long tv_usec; /* microseconds */ + int tv_sec; /* seconds */ + int tv_usec; /* microseconds */ }; struct timezone { @@ -13,11 +13,22 @@ struct timezone { #define NFDBITS __NFDBITS +#ifdef __KERNEL__ +void do_gettimeofday(struct timeval *tv); +#include <asm/bitops.h> +#include <linux/string.h> +#define FD_SETSIZE __FD_SETSIZE +#define FD_SET(fd,fdsetp) set_bit(fd,fdsetp) +#define FD_CLR(fd,fdsetp) clear_bit(fd,fdsetp) +#define FD_ISSET(fd,fdsetp) (0 != test_bit(fd,fdsetp)) +#define FD_ZERO(fdsetp) memset(fdsetp, 0, sizeof(struct fd_set)) +#else #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) +#endif /* * Names of the interval timers, and structure diff --git a/include/linux/timer.h b/include/linux/timer.h index a28616a2a..acb9ca26e 100644 --- a/include/linux/timer.h +++ b/include/linux/timer.h @@ -30,6 +30,7 @@ * QIC02_TAPE_TIMER timer for QIC-02 tape driver (it's not hardcoded) * * MCD_TIMER Mitsumi CD-ROM Timer + * */ #define BLANK_TIMER 0 diff --git a/include/linux/tpqic02.h b/include/linux/tpqic02.h index ff67a7ed6..8a824f7d0 100644 --- a/include/linux/tpqic02.h +++ b/include/linux/tpqic02.h @@ -2,7 +2,7 @@ * * Include file for QIC-02 driver for Linux. * - * Copyright (c) 1992, 1993, 1994 by H. H. Bergman. All rights reserved. + * Copyright (c) 1992--1995 by H. H. Bergman. All rights reserved. * * ******* USER CONFIG SECTION BELOW (Near line 70) ******* */ @@ -504,7 +504,8 @@ #define TPQD_ALWAYS 0x8000 -#define TPQD_DEFAULT_FLAGS 0x01fc +#define TPQD_DEFAULT_FLAGS 0x00fc + #define TPQDBG(f) ((QIC02_TAPE_DEBUG) & (TPQD_##f)) diff --git a/include/linux/tqueue.h b/include/linux/tqueue.h index 45b4403a0..a5a15173a 100644 --- a/include/linux/tqueue.h +++ b/include/linux/tqueue.h @@ -57,7 +57,7 @@ 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; +extern task_queue tq_timer, tq_immediate, tq_scheduler; #ifdef INCLUDE_INLINE_FUNCS struct tq_struct tq_last = { @@ -143,8 +143,7 @@ _INLINE_ void run_task_queue(task_queue *list) void (*f) (void *); while(1) { - p = &tq_last; - atomic_exchange(*list,p); + p = xchg_ptr(list,&tq_last); if(p == &tq_last) break; diff --git a/include/linux/trdevice.h b/include/linux/trdevice.h new file mode 100644 index 000000000..f2e09fa98 --- /dev/null +++ b/include/linux/trdevice.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_TRDEVICE_H +#define _LINUX_TRDEVICE_H + + +#include <linux/if_tr.h> + +#ifdef __KERNEL__ +extern int tr_header(unsigned char *buff, struct device *dev, + unsigned short type, void *daddr, + void *saddr, unsigned len, + struct sk_buff *skb); +extern int tr_rebuild_header(void *buff, struct device *dev, + unsigned long raddr, struct sk_buff *skb); +extern unsigned short tr_type_trans(struct sk_buff *skb, struct device *dev); + +#endif + +#endif /* _LINUX_TRDEVICE_H */ diff --git a/include/linux/tty.h b/include/linux/tty.h index c177902b5..d3761847c 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h @@ -62,6 +62,8 @@ extern struct screen_info screen_info; #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 */ +#define VIDEO_TYPE_PICA_S3 0x30 /* ACER PICA-61 local S3 video */ +#define VIDEO_TYPE_MIPS_G364 0x31 /* MIPS Magnum 4000 G364 video */ /* * This character is the same as _POSIX_VDISABLE: it cannot be used as @@ -199,7 +201,7 @@ struct tty_struct { int pgrp; int session; dev_t device; - int flags; + unsigned long flags; int count; struct winsize winsize; unsigned char stopped:1, hw_stopped:1, packet:1; @@ -222,15 +224,16 @@ struct tty_struct { */ unsigned int column; unsigned char lnext:1, erasing:1, raw:1, real_raw:1, icanon:1; + unsigned char closing:1; unsigned short minimum_to_wake; unsigned overrun_time; int num_overrun; - int process_char_map[256/32]; + unsigned long process_char_map[256/(8*sizeof(unsigned long))]; char *read_buf; int read_head; int read_tail; int read_cnt; - int read_flags[N_TTY_BUF_SIZE/32]; + unsigned long read_flags[N_TTY_BUF_SIZE/(8*sizeof(unsigned long))]; int canon_data; unsigned long canon_head; unsigned int canon_column; @@ -254,6 +257,7 @@ struct tty_struct { #define TTY_DEBUG 4 #define TTY_DO_WRITE_WAKEUP 5 #define TTY_PUSH 6 +#define TTY_CLOSING 7 #define TTY_WRITE_FLUSH(tty) tty_write_flush((tty)) @@ -278,12 +282,16 @@ extern long lp_init(long); extern long con_init(long); extern long pty_init(long); extern long tty_init(long); +extern long vcs_init(long); +#ifdef CONFIG_CYCLADES +extern long cy_init(long); +#endif 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 void tty_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); @@ -322,8 +330,6 @@ extern int pty_open(struct tty_struct * tty, struct file * filp); 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 */ diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h index 5244dc870..6008f6343 100644 --- a/include/linux/tty_driver.h +++ b/include/linux/tty_driver.h @@ -176,6 +176,7 @@ struct tty_driver { #define TTY_DRIVER_TYPE_CONSOLE 0x0002 #define TTY_DRIVER_TYPE_SERIAL 0x0003 #define TTY_DRIVER_TYPE_PTY 0x0004 +#define TTY_DRIVER_TYPE_SCC 0x0005 /* scc driver */ /* system subtypes (magic, used by tty_io.c) */ #define SYSTEM_TYPE_TTY 0x0001 diff --git a/include/linux/types.h b/include/linux/types.h index 8d04cf810..a06f4020d 100644 --- a/include/linux/types.h +++ b/include/linux/types.h @@ -3,47 +3,11 @@ #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__ +#if defined(__GNUC__) && !defined(__STRICT_ANSI__) #define _LOFF_T typedef long long loff_t; #endif @@ -64,7 +28,7 @@ typedef char *caddr_t; typedef unsigned char cc_t; typedef unsigned int speed_t; -typedef unsigned long tcflag_t; +typedef unsigned int tcflag_t; /* * This allows for 256 file descriptors: if NR_OPEN is ever grown beyond that diff --git a/include/linux/umsdos_fs.h b/include/linux/umsdos_fs.h index 9f943237e..170761a5e 100644 --- a/include/linux/umsdos_fs.h +++ b/include/linux/umsdos_fs.h @@ -2,11 +2,7 @@ #define LINUX_UMSDOS_FS_H #define UMSDOS_VERSION 0 -#define UMSDOS_RELEASE 3 - -#ifndef LINUX_FS_H -#include <linux/fs.h> -#endif +#define UMSDOS_RELEASE 4 /* This is the file acting as a directory extension */ #define UMSDOS_EMD_FILE "--linux-.---" @@ -14,6 +10,13 @@ #define UMSDOS_PSDROOT_NAME "linux" #define UMSDOS_PSDROOT_LEN 5 +#ifndef _LINUX_TYPES_H +#include <linux/types.h> +#endif +#ifndef _LINUX_DIRENT_H +#include <linux/dirent.h> +#endif + struct umsdos_fake_info { char fname[13]; int len; @@ -79,12 +82,40 @@ struct umsdos_info{ #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> - +#define UMSDOS_RENAME_DOS 1244 /* rename a file/directory in the DOS */ + /* directory only */ struct umsdos_ioctl{ struct dirent dos_dirent; struct umsdos_dirent umsdos_dirent; - struct new_stat stat; + /* The following structure is used to exchange some data */ + /* with utilities (umsdos_progs/util/umsdosio.c). The first */ + /* releases were using struct stat from "sys/stat.h". This was */ + /* causing some problem for cross compilation of the kernel */ + /* Since I am not really using the structure stat, but only some field */ + /* of it, I have decided to replicate the structure here */ + /* for compatibility with the binaries out there */ + struct { + dev_t st_dev; + unsigned short __pad1; + ino_t st_ino; + umode_t st_mode; + nlink_t st_nlink; + uid_t st_uid; + gid_t st_gid; + dev_t st_rdev; + unsigned short __pad2; + off_t st_size; + unsigned long st_blksize; + unsigned long st_blocks; + time_t st_atime; + unsigned long __unused1; + time_t st_mtime; + unsigned long __unused2; + time_t st_ctime; + unsigned long __unused3; + unsigned long __unused4; + unsigned long __unused5; + }stat; char version,release; }; @@ -93,6 +124,10 @@ struct umsdos_ioctl{ #ifdef __KERNEL__ +#ifndef LINUX_FS_H +#include <linux/fs.h> +#endif + extern struct inode_operations umsdos_dir_inode_operations; extern struct file_operations umsdos_file_operations; extern struct inode_operations umsdos_file_inode_operations; diff --git a/include/linux/umsdos_fs.p b/include/linux/umsdos_fs.p index ef91d03ed..a89ae6e22 100644 --- a/include/linux/umsdos_fs.p +++ b/include/linux/umsdos_fs.p @@ -1,6 +1,6 @@ -/* check.c 20/07/94 10.08.36 */ +/* check.c 30/01/95 22.05.32 */ void check_page_tables (void); -/* dir.c 22/07/94 01.06.58 */ +/* dir.c 18/03/95 00.30.50 */ int UMSDOS_dir_read (struct inode *inode, struct file *filp, char *buf, @@ -19,7 +19,7 @@ int UMSDOS_lookup (struct inode *dir, int len, struct inode **result); int umsdos_hlink2inode (struct inode *hlink, struct inode **result); -/* emd.c 22/07/94 01.06.38 */ +/* emd.c 30/01/95 22.05.32 */ int umsdos_readdir_kmem (struct inode *inode, struct file *filp, struct dirent *dirent, @@ -57,11 +57,11 @@ 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 */ +/* file.c 30/01/95 22.05.56 */ +/* inode.c 25/02/95 09.21.46 */ 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); +void UMSDOS_statfs (struct super_block *sb, struct statfs *buf, int); int umsdos_real_lookup (struct inode *dir, const char *name, int len, @@ -81,16 +81,16 @@ 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 */ +/* ioctl.c 21/02/95 20.58.22 */ int UMSDOS_ioctl_dir (struct inode *dir, struct file *filp, unsigned int cmd, unsigned long data); -/* mangle.c 20/07/94 10.08.36 */ +/* mangle.c 30/01/95 22.05.56 */ 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 */ +/* namei.c 30/01/95 22.05.56 */ void umsdos_lockcreate (struct inode *dir); void umsdos_startlookup (struct inode *dir); void umsdos_unlockcreate (struct inode *dir); @@ -125,9 +125,14 @@ int UMSDOS_rename (struct inode *old_dir, struct inode *new_dir, const char *new_name, int new_len); -/* rdir.c 20/07/94 10.08.38 */ +/* rdir.c 18/03/95 00.30.18 */ +int umsdos_rlookup_x (struct inode *dir, + const char *name, + int len, + struct inode **result, + int nopseudo); int UMSDOS_rlookup (struct inode *dir, const char *name, int len, struct inode **result); -/* symlink.c 22/07/94 00.59.10 */ +/* symlink.c 30/01/95 22.05.32 */ diff --git a/include/linux/umsdos_fs_i.h b/include/linux/umsdos_fs_i.h index 36a5f47f4..1020179eb 100644 --- a/include/linux/umsdos_fs_i.h +++ b/include/linux/umsdos_fs_i.h @@ -68,73 +68,3 @@ struct umsdos_inode_info { }; #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/unistd.h b/include/linux/unistd.h index 8ac5e0474..0ec2184f6 100644 --- a/include/linux/unistd.h +++ b/include/linux/unistd.h @@ -146,6 +146,12 @@ #define __NR_setfsuid 138 #define __NR_setfsgid 139 #define __NR__llseek 140 +#define __NR_getdents 141 +#define __NR__newselect 142 +#define __NR_flock 143 +/* This one hasn't been assigned officially! Code that relies + on it deserves to die ... */ +#define __NR__cacheflush 144 extern int errno; diff --git a/include/linux/vfs.h b/include/linux/vfs.h index 463df2fd7..b3a58657d 100644 --- a/include/linux/vfs.h +++ b/include/linux/vfs.h @@ -1,21 +1,6 @@ #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]; -}; +#include <asm/statfs.h> #endif diff --git a/include/linux/xd.h b/include/linux/xd.h index 64ae79953..6daf3e951 100644 --- a/include/linux/xd.h +++ b/include/linux/xd.h @@ -118,7 +118,7 @@ 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 void xd_interrupt_handler (int irq, struct pt_regs * regs); 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); diff --git a/include/linux/xia_fs.h b/include/linux/xia_fs.h index 47f3e3f16..908360976 100644 --- a/include/linux/xia_fs.h +++ b/include/linux/xia_fs.h @@ -62,6 +62,8 @@ struct xiafs_direct { char d_name[_XIAFS_NAME_LEN+1]; }; +#ifdef __KERNEL__ + 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, @@ -96,7 +98,7 @@ 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 void xiafs_statfs(struct super_block *, struct statfs *, int); extern int xiafs_sync_inode(struct inode *); extern int xiafs_sync_file(struct inode *, struct file *); @@ -104,6 +106,8 @@ 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 /* __KERNEL__ */ + #endif /* _XIA_FS_H */ diff --git a/include/net/arp.h b/include/net/arp.h new file mode 100644 index 000000000..e8fa572ea --- /dev/null +++ b/include/net/arp.h @@ -0,0 +1,20 @@ +/* linux/net/inet/arp.h */ +#ifndef _ARP_H +#define _ARP_H + +extern void arp_init(void); +extern void arp_destroy(unsigned long paddr, int force); +extern void arp_device_down(struct device *dev); +extern int arp_rcv(struct sk_buff *skb, struct device *dev, + struct packet_type *pt); +extern int arp_find(unsigned char *haddr, unsigned long paddr, + struct device *dev, unsigned long saddr, struct sk_buff *skb); +extern int arp_get_info(char *buffer, char **start, off_t origin, int length); +extern int arp_ioctl(unsigned int cmd, void *arg); +extern void arp_send(int type, int ptype, unsigned long dest_ip, + struct device *dev, unsigned long src_ip, + unsigned char *dest_hw, unsigned char *src_hw); +extern int arp_find_cache(unsigned char *dp, unsigned long daddr, struct device *dev); + +extern unsigned long arp_cache_stamp; +#endif /* _ARP_H */ diff --git a/include/net/atalk.h b/include/net/atalk.h new file mode 100644 index 000000000..08760cdac --- /dev/null +++ b/include/net/atalk.h @@ -0,0 +1,144 @@ +/* + * Appletalk networking structures + * + * The following are directly referenced from the University Of Michigan + * netatalk for compatibility reasons. + */ + +#ifndef __LINUX_ATALK_H__ +#define __LINUX_ATALK_H__ + +#define ATPORT_FIRST 1 +#define ATPORT_RESERVED 128 +#define ATPORT_LAST 255 +#define ATADDR_ANYNET (__u16)0 +#define ATADDR_ANYNODE (__u8)0 +#define ATADDR_ANYPORT (__u8)0 +#define ATADDR_BCAST (__u8)255 +#define DDP_MAXSZ 587 + +struct at_addr +{ + __u16 s_net; + __u8 s_node; +}; + +struct sockaddr_at +{ + short sat_family; + __u8 sat_port; + struct at_addr sat_addr; + char sat_zero[ 8 ]; +}; + +struct netrange +{ + __u8 nr_phase; + __u16 nr_firstnet; + __u16 nr_lastnet; +}; + +struct atalk_route +{ + struct device *dev; + struct at_addr target; + struct at_addr gateway; + int flags; + struct atalk_route *next; +}; + +struct atalk_iface +{ + struct device *dev; + struct at_addr address; /* Our address */ + int status; /* What are we doing ?? */ +#define ATIF_PROBE 1 /* Probing for an address */ +#define ATIF_PROBE_FAIL 2 /* Probe collided */ + struct netrange nets; /* Associated direct netrange */ + struct atalk_iface *next; +}; + +struct atalk_sock +{ + unsigned short dest_net; + unsigned short src_net; + unsigned char dest_node; + unsigned char src_node; + unsigned char dest_port; + unsigned char src_port; +}; + +#define DDP_MAXHOPS 15 /* 4 bits of hop counter */ + +#ifdef __KERNEL__ + +struct ddpehdr +{ + /* FIXME for bigendians */ + /*__u16 deh_pad:2,deh_hops:4,deh_len:10;*/ + __u16 deh_len:10,deh_hops:4,deh_pad:2; + __u16 deh_sum; + __u16 deh_dnet; + __u16 deh_snet; + __u8 deh_dnode; + __u8 deh_snode; + __u8 deh_dport; + __u8 deh_sport; + /* And netatalk apps expect to stick the type in themselves */ +}; + +/* + * Unused (and currently unsupported) + */ + +struct ddpshdr +{ + /* FIXME for bigendians */ + __u8 dsh_sport; + __u8 dsh_dport; + __u16 dsh_len:10, dsh_pad:6; + /* And netatalk apps expect to stick the type in themselves */ +}; + +/* Appletalk AARP headers */ + +struct elapaarp +{ + __u16 hw_type; +#define AARP_HW_TYPE_ETHERNET 1 +#define AARP_HW_TYPE_TOKENRING 2 + __u16 pa_type; + __u8 hw_len; + __u8 pa_len; +#define AARP_PA_ALEN 4 + __u16 function; +#define AARP_REQUEST 1 +#define AARP_REPLY 2 +#define AARP_PROBE 3 + __u8 hw_src[ETH_ALEN] __attribute__ ((packed)); + __u8 pa_src_zero __attribute__ ((packed)); + __u16 pa_src_net __attribute__ ((packed)); + __u8 pa_src_node __attribute__ ((packed)); + __u8 hw_dst[ETH_ALEN] __attribute__ ((packed)); + __u8 pa_dst_zero __attribute__ ((packed)); + __u16 pa_dst_net __attribute__ ((packed)); + __u8 pa_dst_node __attribute__ ((packed)); +}; + +typedef struct sock atalk_socket; + +#define AARP_EXPIRY_TIME (5*60*HZ) /* Not specified - how long till we drop a resolved entry */ +#define AARP_HASH_SIZE 16 /* Size of hash table */ +#define AARP_TICK_TIME (HZ/5) /* Fast retransmission timer when resolving */ +#define AARP_RETRANSMIT_LIMIT 10 /* Send 10 requests then give up (2 seconds) */ +#define AARP_RESOLVE_TIME (10*HZ) /* Some value bigger than total retransmit time + a bit for last reply to appear and to stop continual requests */ + +extern struct datalink_proto *ddp_dl, *aarp_dl; +extern void aarp_proto_init(void); +/* Inter module exports */ +extern struct atalk_iface *atalk_find_dev(struct device *dev); +extern struct at_addr *atalk_find_dev_addr(struct device *dev); +extern int aarp_send_ddp(struct device *dev,struct sk_buff *skb, struct at_addr *sa, void *hwaddr); +extern void aarp_send_probe(struct device *dev, struct at_addr *addr); +#endif +#endif diff --git a/include/net/atalkcall.h b/include/net/atalkcall.h new file mode 100644 index 000000000..726e33cd9 --- /dev/null +++ b/include/net/atalkcall.h @@ -0,0 +1,2 @@ +/* Separate to keep compilation of protocols.c simpler */ +extern void atalk_proto_init(struct net_proto *pro); diff --git a/include/net/ax25.h b/include/net/ax25.h new file mode 100644 index 000000000..4195c1246 --- /dev/null +++ b/include/net/ax25.h @@ -0,0 +1,188 @@ +/* + * Declarations of AX.25 type objects. + * + * Alan Cox (GW4PTS) 10/11/93 + */ + +#ifndef _AX25_H +#define _AX25_H +#include <linux/ax25.h> + +#define AX25_P_IP 0xCC +#define AX25_P_ARP 0xCD +#define AX25_P_TEXT 0xF0 +#define AX25_P_NETROM 0xCF + +#define LAPB_UI 0x03 +#define LAPB_C 0x80 +#define LAPB_E 0x01 + +#define SSID_SPARE 0x60 /* Unused bits (DAMA bit and spare must be 1) */ + +#define AX25_REPEATED 0x80 + +#define ACK_PENDING_CONDITION 0x01 +#define REJECT_CONDITION 0x02 +#define PEER_RX_BUSY_CONDITION 0x04 +#define OWN_RX_BUSY_CONDITION 0x08 + +#ifndef _LINUX_NETDEVICE_H +#include <linux/netdevice.h> +#endif + +/* + * These headers are taken from the KA9Q package by Phil Karn. These specific + * files have been placed under the GPL (not the whole package) by Phil. + * + * + * Copyright 1991 Phil Karn, KA9Q + * + * 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; version 2 dated June, 1991. + * + * 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. + */ + +/* Upper sub-layer (LAPB) definitions */ + +/* Control field templates */ +#define I 0x00 /* Information frames */ +#define S 0x01 /* Supervisory frames */ +#define RR 0x01 /* Receiver ready */ +#define RNR 0x05 /* Receiver not ready */ +#define REJ 0x09 /* Reject */ +#define U 0x03 /* Unnumbered frames */ +#define SABM 0x2f /* Set Asynchronous Balanced Mode */ +#define SABME 0x6f /* Set Asynchronous Balanced Mode Extended */ +#define DISC 0x43 /* Disconnect */ +#define DM 0x0f /* Disconnected mode */ +#define UA 0x63 /* Unnumbered acknowledge */ +#define FRMR 0x87 /* Frame reject */ +#define UI 0x03 /* Unnumbered information */ +#define PF 0x10 /* Poll/final bit */ + +#define ILLEGAL 0x100 /* Impossible to be a real frame type */ + +#define MMASK 7 /* Mask for modulo-8 sequence numbers */ + +/* AX25 L2 C-bit */ + +#define C_COMMAND 1 /* C_ otherwise it clashes with the de600 defines (sigh)) */ +#define C_RESPONSE 2 + +/* Define Link State constants. */ + +#define AX25_STATE_0 0 +#define AX25_STATE_1 1 +#define AX25_STATE_2 2 +#define AX25_STATE_3 3 +#define AX25_STATE_4 4 + +#define PR_SLOWHZ 10 /* Run timing at 1/10 second - gives us better resolution for 56kbit links */ +#define DEFAULT_T1 (10 * PR_SLOWHZ) /* Outstanding frames - 10 seconds */ +#define DEFAULT_T2 (3 * PR_SLOWHZ) /* Response delay - 3 seconds */ +#define DEFAULT_T3 (300 * PR_SLOWHZ) /* Idle supervision - 300 seconds */ +#define DEFAULT_N2 10 /* Number of retries */ +#define DEFAULT_WINDOW 2 /* Default window size */ +#define MODULUS 8 +#define MAX_WINDOW_SIZE 7 /* Maximum window allowable */ + +typedef struct ax25_uid_assoc { + struct ax25_uid_assoc *next; + uid_t uid; + ax25_address call; +} ax25_uid_assoc; + +typedef struct { + ax25_address calls[6]; + unsigned char repeated[6]; + unsigned char ndigi; + char lastrepeat; +} ax25_digi; + +typedef struct ax25_cb { + struct ax25_cb *next; + ax25_address source_addr, dest_addr; + struct device *device; + unsigned char state; + unsigned short vs, vr, va; + unsigned char condition; + unsigned char n2, n2count; + unsigned short t1, t2, t3, rtt; + unsigned short t1timer, t2timer, t3timer; + ax25_digi *digipeat; + struct sk_buff_head write_queue; + struct sk_buff_head ack_queue; + unsigned char window; + struct timer_list timer; + struct sock *sk; /* Backlink to socket */ +} ax25_cb; + +/* ax25.c */ +extern char *ax2asc(ax25_address *); +extern int ax25cmp(ax25_address *, ax25_address *); +extern int ax25_send_frame(struct sk_buff *, ax25_address *, ax25_address *, struct device *); +extern int ax25_rcv(struct sk_buff *,struct device *,struct packet_type *); +extern void ax25_destroy_socket(ax25_cb *); +extern struct device *ax25rtr_get_dev(ax25_address *); +extern int ax25_encapsulate(unsigned char *, struct device *, unsigned short, + void *, void *, unsigned int, struct sk_buff *); +extern int ax25_rebuild_header(unsigned char *, struct device *, unsigned long, struct sk_buff *); +extern int ax25_get_info(char *, char **, off_t, int); +extern ax25_uid_assoc *ax25_uid_list; +extern int ax25_uid_policy; +extern ax25_address *ax25_findbyuid(uid_t); + +#include "ax25call.h" + +/* ax25_in.c */ +extern int ax25_process_rx_frame(ax25_cb *, struct sk_buff *, int); + +/* ax25_out.c */ +extern int ax25_output(ax25_cb *, struct sk_buff *); +extern void ax25_kick(ax25_cb *); +extern void ax25_transmit_buffer(ax25_cb *, struct sk_buff *, int); +extern void ax25_nr_error_recovery(ax25_cb *); +extern void ax25_establish_data_link(ax25_cb *); +extern void ax25_transmit_enquiry(ax25_cb *); +extern void ax25_enquiry_response(ax25_cb *); +extern void ax25_check_iframes_acked(ax25_cb *, unsigned short); +extern void ax25_check_need_response(ax25_cb *, int, int); + +/* ax25_route.c */ +extern void ax25_rt_rx_frame(ax25_address *, struct device *); +extern int ax25_rt_get_info(char *, char **, off_t, int); +extern int ax25_cs_get_info(char *, char **, off_t, int); +extern int ax25_rt_autobind(ax25_cb *, ax25_address *); +extern void ax25_rt_device_down(struct device *); +extern void ax25_ip_mode_set(ax25_address *, struct device *, char); +extern char ax25_ip_mode_get(ax25_address *, struct device *); + +/* ax25_subr.c */ +extern void ax25_clear_tx_queue(ax25_cb *); +extern void ax25_frames_acked(ax25_cb *, unsigned short); +extern int ax25_validate_nr(ax25_cb *, unsigned short); +extern int ax25_decode(unsigned char *); +extern void ax25_send_control(ax25_cb *, int, int); +extern unsigned short ax25_calculate_t1(ax25_cb *); +extern void ax25_calculate_rtt(ax25_cb *); +extern unsigned char *ax25_parse_addr(unsigned char *, int, ax25_address *, + ax25_address *, ax25_digi *, int *); +extern int build_ax25_addr(unsigned char *, ax25_address *, ax25_address *, + ax25_digi *, int); +extern int size_ax25_addr(ax25_digi *); +extern void ax25_digi_invert(ax25_digi *, ax25_digi *); +extern void ax25_return_dm(struct device *, ax25_address *, ax25_address *, ax25_digi *); + +/* ax25_timer */ +extern void ax25_set_timer(ax25_cb *); + +#endif diff --git a/include/net/ax25call.h b/include/net/ax25call.h new file mode 100644 index 000000000..89569656b --- /dev/null +++ b/include/net/ax25call.h @@ -0,0 +1,2 @@ +/* Seperate to keep compilation of protocols.c simpler */ +extern void ax25_proto_init(struct net_proto *pro); diff --git a/include/net/checksum.h b/include/net/checksum.h new file mode 100644 index 000000000..7f9492328 --- /dev/null +++ b/include/net/checksum.h @@ -0,0 +1,237 @@ +/* + * 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. + * + * Checksumming functions for IP, TCP, UDP and so on + * + * Authors: Jorge Cwik, <jorge@laser.satlink.net> + * Arnt Gulbrandsen, <agulbra@nvg.unit.no> + * Borrows very liberally from tcp.c and ip.c, see those + * files for more names. + * + * 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 _CHECKSUM_H +#define _CHECKSUM_H + +#include <asm/byteorder.h> +#include "ip.h" + +/* + * This is a version of ip_compute_csum() optimized for IP headers, + * which always checksum on 4 octet boundaries. + * + * By Jorge Cwik <jorge@laser.satlink.net>, adapted for linux by + * Arnt Gulbrandsen. + */ +static inline unsigned short ip_fast_csum(unsigned char * iph, + unsigned int ihl) { + unsigned short int sum; + +#ifdef __i386__ + __asm__(" + movl (%%esi), %%eax + andl $15, %%ecx + subl $4, %%ecx + jbe 2f + addl 4(%%esi), %%eax + adcl 8(%%esi), %%eax + adcl 12(%%esi), %%eax +1: adcl 16(%%esi), %%eax + lea 4(%%esi), %%esi + decl %%ecx + jne 1b + adcl $0, %%eax + movl %%eax, %%ecx + shrl $16, %%eax + addw %%ecx, %%eax + adcl $0, %%eax + notl %%eax + andl $65535, %%eax +2: + " + : "=a" (sum) + : "S" (iph), "c"(ihl) + : "ax", "cx", "si"); +#elif defined (__mips__) + unsigned long dummy1, dummy2; + /* + * This is optimized for 32-bit MIPS processors. + * I tried it in plain C but the generated code looks to bad to + * use with old first generation MIPS CPUs. + * Using 64-bit code could even further improve these routines. + */ + __asm__(" + .set noreorder + .set noat + lw %0,(%3) + subu %1,4 + blez %1,2f + sll %1,%4,2 # delay slot + lw %2,4(%3) + addu %1,%3 # delay slot + addu %0,%2 + sltu $1,%0,%2 + lw %2,8(%3) + addu %0,$1 + addu %0,%2 + sltu $1,%0,%2 + lw %2,12(%3) + addu %0,$1 + addu %0,%2 + sltu $1,%0,%2 + addu %0,$1 +1: lw %2,16(%3) + addu %1,4 + addu %0,%2 + sltu $1,%0,%2 + bne %1,%3,1b + addu %0,$1 # delay slot + srl $1,%0,16 + addu %0,$1 + sltu $1,%0,$1 + addu %0,$1 + nor %0,$0,%0 + andi %0,0xffff +2: .set at + .set reorder" + : "=r" (sum), "=r" (dummy1), "=r" (dummy2) + : "r" (iph), "r"(ihl) + : "$1"); +#else +#error Not implemented for this CPU +#endif + return(sum); +} + + + + +/* + * computes the checksum of the TCP/UDP pseudo-header + * returns a 16-bit checksum, already complemented + */ + +static inline unsigned short int csum_tcpudp_magic(unsigned long saddr, + unsigned long daddr, + unsigned short len, + unsigned short proto, + unsigned int sum) { +#ifdef __i386__ + __asm__(" + addl %2, %0 + adcl %3, %0 + adcl %4, %0 + adcl $0, %0 + movl %0, %2 + shrl $16, %2 + addw %2, %0 + adcl $0, %0 + notl %0 + andl $65535, %0 + " + : "=r" (sum) + : "0" (daddr), "S"(saddr), "r"((ntohs(len)<<16)+proto*256), "r"(sum) + : "si" ); +#elif defined (__mips__) + __asm__(" + .set noat + addu %0,%2 + sltu $1,%0,%2 + addu %0,$1 + addu %0,%3 + sltu $1,%0,%3 + addu %0,$1 + addu %0,%4 + sltu $1,%0,%4 + addu %0,$1 + srl $1,%0,16 + addu %0,$1 + sltu $1,%0,$1 + addu %0,$1 + nor %0,$0,%0 + andi %0,0xffff + .set at" + : "=r" (sum) + : "0" (daddr), "r"(saddr), "r"((ntohs(len)<<16)+proto*256), "r"(sum) + : "$1"); +#else +#error Not implemented for this CPU +#endif + return((unsigned short)sum); +} + + + +/* + * computes the checksum of a memory block at buff, length len, + * and adds in "sum" (32-bit) + * + * returns a 32-bit number suitable for feeding into itself + * or csum_tcpudp_magic + * + * this function must be called with even lengths, except + * for the last fragment, which may be odd + * + * it's best to have buff aligned on a 32-bit boundary + */ +unsigned int csum_partial(unsigned char * buff, int len, unsigned int sum); + + + +/* + * the same as csum_partial, but copies from fs:src while it + * checksums + * + * here even more important to align src and dst on a 32-bit (or even + * better 64-bit) boundary + */ + +unsigned int csum_partial_copyffs( char *src, char *dst, int len, int sum); + + + + +/* + * this routine is used for miscellaneous IP-like checksums, mainly + * in icmp.c + */ + +static inline unsigned short ip_compute_csum(unsigned char * buff, int len) { + unsigned short int sum; + +#ifdef __i386__ + __asm__(" + movl %%eax, %%ecx + shrl $16, %%ecx + addw %%cx, %%ax + adcl $0, %%eax + notl %%eax + andl $65535, %%eax + " + : "=a"(sum) + : "a" (csum_partial(buff, len, 0)) + : "cx"); +#elif defined (__mips__) + __asm__(" + .set noat + srl $1,%0,16 + addu %0,$1 + sltu $1,%0,$1 + nor %0,$0,%0 + andi %0,0xffff + .set at" + : "=r"(sum) + : "r" (csum_partial(buff, len, 0)) + : "$1"); +#else +#error Not implemented for this CPU +#endif + return(sum); +} + +#endif diff --git a/include/net/datalink.h b/include/net/datalink.h new file mode 100644 index 000000000..34ae08daa --- /dev/null +++ b/include/net/datalink.h @@ -0,0 +1,17 @@ +#ifndef _NET_INET_DATALINK_H_ +#define _NET_INET_DATALINK_H_ + +struct datalink_proto { + unsigned short type_len; + unsigned char type[8]; + char *string_name; + unsigned short header_length; + int (*rcvfunc)(struct sk_buff *, struct device *, + struct packet_type *); + void (*datalink_header)(struct datalink_proto *, struct sk_buff *, + unsigned char *); + struct datalink_proto *next; +}; + +#endif + diff --git a/include/net/eth.h b/include/net/eth.h new file mode 100644 index 000000000..3c11603e0 --- /dev/null +++ b/include/net/eth.h @@ -0,0 +1,36 @@ +/* + * 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> + * + * 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 _ETH_H +#define _ETH_H + + +#include <linux/if_ether.h> + + +extern char *eth_print(unsigned char *ptr); +extern void eth_dump(struct ethhdr *eth); +extern int eth_header(unsigned char *buff, struct device *dev, + unsigned short type, unsigned long daddr, + unsigned long saddr, unsigned len); +extern int eth_rebuild_header(void *buff, struct device *dev); +extern void eth_add_arp(unsigned long addr, struct sk_buff *skb, + struct device *dev); +extern unsigned short eth_type_trans(struct sk_buff *skb, struct device *dev); +extern int eth_header_cache(struct device *dev, struct sock *sk, unsigned long saddr, unsigned long daddr); + +#endif /* _ETH_H */ diff --git a/include/net/head_explode.h b/include/net/head_explode.h new file mode 100644 index 000000000..90276fafe --- /dev/null +++ b/include/net/head_explode.h @@ -0,0 +1,140 @@ +/* + * Header exploders. We inline those only appearing once. + * + * We assume 8 bit bytes. + * + * This is oriented to getting good code out of GCC. It may need + * tuning for other processors. + * + * Note only IGMP uses this so far. Just as an experiment. + */ + + +extern __inline__ unsigned char *exp_getu16(unsigned char *bp, unsigned short *u) +{ + *u=(*bp<<8)|bp[1]; + return bp+2; +} + +extern __inline__ unsigned char *exp_getn16(unsigned char *bp, unsigned short *u) +{ + unsigned char *tp=(unsigned char *)u; + *tp++=*bp++; + *tp++=*bp++; + return bp; +} + +extern __inline__ unsigned char *imp_putu16(unsigned char *bp, unsigned short n) +{ + *bp=(n>>8); + bp[1]=n&0xFF; + return bp+2; +} + +extern __inline__ unsigned char *imp_putn16(unsigned char *bp, unsigned short n) +{ + unsigned char *sp=(unsigned char *)&n; + *bp++=*sp++; + *bp++=*sp++; + return bp; +} + +extern __inline__ unsigned char *exp_getu32(unsigned char *bp, unsigned long *u) +{ + *u=(bp[0]<<24)|(bp[1]<<16)|(bp[2]<<8)|bp[3]; + return bp+4; +} + +extern __inline__ unsigned char *exp_getn32(unsigned char *bp, unsigned long *u) +{ + unsigned char *tp=(unsigned char *)u; + *tp++=*bp++; + *tp++=*bp++; + *tp++=*bp++; + *tp++=*bp++; + return bp; +} + +extern __inline__ unsigned char *imp_putu32(unsigned char *bp, unsigned long n) +{ + bp[0]=n>>24; + bp[1]=(n>>16)&0xFF; + bp[2]=(n>>8)&0xFF; + bp[3]=n&0xFF; + return bp+4; +} + +extern __inline__ unsigned char *imp_putn32(unsigned char *bp, unsigned long n) +{ + unsigned char *sp=(unsigned char *)&n; + *bp++=*sp++; + *bp++=*sp++; + *bp++=*sp++; + *bp++=*sp++; + return bp; +} + +#if 0 + +extern __inline__ unsigned char *ip_explode(unsigned char *iph, struct ip_header *ip) +{ + ip->version=*iph>>4; /* Avoid the shift. We do our equality checks shifted too */ + ip->ihl=(*iph++)&0xF; /* Length in long words */ + ip->tos=*iph++; /* Service type */ + iph=exp_getu16(iph,&ip->tot_len); /* Length of packet */ + iph=exp_getu16(iph,&ip->id); /* Packet identity */ + iph=exp_getu16(iph,&ip->frag_off); /* Fragment offset */ + ip->ttl=*iph++; + ip->protocol=*iph++; + iph=exp_getn16(iph,&ip->check); + iph=exp_getn32(iph,&ip->saddr); + iph=exp_getn32(iph,&ip->daddr); + return iph; +} + +extern __inline__ unsigned char *icmp_explode(unsigned char *icmph, struct icmp_header *icmp) +{ + icmp->type=*icmp++; + icmp->code=*icmp++; + icmph=exp_getn16(icmph,&icmp->checksum); + /* These two pairs are a union... expand both */ + exp_getu32(icmph,&icmp->gateway); + icmph=exp_getu16(icmph,&icmp->id); + icmph=exp_getu16(icmph,&icmp->sequence); + return icmph; +} + +#endif + +extern __inline__ unsigned char *igmp_explode(unsigned char *igmph, struct igmp_header *igmp) +{ + igmp->type=*igmph++; + igmph++; /* unused */ + igmph=exp_getn16(igmph,&igmp->csum); + igmph=exp_getn32(igmph,&igmp->group); + return igmph; +} + +#if 0 +extern __inline__ unsigned char *tcp_explode(unsigned char *tcph, struct tcp_header *tcp) +{ + tcph=exp_getu16(tcph,&tcp->source); + tcph=exp_getu16(tcph,&tcp->dest); + tcph=exp_getu32(tcph,&tcp->seq); + tcph=exp_getu32(tcph,&tcp->ack_seq); + tcph=exp_getu16(tcph,&tcp->u.bitmask); + tcph=exp_getu16(tcph,&tcp->window); + tcph=exp_getn16(tcph,&tcp->check); + tcph=exp_getu16(tcph,&tcp->urg_ptr); + return tcph; +} + +extern __inline__ unsigned char *udp_explode(unsigned char *udph, struct udp_header *udp) +{ + udph=exp_getu16(tcph,&udp->source); + udph=exp_getu16(udph,&udp->dest); + udph=exp_getu16(udph,&udp->len); + udph=exp_getn16(udph,&udp->check); + return udph; +} +#endif diff --git a/include/net/icmp.h b/include/net/icmp.h new file mode 100644 index 000000000..8f1c34983 --- /dev/null +++ b/include/net/icmp.h @@ -0,0 +1,38 @@ +/* + * 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 module. + * + * Version: @(#)icmp.h 1.0.4 05/13/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 _ICMP_H +#define _ICMP_H + +#include <linux/icmp.h> + + +extern struct icmp_err icmp_err_convert[]; +extern struct icmp_mib icmp_statistics; + + +extern void icmp_send(struct sk_buff *skb_in, int type, int code, + unsigned long info, struct device *dev); +extern int icmp_rcv(struct sk_buff *skb1, struct device *dev, + struct options *opt, unsigned long daddr, + unsigned short len, unsigned long saddr, + int redo, struct inet_protocol *protocol); + +extern int icmp_ioctl(struct sock *sk, int cmd, + unsigned long arg); + +#endif /* _ICMP_H */ diff --git a/include/net/ip.h b/include/net/ip.h new file mode 100644 index 000000000..6726e8a48 --- /dev/null +++ b/include/net/ip.h @@ -0,0 +1,115 @@ +/* + * 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 module. + * + * Version: @(#)ip.h 1.0.2 05/07/93 + * + * Authors: Ross Biro, <bir7@leland.Stanford.Edu> + * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> + * 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. + */ +#ifndef _IP_H +#define _IP_H + + +#include <linux/config.h> +#include <linux/types.h> +#include <linux/socket.h> +#include <linux/ip.h> +#include <linux/netdevice.h> + +#ifndef _SNMP_H +#include "snmp.h" +#endif + +#include "sock.h" /* struct sock */ + +/* IP flags. */ +#define IP_CE 0x8000 /* Flag: "Congestion" */ +#define IP_DF 0x4000 /* Flag: "Don't Fragment" */ +#define IP_MF 0x2000 /* Flag: "More Fragments" */ +#define IP_OFFSET 0x1FFF /* "Fragment Offset" part */ + +#define IP_FRAG_TIME (30 * HZ) /* fragment lifetime */ + +#ifdef CONFIG_IP_MULTICAST +extern void ip_mc_dropsocket(struct sock *); +extern void ip_mc_dropdevice(struct device *dev); +extern int ip_mc_procinfo(char *, char **, off_t, int); +#define MULTICAST(x) (IN_MULTICAST(htonl(x))) +#endif + + +/* Describe an IP fragment. */ +struct ipfrag { + int offset; /* offset of fragment in IP datagram */ + int end; /* last byte of data in datagram */ + int len; /* length of this fragment */ + struct sk_buff *skb; /* complete received fragment */ + unsigned char *ptr; /* pointer into real fragment data */ + struct ipfrag *next; /* linked list pointers */ + struct ipfrag *prev; +}; + +/* Describe an entry in the "incomplete datagrams" queue. */ +struct ipq { + unsigned char *mac; /* pointer to MAC header */ + struct iphdr *iph; /* pointer to IP header */ + int len; /* total length of original datagram */ + short ihlen; /* length of the IP header */ + short maclen; /* length of the MAC header */ + struct timer_list timer; /* when will this queue expire? */ + struct ipfrag *fragments; /* linked list of received fragments */ + struct ipq *next; /* linked list pointers */ + struct ipq *prev; + struct device *dev; /* Device - for icmp replies */ +}; + + +extern int backoff(int n); + +extern void ip_print(const struct iphdr *ip); +extern int ip_ioctl(struct sock *sk, int cmd, + unsigned long arg); +extern void ip_route_check(unsigned long daddr); +extern int ip_build_header(struct sk_buff *skb, + unsigned long saddr, + unsigned long daddr, + struct device **dev, int type, + struct options *opt, int len, + int tos,int ttl); +/*extern unsigned short ip_compute_csum(unsigned char * buff, int len);*/ +extern int ip_rcv(struct sk_buff *skb, struct device *dev, + struct packet_type *pt); +extern void ip_forward(struct sk_buff *skb, struct device *dev, int is_frag, unsigned long target_addr, int target_strict); +extern void ip_send_check(struct iphdr *ip); +extern int ip_id_count; +extern void ip_queue_xmit(struct sock *sk, + struct device *dev, struct sk_buff *skb, + int free); +extern int ip_setsockopt(struct sock *sk, int level, int optname, char *optval, int optlen); +extern int ip_getsockopt(struct sock *sk, int level, int optname, char *optval, int *optlen); +extern void ip_init(void); +extern int ip_build_xmit(struct sock *sk, + void getfrag (void *, + int, + char *, + unsigned int, + unsigned int), + void *frag, + unsigned short int length, + int daddr, + int flags, + int type); + +extern struct ip_mib ip_statistics; + +#endif /* _IP_H */ diff --git a/include/net/ipip.h b/include/net/ipip.h new file mode 100644 index 000000000..398e375de --- /dev/null +++ b/include/net/ipip.h @@ -0,0 +1,4 @@ +extern int ipip_rcv(struct sk_buff *skb, struct device *dev, struct options *opt, + unsigned long daddr, unsigned short len, unsigned long saddr, + int redo, struct inet_protocol *protocol); + diff --git a/include/net/ipx.h b/include/net/ipx.h new file mode 100644 index 000000000..6842c8325 --- /dev/null +++ b/include/net/ipx.h @@ -0,0 +1,84 @@ + +/* + * The following information is in its entirety obtained from: + * + * Novell 'IPX Router Specification' Version 1.10 + * Part No. 107-000029-001 + * + * Which is available from ftp.novell.com + */ + +#ifndef _NET_INET_IPX_H_ +#define _NET_INET_IPX_H_ + +#include <linux/skbuff.h> +#include "datalink.h" +#include <linux/ipx.h> + +typedef struct +{ + unsigned long net; + unsigned char node[IPX_NODE_LEN]; + unsigned short sock; +} ipx_address; + +#define ipx_broadcast_node "\377\377\377\377\377\377" + +typedef struct ipx_packet +{ + unsigned short ipx_checksum; +#define IPX_NO_CHECKSUM 0xFFFF + unsigned short ipx_pktsize; + unsigned char ipx_tctrl; + unsigned char ipx_type; +#define IPX_TYPE_UNKNOWN 0x00 +#define IPX_TYPE_RIP 0x01 /* may also be 0 */ +#define IPX_TYPE_SAP 0x04 /* may also be 0 */ +#define IPX_TYPE_SPX 0x05 /* Not yet implemented */ +#define IPX_TYPE_NCP 0x11 /* $lots for docs on this (SPIT) */ +#define IPX_TYPE_PPROP 0x14 /* complicated flood fill brdcast [Not supported] */ + ipx_address ipx_dest __attribute__ ((packed)); + ipx_address ipx_source __attribute__ ((packed)); +} ipx_packet; + + +typedef struct sock ipx_socket; + +#include "ipxcall.h" +extern int ipx_rcv(struct sk_buff *skb, struct device *dev, struct packet_type *pt); +extern void ipxrtr_device_down(struct device *dev); + +typedef struct ipx_interface { + /* IPX address */ + unsigned long if_netnum; + unsigned char if_node[IPX_NODE_LEN]; + + /* physical device info */ + struct device *if_dev; + struct datalink_proto *if_dlink; + unsigned short if_dlink_type; + + /* socket support */ + unsigned short if_sknum; + ipx_socket *if_sklist; + + /* administrative overhead */ + int if_ipx_offset; + unsigned char if_internal; + unsigned char if_primary; + + struct ipx_interface *if_next; +} ipx_interface; + +typedef struct ipx_route { + unsigned long ir_net; + ipx_interface *ir_intrfc; + unsigned char ir_routed; + unsigned char ir_router_node[IPX_NODE_LEN]; + struct ipx_route *ir_next; +} ipx_route; + +#define IPX_MIN_EPHEMERAL_SOCKET 0x4000 +#define IPX_MAX_EPHEMERAL_SOCKET 0x7fff + +#endif diff --git a/include/net/ipxcall.h b/include/net/ipxcall.h new file mode 100644 index 000000000..eb5bd2bd2 --- /dev/null +++ b/include/net/ipxcall.h @@ -0,0 +1,2 @@ +/* Separate to keep compilation of protocols.c simpler */ +extern void ipx_proto_init(struct net_proto *pro); diff --git a/include/net/netrom.h b/include/net/netrom.h new file mode 100644 index 000000000..c6f772920 --- /dev/null +++ b/include/net/netrom.h @@ -0,0 +1,131 @@ +/* + * Declarations of NET/ROM type objects. + * + * Jonathan Naylor G4KLX 9/4/95 + */ + +#ifndef _NETROM_H +#define _NETROM_H +#include <linux/netrom.h> + +#define NR_PROTO_IP 0x0C + +#define NR_PROTOEXT 0x00 +#define NR_CONNREQ 0x01 +#define NR_CONNACK 0x02 +#define NR_DISCREQ 0x03 +#define NR_DISCACK 0x04 +#define NR_INFO 0x05 +#define NR_INFOACK 0x06 + +#define NR_CHOKE_FLAG 0x80 +#define NR_NAK_FLAG 0x40 +#define NR_MORE_FLAG 0x20 + +/* Define Link State constants. */ + +#define NR_STATE_0 0 +#define NR_STATE_1 1 +#define NR_STATE_2 2 +#define NR_STATE_3 3 + +#define NR_DEFAULT_T1 (120 * PR_SLOWHZ) /* Outstanding frames - 10 seconds */ +#define NR_DEFAULT_T2 (5 * PR_SLOWHZ) /* Response delay - 3 seconds */ +#define NR_DEFAULT_N2 3 /* Number of Retries */ +#define NR_DEFAULT_T4 (180 * PR_SLOWHZ) /* Transport Busy Delay */ +#define NR_DEFAULT_WINDOW 4 /* Default Window Size */ +#define NR_DEFAULT_OBS 6 /* Default Obscolesence Count */ +#define NR_DEFAULT_QUAL 10 /* Default Neighbour Quality */ +#define NR_DEFAULT_TTL 16 /* Default Time To Live */ +#define NR_MODULUS 256 +#define NR_MAX_WINDOW_SIZE 127 /* Maximum Window Allowable */ + +typedef struct { + ax25_address user_addr, source_addr, dest_addr; + unsigned char my_index, my_id; + unsigned char your_index, your_id; + unsigned char state; + unsigned short vs, vr, va, vl; + unsigned char condition; + unsigned char n2, n2count; + unsigned short t1, t2, rtt; + unsigned short t1timer, t2timer, t4timer; + struct sk_buff_head ack_queue, reseq_queue; + struct sock *sk; /* Backlink to socket */ +} nr_cb; + +struct nr_route { + unsigned char quality; + unsigned char obs_count; + unsigned short neighbour; +}; + +struct nr_node { + struct nr_node *next; + ax25_address callsign; + char mnemonic[7]; + unsigned char which; + unsigned char count; + struct nr_route routes[3]; +}; + +struct nr_neigh { + struct nr_neigh *next; + ax25_address callsign; + struct device *dev; + unsigned char quality; + unsigned char locked; + unsigned short count; + unsigned short number; +}; + +/* netrom.c */ +extern struct nr_parms_struct nr_default; +extern int nr_rx_frame(struct sk_buff *, struct device *); +extern void nr_destroy_socket(struct sock *); +extern int nr_get_info(char *, char **, off_t, int); + +/* nr_dev.c */ +extern int nr_rx_ip(struct sk_buff *, struct device *); +extern int nr_init(struct device *); + +#include "nrcall.h" + +/* nr_in.c */ +extern int nr_process_rx_frame(struct sock *, struct sk_buff *); + +/* nr_out.c */ +extern int nr_output(struct sock *, struct sk_buff *); +extern void nr_send_nak_frame(struct sock *); +extern void nr_kick(struct sock *); +extern void nr_transmit_buffer(struct sock *, struct sk_buff *); +extern void nr_nr_error_recovery(struct sock *); +extern void nr_establish_data_link(struct sock *); +extern void nr_enquiry_response(struct sock *); +extern void nr_check_iframes_acked(struct sock *, unsigned short); + +/* nr_route.c */ +extern void nr_rt_device_down(struct device *); +extern struct device *nr_dev_first(void); +extern struct device *nr_dev_get(ax25_address *); +extern int nr_rt_ioctl(unsigned int, void *); +extern void nr_link_failed(ax25_address *, struct device *); +extern int nr_route_frame(struct sk_buff *, struct device *); +extern int nr_nodes_get_info(char *, char **, off_t, int); +extern int nr_neigh_get_info(char *, char **, off_t, int); + +/* nr_subr.c */ +extern void nr_clear_tx_queue(struct sock *); +extern void nr_frames_acked(struct sock *, unsigned short); +extern void nr_requeue_frames(struct sock *); +extern int nr_validate_nr(struct sock *, unsigned short); +extern int nr_in_rx_window(struct sock *, unsigned short); +extern void nr_write_internal(struct sock *, int); +extern void nr_transmit_dm(struct sk_buff *); +extern unsigned short nr_calculate_t1(struct sock *); +extern void nr_calculate_rtt(struct sock *); + +/* ax25_timer */ +extern void nr_set_timer(struct sock *); + +#endif diff --git a/include/net/nrcall.h b/include/net/nrcall.h new file mode 100644 index 000000000..f58c2d4fe --- /dev/null +++ b/include/net/nrcall.h @@ -0,0 +1,2 @@ +/* Seperate to keep compilation of protocols.c simpler */ +extern void nr_proto_init(struct net_proto *pro); diff --git a/include/net/p8022.h b/include/net/p8022.h new file mode 100644 index 000000000..52c676be2 --- /dev/null +++ b/include/net/p8022.h @@ -0,0 +1,2 @@ +struct datalink_proto *register_8022_client(unsigned char type, int (*rcvfunc)(struct sk_buff *, struct device *, struct packet_type *)); + diff --git a/include/net/p8022call.h b/include/net/p8022call.h new file mode 100644 index 000000000..14f0c2cee --- /dev/null +++ b/include/net/p8022call.h @@ -0,0 +1,2 @@ +/* Separate to keep compilation of Space.c simpler */ +extern void p8022_proto_init(struct net_proto *); diff --git a/include/net/protocol.h b/include/net/protocol.h new file mode 100644 index 000000000..3e0b6fb3c --- /dev/null +++ b/include/net/protocol.h @@ -0,0 +1,59 @@ +/* + * 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 protocol dispatcher. + * + * Version: @(#)protocol.h 1.0.2 05/07/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. + * + * Changes: + * Alan Cox : Added a name field and a frag handler + * field for later. + */ + +#ifndef _PROTOCOL_H +#define _PROTOCOL_H + + +#define MAX_INET_PROTOS 32 /* Must be a power of 2 */ + + +/* This is used to register protocols. */ +struct inet_protocol { + int (*handler)(struct sk_buff *skb, struct device *dev, + struct options *opt, unsigned long daddr, + unsigned short len, unsigned long saddr, + int redo, struct inet_protocol *protocol); + int (*frag_handler)(struct sk_buff *skb, struct device *dev, + struct options *opt, unsigned long daddr, + unsigned short len, unsigned long saddr, + int redo, struct inet_protocol *protocol); + void (*err_handler)(int err, unsigned char *buff, + unsigned long daddr, + unsigned long saddr, + struct inet_protocol *protocol); + struct inet_protocol *next; + unsigned char protocol; + unsigned char copy:1; + void *data; + char *name; +}; + + +extern struct inet_protocol *inet_protocol_base; +extern struct inet_protocol *inet_protos[MAX_INET_PROTOS]; + + +extern void inet_add_protocol(struct inet_protocol *prot); +extern int inet_del_protocol(struct inet_protocol *prot); + + +#endif /* _PROTOCOL_H */ diff --git a/include/net/psnap.h b/include/net/psnap.h new file mode 100644 index 000000000..b69859dbd --- /dev/null +++ b/include/net/psnap.h @@ -0,0 +1,2 @@ +struct datalink_proto *register_snap_client(unsigned char *desc, int (*rcvfunc)(struct sk_buff *, struct device *, struct packet_type *)); + diff --git a/include/net/psnapcall.h b/include/net/psnapcall.h new file mode 100644 index 000000000..9da5763c5 --- /dev/null +++ b/include/net/psnapcall.h @@ -0,0 +1,2 @@ +/* Separate to keep compilation of Space.c simpler */ +extern void snap_proto_init(struct net_proto *); diff --git a/include/net/rarp.h b/include/net/rarp.h new file mode 100644 index 000000000..02ee7784f --- /dev/null +++ b/include/net/rarp.h @@ -0,0 +1,14 @@ +/* linux/net/inet/rarp.h */ +#ifndef _RARP_H +#define _RARP_H + +extern int rarp_ioctl(unsigned int cmd, void *arg); +extern int rarp_rcv(struct sk_buff *skb, + struct device *dev, + struct packet_type *pt); +extern int rarp_get_info(char *buffer, + char **start, + off_t offset, + int length); +#endif /* _RARP_H */ + diff --git a/include/net/raw.h b/include/net/raw.h new file mode 100644 index 000000000..8f1cf0c22 --- /dev/null +++ b/include/net/raw.h @@ -0,0 +1,34 @@ +/* + * 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 RAW-IP module. + * + * Version: @(#)raw.h 1.0.2 05/07/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 _RAW_H +#define _RAW_H + + +extern struct proto raw_prot; + + +extern void raw_err(int err, unsigned char *header, unsigned long daddr, + unsigned long saddr, struct inet_protocol *protocol); +extern int raw_recvfrom(struct sock *sk, unsigned char *to, + int len, int noblock, unsigned flags, + struct sockaddr_in *sin, int *addr_len); +extern int raw_read(struct sock *sk, unsigned char *buff, + int len, int noblock, unsigned flags); +extern int raw_rcv(struct sock *, struct sk_buff *, struct device *, + long, long); + +#endif /* _RAW_H */ diff --git a/include/net/route.h b/include/net/route.h new file mode 100644 index 000000000..d85fefdcd --- /dev/null +++ b/include/net/route.h @@ -0,0 +1,56 @@ +/* + * 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 router. + * + * Version: @(#)route.h 1.0.4 05/27/93 + * + * Authors: Ross Biro, <bir7@leland.Stanford.Edu> + * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> + * Fixes: + * Alan Cox : Reformatted. Added ip_rt_local() + * Alan Cox : Support for TCP parameters. + * + * 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 _ROUTE_H +#define _ROUTE_H + + +#include <linux/route.h> + + +/* This is an entry in the IP routing table. */ +struct rtable +{ + struct rtable *rt_next; + unsigned long rt_dst; + unsigned long rt_mask; + unsigned long rt_gateway; + unsigned char rt_flags; + unsigned char rt_metric; + short rt_refcnt; + unsigned long rt_use; + unsigned short rt_mss; + unsigned short rt_irtt; + unsigned long rt_window; + struct device *rt_dev; +}; + + +extern void ip_rt_flush(struct device *dev); +extern void ip_rt_add(short flags, unsigned long addr, unsigned long mask, + unsigned long gw, struct device *dev, unsigned short mss, unsigned long window, unsigned short irtt); +extern struct rtable *ip_rt_route(unsigned long daddr, struct options *opt, unsigned long *src_addr); +extern struct rtable *ip_rt_local(unsigned long daddr, struct options *opt, unsigned long *src_addr); +extern int rt_get_info(char * buffer, char **start, off_t offset, int length); +extern int ip_rt_ioctl(unsigned int cmd, void *arg); + +extern unsigned long rt_stamp; + +#endif /* _ROUTE_H */ diff --git a/include/net/snmp.h b/include/net/snmp.h new file mode 100644 index 000000000..552292be6 --- /dev/null +++ b/include/net/snmp.h @@ -0,0 +1,107 @@ +/* + * + * SNMP MIB entries for the IP subsystem. + * + * Alan Cox <gw4pts@gw4pts.ampr.org> + * + * We don't chose to implement SNMP in the kernel (this would + * be silly as SNMP is a pain in the backside in places). We do + * however need to collect the MIB statistics and export them + * out of /proc (eventually) + * + * 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 _SNMP_H +#define _SNMP_H + +/* + * We use all unsigned longs. Linux will soon be so reliable that even these + * will rapidly get too small 8-). Seriously consider the IpInReceives count + * on the 20Gb/s + networks people expect in a few years time! + */ + +struct ip_mib +{ + unsigned long IpForwarding; + unsigned long IpDefaultTTL; + unsigned long IpInReceives; + unsigned long IpInHdrErrors; + unsigned long IpInAddrErrors; + unsigned long IpForwDatagrams; + unsigned long IpInUnknownProtos; + unsigned long IpInDiscards; + unsigned long IpInDelivers; + unsigned long IpOutRequests; + unsigned long IpOutDiscards; + unsigned long IpOutNoRoutes; + unsigned long IpReasmTimeout; + unsigned long IpReasmReqds; + unsigned long IpReasmOKs; + unsigned long IpReasmFails; + unsigned long IpFragOKs; + unsigned long IpFragFails; + unsigned long IpFragCreates; +}; + + +struct icmp_mib +{ + unsigned long IcmpInMsgs; + unsigned long IcmpInErrors; + unsigned long IcmpInDestUnreachs; + unsigned long IcmpInTimeExcds; + unsigned long IcmpInParmProbs; + unsigned long IcmpInSrcQuenchs; + unsigned long IcmpInRedirects; + unsigned long IcmpInEchos; + unsigned long IcmpInEchoReps; + unsigned long IcmpInTimestamps; + unsigned long IcmpInTimestampReps; + unsigned long IcmpInAddrMasks; + unsigned long IcmpInAddrMaskReps; + unsigned long IcmpOutMsgs; + unsigned long IcmpOutErrors; + unsigned long IcmpOutDestUnreachs; + unsigned long IcmpOutTimeExcds; + unsigned long IcmpOutParmProbs; + unsigned long IcmpOutSrcQuenchs; + unsigned long IcmpOutRedirects; + unsigned long IcmpOutEchos; + unsigned long IcmpOutEchoReps; + unsigned long IcmpOutTimestamps; + unsigned long IcmpOutTimestampReps; + unsigned long IcmpOutAddrMasks; + unsigned long IcmpOutAddrMaskReps; +}; + +struct tcp_mib +{ + unsigned long TcpRtoAlgorithm; + unsigned long TcpRtoMin; + unsigned long TcpRtoMax; + unsigned long TcpMaxConn; + unsigned long TcpActiveOpens; + unsigned long TcpPassiveOpens; + unsigned long TcpAttemptFails; + unsigned long TcpEstabResets; + unsigned long TcpCurrEstab; + unsigned long TcpInSegs; + unsigned long TcpOutSegs; + unsigned long TcpRetransSegs; +}; + +struct udp_mib +{ + unsigned long UdpInDatagrams; + unsigned long UdpNoPorts; + unsigned long UdpInErrors; + unsigned long UdpOutDatagrams; +}; + + +#endif diff --git a/include/net/sock.h b/include/net/sock.h new file mode 100644 index 000000000..be7c84591 --- /dev/null +++ b/include/net/sock.h @@ -0,0 +1,354 @@ +/* + * 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 AF_INET socket handler. + * + * Version: @(#)sock.h 1.0.4 05/13/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> + * Florian La Roche <flla@stud.uni-sb.de> + * + * Fixes: + * Alan Cox : Volatiles in skbuff pointers. See + * skbuff comments. May be overdone, + * better to prove they can be removed + * than the reverse. + * Alan Cox : Added a zapped field for tcp to note + * a socket is reset and must stay shut up + * Alan Cox : New fields for options + * Pauline Middelink : identd support + * + * 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 _SOCK_H +#define _SOCK_H + +#include <linux/timer.h> +#include <linux/ip.h> /* struct options */ +#include <linux/in.h> /* struct sockaddr_in */ +#include <linux/tcp.h> /* struct tcphdr */ +#include <linux/config.h> + +#include <linux/skbuff.h> /* struct sk_buff */ +#include "protocol.h" /* struct inet_protocol */ +#ifdef CONFIG_AX25 +#include "ax25.h" +#ifdef CONFIG_NETROM +#include "netrom.h" +#endif +#endif +#ifdef CONFIG_IPX +#include "ipx.h" +#endif +#ifdef CONFIG_ATALK +#include "atalk.h" +#endif + +#include <linux/igmp.h> + +#define SOCK_ARRAY_SIZE 256 /* Think big (also on some systems a byte is faster */ + + +/* + * This structure really needs to be cleaned up. + * Most of it is for TCP, and not used by any of + * the other protocols. + */ +struct sock { + struct options *opt; + volatile unsigned long wmem_alloc; + volatile unsigned long rmem_alloc; + unsigned long write_seq; + unsigned long sent_seq; + unsigned long acked_seq; + unsigned long copied_seq; + unsigned long rcv_ack_seq; + unsigned long window_seq; + unsigned long fin_seq; + unsigned long urg_seq; + unsigned long urg_data; + + /* + * Not all are volatile, but some are, so we + * might as well say they all are. + */ + volatile char inuse, + dead, + urginline, + intr, + blog, + done, + reuse, + keepopen, + linger, + delay_acks, + destroy, + ack_timed, + no_check, + zapped, /* In ax25 & ipx means not linked */ + broadcast, + nonagle; + unsigned long lingertime; + int proc; + struct sock *next; + struct sock *prev; /* Doubly linked chain.. */ + struct sock *pair; + struct sk_buff * volatile send_head; + struct sk_buff * volatile send_tail; + struct sk_buff_head back_log; + struct sk_buff *partial; + struct timer_list partial_timer; + long retransmits; + struct sk_buff_head write_queue, + receive_queue; + struct proto *prot; + struct wait_queue **sleep; + unsigned long daddr; + unsigned long saddr; + unsigned short max_unacked; + unsigned short window; + unsigned short bytes_rcv; +/* mss is min(mtu, max_window) */ + unsigned short mtu; /* mss negotiated in the syn's */ + volatile unsigned short mss; /* current eff. mss - can change */ + volatile unsigned short user_mss; /* mss requested by user in ioctl */ + volatile unsigned short max_window; + unsigned long window_clamp; + unsigned short num; + volatile unsigned short cong_window; + volatile unsigned short cong_count; + volatile unsigned short ssthresh; + volatile unsigned short packets_out; + volatile unsigned short shutdown; + volatile unsigned long rtt; + volatile unsigned long mdev; + volatile unsigned long rto; +/* currently backoff isn't used, but I'm maintaining it in case + * we want to go back to a backoff formula that needs it + */ + volatile unsigned short backoff; + volatile short err; + unsigned char protocol; + volatile unsigned char state; + volatile unsigned char ack_backlog; + unsigned char max_ack_backlog; + unsigned char priority; + unsigned char debug; + unsigned short rcvbuf; + unsigned short sndbuf; + unsigned short type; + unsigned char localroute; /* Route locally only */ +#ifdef CONFIG_IPX + ipx_address ipx_dest_addr; + ipx_interface *ipx_intrfc; + unsigned short ipx_port; + unsigned short ipx_type; +#endif +#ifdef CONFIG_AX25 + ax25_cb *ax25; +#ifdef CONFIG_NETROM + nr_cb *nr; +#endif +#endif +#ifdef CONFIG_ATALK + struct atalk_sock at; +#endif + +/* IP 'private area' or will be eventually */ + int ip_ttl; /* TTL setting */ + int ip_tos; /* TOS */ + struct tcphdr dummy_th; + struct timer_list keepalive_timer; /* TCP keepalive hack */ + struct timer_list retransmit_timer; /* TCP retransmit timer */ + struct timer_list ack_timer; /* TCP delayed ack timer */ + int ip_xmit_timeout; /* Why the timeout is running */ + struct rtable *ip_route_cache; /* Cached output route */ + unsigned long ip_route_stamp; /* Route cache stamp */ + unsigned long ip_route_daddr; /* Target address */ + unsigned long ip_route_saddr; /* Source address */ + int ip_route_local; /* State of locality flag */ + unsigned long ip_hcache_stamp; /* Header cache stamp */ + unsigned long *ip_hcache_ver; /* Pointer to version of cache */ + char ip_hcache_data[16]; /* Cached header */ + int ip_hcache_state; /* Have we a cached header */ + unsigned char ip_option_len; /* Length of IP options */ + unsigned char ip_option_flen; /* Second fragment option length */ + unsigned char ip_opt_next_strict; /* Next hop is strict route */ + unsigned long ip_opt_next_hop; /* Next hop if forced */ + unsigned char *ip_opt_ptr[2]; /* IP option pointers */ +#ifdef CONFIG_IP_MULTICAST + int ip_mc_ttl; /* Multicasting TTL */ + int ip_mc_loop; /* Loopback */ + char ip_mc_name[MAX_ADDR_LEN]; /* Multicast device name */ + struct ip_mc_socklist *ip_mc_list; /* Group array */ +#endif + + /* This part is used for the timeout functions (timer.c). */ + int timeout; /* What are we waiting for? */ + struct timer_list timer; /* This is the TIME_WAIT/receive timer when we are doing IP */ + struct timeval stamp; + + /* identd */ + struct socket *socket; + + /* Callbacks */ + void (*state_change)(struct sock *sk); + void (*data_ready)(struct sock *sk,int bytes); + void (*write_space)(struct sock *sk); + void (*error_report)(struct sock *sk); + +}; + +struct proto { + struct sk_buff * (*wmalloc)(struct sock *sk, + unsigned long size, int force, + int priority); + struct sk_buff * (*rmalloc)(struct sock *sk, + unsigned long size, int force, + int priority); + void (*wfree)(struct sock *sk, struct sk_buff *skb, + unsigned long size); + void (*rfree)(struct sock *sk, struct sk_buff *skb, + unsigned long size); + unsigned long (*rspace)(struct sock *sk); + unsigned long (*wspace)(struct sock *sk); + void (*close)(struct sock *sk, int timeout); + int (*read)(struct sock *sk, unsigned char *to, + int len, int nonblock, unsigned flags); + int (*write)(struct sock *sk, unsigned char *to, + int len, int nonblock, unsigned flags); + int (*sendto)(struct sock *sk, + unsigned char *from, int len, int noblock, + unsigned flags, struct sockaddr_in *usin, + int addr_len); + int (*recvfrom)(struct sock *sk, + unsigned char *from, int len, int noblock, + unsigned flags, struct sockaddr_in *usin, + int *addr_len); + int (*build_header)(struct sk_buff *skb, + unsigned long saddr, + unsigned long daddr, + struct device **dev, int type, + struct options *opt, int len, int tos, int ttl); + int (*connect)(struct sock *sk, + struct sockaddr_in *usin, int addr_len); + struct sock * (*accept) (struct sock *sk, int flags); + void (*queue_xmit)(struct sock *sk, + struct device *dev, struct sk_buff *skb, + int free); + void (*retransmit)(struct sock *sk, int all); + void (*write_wakeup)(struct sock *sk); + void (*read_wakeup)(struct sock *sk); + int (*rcv)(struct sk_buff *buff, struct device *dev, + struct options *opt, unsigned long daddr, + unsigned short len, unsigned long saddr, + int redo, struct inet_protocol *protocol); + int (*select)(struct sock *sk, int which, + select_table *wait); + int (*ioctl)(struct sock *sk, int cmd, + unsigned long arg); + int (*init)(struct sock *sk); + void (*shutdown)(struct sock *sk, int how); + int (*setsockopt)(struct sock *sk, int level, int optname, + char *optval, int optlen); + int (*getsockopt)(struct sock *sk, int level, int optname, + char *optval, int *option); + unsigned short max_header; + unsigned long retransmits; + char name[32]; + int inuse, highestinuse; +#ifndef PACKET_C /* Hack to save 1K for packet sockets */ + struct sock * sock_array[SOCK_ARRAY_SIZE]; +#endif PACKET_C +}; + +#define TIME_WRITE 1 +#define TIME_CLOSE 2 +#define TIME_KEEPOPEN 3 +#define TIME_DESTROY 4 +#define TIME_DONE 5 /* used to absorb those last few packets */ +#define TIME_PROBE0 6 +#define SOCK_DESTROY_TIME 1000 /* about 10 seconds */ + +#define PROT_SOCK 1024 /* Sockets 0-1023 can't be bound too unless you are superuser */ + +#define SHUTDOWN_MASK 3 +#define RCV_SHUTDOWN 1 +#define SEND_SHUTDOWN 2 + + +extern void destroy_sock(struct sock *sk); +extern unsigned short get_new_socknum(struct proto *, unsigned short); +extern void put_sock(unsigned short, struct sock *); +extern void release_sock(struct sock *sk); +extern struct sock *get_sock(struct proto *, unsigned short, + unsigned long, unsigned short, + unsigned long); +extern struct sock *get_sock_mcast(struct sock *, unsigned short, + unsigned long, unsigned short, + unsigned long); +extern struct sock *get_sock_raw(struct sock *, unsigned short, + unsigned long, unsigned long); + +extern struct sk_buff *sock_wmalloc(struct sock *sk, + unsigned long size, int force, + int priority); +extern struct sk_buff *sock_rmalloc(struct sock *sk, + unsigned long size, int force, + int priority); +extern void sock_wfree(struct sock *sk, struct sk_buff *skb, + unsigned long size); +extern void sock_rfree(struct sock *sk, struct sk_buff *skb, + unsigned long size); +extern unsigned long sock_rspace(struct sock *sk); +extern unsigned long sock_wspace(struct sock *sk); + +extern int sock_setsockopt(struct sock *sk,int level,int op,char *optval,int optlen); + +extern int sock_getsockopt(struct sock *sk,int level,int op,char *optval,int *optlen); +extern struct sk_buff *sock_alloc_send_skb(struct sock *skb, unsigned long size, int noblock, int *errcode); + +/* + * Queue a received datagram if it will fit. Stream and sequenced protocols + * can't normally use this as they need to fit buffers in and play with them. + * + * Inlined as its very short and called for pretty much every packet ever + * received. + */ + +extern __inline__ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) +{ + unsigned long flags; + if(sk->rmem_alloc + skb->mem_len >= sk->rcvbuf) + return -ENOMEM; + save_flags(flags); + cli(); + sk->rmem_alloc+=skb->mem_len; + skb->sk=sk; + restore_flags(flags); + skb_queue_tail(&sk->receive_queue,skb); + if(!sk->dead) + sk->data_ready(sk,skb->len); + return 0; +} + +/* declarations from timer.c */ +extern struct sock *timer_base; + +void delete_timer (struct sock *); +void reset_timer (struct sock *, int, unsigned long); +void net_timer (unsigned long); + + +/* Enable debug/info messages */ + +#define NETDEBUG(x) x + +#endif /* _SOCK_H */ diff --git a/include/net/tcp.h b/include/net/tcp.h new file mode 100644 index 000000000..efeaac0da --- /dev/null +++ b/include/net/tcp.h @@ -0,0 +1,142 @@ +/* + * 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 module. + * + * Version: @(#)tcp.h 1.0.5 05/23/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 _TCP_H +#define _TCP_H + +#include <linux/tcp.h> + +#define MAX_SYN_SIZE 44 + MAX_HEADER +#define MAX_FIN_SIZE 40 + MAX_HEADER +#define MAX_ACK_SIZE 40 + MAX_HEADER +#define MAX_RESET_SIZE 40 + MAX_HEADER +#define MAX_WINDOW 16384 +#define MIN_WINDOW 2048 +#define MAX_ACK_BACKLOG 2 +#define MIN_WRITE_SPACE 2048 +#define TCP_WINDOW_DIFF 2048 + +/* urg_data states */ +#define URG_VALID 0x0100 +#define URG_NOTYET 0x0200 +#define URG_READ 0x0400 + +#define TCP_RETR1 7 /* + * This is how many retries it does before it + * tries to figure out if the gateway is + * down. + */ + +#define TCP_RETR2 15 /* + * This should take at least + * 90 minutes to time out. + */ + +#define TCP_TIMEOUT_LEN (15*60*HZ) /* should be about 15 mins */ +#define TCP_TIMEWAIT_LEN (60*HZ) /* how long to wait to successfully + * close the socket, about 60 seconds */ +#define TCP_FIN_TIMEOUT (3*60*HZ) /* BSD style FIN_WAIT2 deadlock breaker */ +#define TCP_ACK_TIME (3*HZ) /* time to delay before sending an ACK */ +#define TCP_DONE_TIME 250 /* maximum time to wait before actually + * destroying a socket */ +#define TCP_WRITE_TIME 3000 /* initial time to wait for an ACK, + * after last transmit */ +#define TCP_TIMEOUT_INIT (3*HZ) /* RFC 1122 initial timeout value */ +#define TCP_SYN_RETRIES 10 /* number of times to retry opening a + * connection (TCP_RETR2-....) */ +#define TCP_PROBEWAIT_LEN 100 /* time to wait between probes when + * I've got something to write and + * there is no window */ + +#define TCP_NO_CHECK 0 /* turn to one if you want the default + * to be no checksum */ + + +/* + * TCP option + */ + +#define TCPOPT_NOP 1 /* Padding */ +#define TCPOPT_EOL 0 /* End of options */ +#define TCPOPT_MSS 2 /* Segment size negotiating */ +/* + * We don't use these yet, but they are for PAWS and big windows + */ +#define TCPOPT_WINDOW 3 /* Window scaling */ +#define TCPOPT_TIMESTAMP 8 /* Better RTT estimations/PAWS */ + + +/* + * The next routines deal with comparing 32 bit unsigned ints + * and worry about wraparound (automatic with unsigned arithmetic). + */ + +extern __inline int before(unsigned long seq1, unsigned long seq2) +{ + return (long)(seq1-seq2) < 0; +} + +extern __inline int after(unsigned long seq1, unsigned long seq2) +{ + return (long)(seq1-seq2) > 0; +} + + +/* is s2<=s1<=s3 ? */ +extern __inline int between(unsigned long seq1, unsigned long seq2, unsigned long seq3) +{ + return (after(seq1+1, seq2) && before(seq1, seq3+1)); +} + + +/* + * List all states of a TCP socket that can be viewed as a "connected" + * state. This now includes TCP_SYN_RECV, although I am not yet fully + * convinced that this is the solution for the 'getpeername(2)' + * problem. Thanks to Stephen A. Wood <saw@cebaf.gov> -FvK + */ +extern __inline const int +tcp_connected(const int state) +{ + return(state == TCP_ESTABLISHED || state == TCP_CLOSE_WAIT || + state == TCP_FIN_WAIT1 || state == TCP_FIN_WAIT2 || + state == TCP_SYN_RECV); +} + + +extern struct proto tcp_prot; + + +extern void tcp_err(int err, unsigned char *header, unsigned long daddr, + unsigned long saddr, struct inet_protocol *protocol); +extern void tcp_shutdown (struct sock *sk, int how); +extern int tcp_rcv(struct sk_buff *skb, struct device *dev, + struct options *opt, unsigned long daddr, + unsigned short len, unsigned long saddr, int redo, + struct inet_protocol *protocol); + +extern int tcp_ioctl(struct sock *sk, int cmd, unsigned long arg); + +extern int tcp_select_window(struct sock *sk); +extern void tcp_send_check(struct tcphdr *th, unsigned long saddr, + unsigned long daddr, int len, struct sock *sk); +extern void tcp_send_probe0(struct sock *sk); +extern void tcp_enqueue_partial(struct sk_buff *, struct sock *); +extern struct sk_buff * tcp_dequeue_partial(struct sock *); +extern void tcp_cache_zap(void); + +#endif /* _TCP_H */ diff --git a/include/net/udp.h b/include/net/udp.h new file mode 100644 index 000000000..62f0c7a0e --- /dev/null +++ b/include/net/udp.h @@ -0,0 +1,52 @@ +/* + * 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 module. + * + * Version: @(#)udp.h 1.0.2 05/07/93 + * + * Authors: Ross Biro, <bir7@leland.Stanford.Edu> + * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> + * + * Fixes: + * Alan Cox : Turned on udp checksums. I don't want to + * chase 'memory corruption' bugs that aren't! + * + * 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 _UDP_H +#define _UDP_H + +#include <linux/udp.h> + + +#define UDP_NO_CHECK 0 + + +extern struct proto udp_prot; + + +extern void udp_err(int err, unsigned char *header, unsigned long daddr, + unsigned long saddr, struct inet_protocol *protocol); +extern void udp_send_check(struct udphdr *uh, unsigned long saddr, + unsigned long daddr, int len, struct sock *sk); +extern int udp_recvfrom(struct sock *sk, unsigned char *to, + int len, int noblock, unsigned flags, + struct sockaddr_in *sin, int *addr_len); +extern int udp_read(struct sock *sk, unsigned char *buff, + int len, int noblock, unsigned flags); +extern int udp_connect(struct sock *sk, + struct sockaddr_in *usin, int addr_len); +extern int udp_rcv(struct sk_buff *skb, struct device *dev, + struct options *opt, unsigned long daddr, + unsigned short len, unsigned long saddr, int redo, + struct inet_protocol *protocol); +extern int udp_ioctl(struct sock *sk, int cmd, unsigned long arg); +extern void udp_cache_zap(void); /* Remove udp last socket cache */ + +#endif /* _UDP_H */ diff --git a/include/net/unix.h b/include/net/unix.h new file mode 100644 index 000000000..dba43800f --- /dev/null +++ b/include/net/unix.h @@ -0,0 +1,69 @@ +/* + * UNIX An implementation of the AF_UNIX network domain for the + * LINUX operating system. UNIX is implemented using the + * BSD Socket interface as the means of communication with + * the user level. + * + * This file describes some things of the UNIX protocol family + * module. It is mainly used for the "proc" sub-module now, + * but it may be useful for cleaning up the UNIX module as a + * whole later. + * + * Version: @(#)unix.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> + * + * Fixes: + * Dmitry Gorodchanin - proc locking + * + * 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. + */ + + +#ifdef _LINUX_UN_H + + +struct unix_proto_data { + int refcnt; /* cnt of reference 0=free */ + /* -1=not initialised -bgm */ + struct socket *socket; /* socket we're bound to */ + int protocol; + struct sockaddr_un sockaddr_un; + short sockaddr_len; /* >0 if name bound */ + char *buf; + int bp_head, bp_tail; + struct inode *inode; + struct unix_proto_data *peerupd; + struct wait_queue *wait; /* Lock across page faults (FvK) */ + int lock_flag; +}; + +extern struct unix_proto_data unix_datas[NSOCKETS_UNIX]; + + +#define last_unix_data (unix_datas + NSOCKETS_UNIX - 1) + + +#define UN_DATA(SOCK) ((struct unix_proto_data *)(SOCK)->data) +#define UN_PATH_OFFSET ((unsigned long)((struct sockaddr_un *)0) \ + ->sun_path) + +/* + * Buffer size must be power of 2. buffer mgmt inspired by pipe code. + * note that buffer contents can wraparound, and we can write one byte less + * than full size to discern full vs empty. + */ +#define BUF_SIZE PAGE_SIZE +#define UN_BUF_AVAIL(UPD) (((UPD)->bp_head - (UPD)->bp_tail) & \ + (BUF_SIZE-1)) +#define UN_BUF_SPACE(UPD) ((BUF_SIZE-1) - UN_BUF_AVAIL(UPD)) + +#endif /* _LINUX_UN_H */ + + +extern void unix_proto_init(struct net_proto *pro); |