diff options
author | Ralf Baechle <ralf@linux-mips.org> | 1994-12-01 08:00:00 +0000 |
---|---|---|
committer | <ralf@linux-mips.org> | 1994-12-01 08:00:00 +0000 |
commit | 90ecc248e200fee448001248dde0ca540dd3ef64 (patch) | |
tree | a3fe89494ce63b4835f0f9cf5c45e74cde88252b /include/asm-i386 | |
parent | 1513ff9b7899ab588401c89db0e99903dbf5f886 (diff) |
Import of Linux/MIPS 1.1.68
Diffstat (limited to 'include/asm-i386')
-rw-r--r-- | include/asm-i386/bitops.h | 14 | ||||
-rw-r--r-- | include/asm-i386/head.h | 20 | ||||
-rw-r--r-- | include/asm-i386/in.h | 64 | ||||
-rw-r--r-- | include/asm-i386/interrupt.h | 19 | ||||
-rw-r--r-- | include/asm-i386/mm.h | 73 | ||||
-rw-r--r-- | include/asm-i386/ptrace.h | 61 | ||||
-rw-r--r-- | include/asm-i386/sched.h | 331 | ||||
-rw-r--r-- | include/asm-i386/signal.h | 33 | ||||
-rw-r--r-- | include/asm-i386/slots.h | 17 | ||||
-rw-r--r-- | include/asm-i386/system.h | 10 |
10 files changed, 642 insertions, 0 deletions
diff --git a/include/asm-i386/bitops.h b/include/asm-i386/bitops.h index ee339bd64..36b0bedc0 100644 --- a/include/asm-i386/bitops.h +++ b/include/asm-i386/bitops.h @@ -132,4 +132,18 @@ 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/head.h b/include/asm-i386/head.h new file mode 100644 index 000000000..c77f02bdf --- /dev/null +++ b/include/asm-i386/head.h @@ -0,0 +1,20 @@ +#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 new file mode 100644 index 000000000..91b2f4d04 --- /dev/null +++ b/include/asm-i386/in.h @@ -0,0 +1,64 @@ +#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 new file mode 100644 index 000000000..30ccb5b15 --- /dev/null +++ b/include/asm-i386/interrupt.h @@ -0,0 +1,19 @@ +#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/mm.h b/include/asm-i386/mm.h new file mode 100644 index 000000000..56df7bf23 --- /dev/null +++ b/include/asm-i386/mm.h @@ -0,0 +1,73 @@ +#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/ptrace.h b/include/asm-i386/ptrace.h new file mode 100644 index 000000000..294acc7bd --- /dev/null +++ b/include/asm-i386/ptrace.h @@ -0,0 +1,61 @@ +#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. */ + +#define EBX 0 +#define ECX 1 +#define EDX 2 +#define ESI 3 +#define EDI 4 +#define EBP 5 +#define EAX 6 +#define DS 7 +#define ES 8 +#define FS 9 +#define GS 10 +#define ORIG_EAX 11 +#define EIP 12 +#define CS 13 +#define EFL 14 +#define UESP 15 +#define SS 16 + + +/* this struct defines the way the registers are stored on the + stack during a system call. */ + +struct pt_regs { + long ebx; + long ecx; + long edx; + long esi; + long edi; + long ebp; + long eax; + unsigned short ds, __dsu; + unsigned short es, __esu; + unsigned short fs, __fsu; + unsigned short gs, __gsu; + long orig_eax; + long eip; + unsigned short cs, __csu; + long eflags; + long esp; + unsigned short ss, __ssu; +}; + +/* + * This function computes the interrupt number from the stack frame + */ +#define pt_regs2irq(p) ((int) -(((struct pt_regs *)p)->orig_eax+2)) + +#endif /* _ASM_I386_PTRACE_H */ diff --git a/include/asm-i386/sched.h b/include/asm-i386/sched.h new file mode 100644 index 000000000..1371d0226 --- /dev/null +++ b/include/asm-i386/sched.h @@ -0,0 +1,331 @@ +#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/signal.h b/include/asm-i386/signal.h new file mode 100644 index 000000000..5982091a3 --- /dev/null +++ b/include/asm-i386/signal.h @@ -0,0 +1,33 @@ +#ifndef _ASM_I386_SIGNAL_H +#define _ASM_I386_SIGNAL_H + +#ifdef __KERNEL__ + +struct sigcontext_struct { + unsigned short gs, __gsh; + unsigned short fs, __fsh; + unsigned short es, __esh; + unsigned short ds, __dsh; + unsigned long edi; + unsigned long esi; + unsigned long ebp; + unsigned long esp; + unsigned long ebx; + unsigned long edx; + unsigned long ecx; + unsigned long eax; + unsigned long trapno; + unsigned long err; + unsigned long eip; + unsigned short cs, __csh; + unsigned long eflags; + unsigned long esp_at_signal; + unsigned short ss, __ssh; + unsigned long i387; + unsigned long oldmask; + unsigned long cr2; +}; + +#endif + +#endif /* _ASM_I386_SIGNAL_H */ diff --git a/include/asm-i386/slots.h b/include/asm-i386/slots.h new file mode 100644 index 000000000..21139c59c --- /dev/null +++ b/include/asm-i386/slots.h @@ -0,0 +1,17 @@ +/* + * include/asm-i386/slots.h + * + * Written by Ralf Baechle + * Copyright (C) 1994 by Waldorf GMBH + */ +#ifndef _ASM_I386_SLOTS_H +#define _ASM_I386_SLOTS_H + +/* + * SLOTSPACE is the address to which the physical address 0 + * of the Slotspace is mapped by the chipset in the main CPU's + * address space. + */ +#define SLOTSPACE 0x0 + +#endif /* _ASM_I386_SLOTS_H */ diff --git a/include/asm-i386/system.h b/include/asm-i386/system.h index 04c8b96b6..23af2e513 100644 --- a/include/asm-i386/system.h +++ b/include/asm-i386/system.h @@ -44,6 +44,16 @@ extern inline int tas(char * m) return res; } +/* + * atomic exchange + */ +#define atomic_exchange(m,r) \ + __asm__ __volatile__( \ + "xchgl %0,%2" \ + : "=r" ((r)) \ + : "0" ((r)), "m" (*(m)) \ + : "memory"); + #define save_flags(x) \ __asm__ __volatile__("pushfl ; popl %0":"=r" (x): /* no input */ :"memory") |