[BACK]Return to arch.h CVS log [TXT][DIR] Up to [local] / prex-old / sys / arch / i386 / include

Annotation of prex-old/sys/arch/i386/include/arch.h, Revision 1.1.1.1

1.1       nbrk        1: /*
                      2:  * Copyright (c) 2005-2007, Kohsuke Ohtani
                      3:  * All rights reserved.
                      4:  *
                      5:  * Redistribution and use in source and binary forms, with or without
                      6:  * modification, are permitted provided that the following conditions
                      7:  * are met:
                      8:  * 1. Redistributions of source code must retain the above copyright
                      9:  *    notice, this list of conditions and the following disclaimer.
                     10:  * 2. Redistributions in binary form must reproduce the above copyright
                     11:  *    notice, this list of conditions and the following disclaimer in the
                     12:  *    documentation and/or other materials provided with the distribution.
                     13:  * 3. Neither the name of the author nor the names of any co-contributors
                     14:  *    may be used to endorse or promote products derived from this software
                     15:  *    without specific prior written permission.
                     16:  *
                     17:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
                     18:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     19:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     20:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
                     21:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     22:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     23:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     24:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     25:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     26:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     27:  * SUCH DAMAGE.
                     28:  */
                     29:
                     30: #ifndef _ARCH_H
                     31: #define _ARCH_H
                     32:
                     33: /*
                     34:  * Common register frame for trap/interrupt.
                     35:  * These cpu state are saved into top of the kernel stack in
                     36:  * trap/interrupt entries. Since the arguments of system calls are
                     37:  * passed via registers, the system call library is completely
                     38:  * dependent on this register format.
                     39:  *
                     40:  * The value of ss & esp are not valid for kernel mode trap
                     41:  * because these are set only when privilege level is changed.
                     42:  */
                     43: struct cpu_regs {
                     44:        u_long  ebx;            /*  +0 (00) --- s/w trap frame --- */
                     45:        u_long  ecx;            /*  +4 (04) */
                     46:        u_long  edx;            /*  +8 (08) */
                     47:        u_long  esi;            /* +12 (0C) */
                     48:        u_long  edi;            /* +16 (10) */
                     49:        u_long  ebp;            /* +20 (14) */
                     50:        u_long  eax;            /* +24 (18) */
                     51:        u_long  ds;             /* +28 (1C) */
                     52:        u_long  es;             /* +32 (20) */
                     53:        u_long  trap_no;        /* +36 (24) --- h/w trap frame --- */
                     54:        u_long  err_code;       /* +40 (28) */
                     55:        u_long  eip;            /* +44 (2C) */
                     56:        u_long  cs;             /* +48 (30) */
                     57:        u_long  eflags;         /* +52 (34) */
                     58:        u_long  esp;            /* +56 (38) */
                     59:        u_long  ss;             /* +60 (3C) */
                     60: };
                     61:
                     62: /*
                     63:  * Kernel mode context for context switching.
                     64:  */
                     65: struct kern_regs {
                     66:        u_long  eip;            /*  +0 (00) */
                     67:        u_long  edi;            /*  +4 (04) */
                     68:        u_long  esi;            /*  +8 (08) */
                     69:        u_long  ebp;            /* +12 (0C) */
                     70:        u_long  esp;            /* +16 (10) */
                     71: };
                     72:
                     73: #ifdef CONFIG_FPU
                     74: /*
                     75:  * FPU register for fsave/frstor
                     76:  */
                     77: struct fpu_regs {
                     78:        u_long  ctrl_word;
                     79:        u_long  stat_word;
                     80:        u_long  tag_word;
                     81:        u_long  ip_offset;
                     82:        u_long  cs_sel;
                     83:        u_long  op_offset;
                     84:        u_long  op_sel;
                     85:        u_long  st[20];
                     86: };
                     87: #endif
                     88:
                     89: /*
                     90:  * Processor context
                     91:  */
                     92: struct context {
                     93:        struct kern_regs kregs;         /* kernel mode registers */
                     94:        struct cpu_regs *uregs;         /* user mode registers */
                     95: #ifdef CONFIG_FPU
                     96:        struct fpu_regs *fregs;         /* co-processor registers */
                     97: #endif
                     98:        u_long  esp0;                   /* top of kernel stack */
                     99: };
                    100:
                    101: typedef struct context *context_t;     /* context id */
                    102:
                    103: /* types for context_set */
                    104: #define CTX_UENTRY     0               /* set user mode entry addres */
                    105: #define CTX_USTACK     1               /* set user mode stack address */
                    106: #define CTX_KENTRY     2               /* set kernel mode entry address */
                    107: #define CTX_KARG       3               /* set kernel mode argument */
                    108:
                    109: extern void context_init(context_t, u_long);
                    110: extern void context_set(context_t, int, u_long);
                    111: extern void context_switch(context_t, context_t);
                    112: extern void context_save(context_t, int);
                    113: extern void context_restore(context_t, void *);
                    114:
                    115: /*
                    116:  * Memory Management Unit
                    117:  */
                    118:
                    119: typedef long *pgd_t;                   /* page directory */
                    120:
                    121: /* memory page type */
                    122: #define PG_UNMAP       0               /* no page */
                    123: #define PG_READ                1               /* read only */
                    124: #define PG_WRITE       2               /* read/write */
                    125:
                    126: #ifdef CONFIG_MMU
                    127: extern void mmu_init(void);
                    128: extern pgd_t mmu_newmap(void);
                    129: extern void mmu_delmap(pgd_t);
                    130: extern int  mmu_map(pgd_t, void *, void *, size_t, int);
                    131: extern void mmu_switch(pgd_t);
                    132: extern void *mmu_extract(pgd_t, void *, size_t);
                    133: #else /* CONFIG_MMU */
                    134: #define mmu_init()             do {} while (0)
                    135: #endif /* CONFIG_MMU */
                    136:
                    137: /*
                    138:  * User Memory access
                    139:  */
                    140: extern int umem_copyin(void *, void *, size_t);
                    141: extern int umem_copyout(void *, void *, size_t);
                    142: extern int umem_strnlen(const char *, size_t, size_t *);
                    143:
                    144: #define breakpoint()   __asm__ __volatile__("int $3"::)
                    145:
                    146: #endif /* !_ARCH_H */

CVSweb