Linux kernel & device driver programming

Cross-Referenced Linux and Device Driver Code

[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ]
Version: [ 2.6.11.8 ] [ 2.6.25 ] [ 2.6.25.8 ] [ 2.6.31.13 ] Architecture: [ i386 ]
  1 /* $Id: processor.h,v 1.83 2001/10/08 09:32:13 davem Exp $
  2  * include/asm-sparc/processor.h
  3  *
  4  * Copyright (C) 1994 David S. Miller (davem@caip.rutgers.edu)
  5  */
  6 
  7 #ifndef __ASM_SPARC_PROCESSOR_H
  8 #define __ASM_SPARC_PROCESSOR_H
  9 
 10 /*
 11  * Sparc32 implementation of macro that returns current
 12  * instruction pointer ("program counter").
 13  */
 14 #define current_text_addr() ({ void *pc; __asm__("sethi %%hi(1f), %0; or %0, %%lo(1f), %0;\n1:" : "=r" (pc)); pc; })
 15 
 16 #include <linux/a.out.h>
 17 
 18 #include <asm/psr.h>
 19 #include <asm/ptrace.h>
 20 #include <asm/head.h>
 21 #include <asm/signal.h>
 22 #include <asm/segment.h>
 23 #include <asm/btfixup.h>
 24 #include <asm/page.h>
 25 
 26 /*
 27  * The sparc has no problems with write protection
 28  */
 29 #define wp_works_ok 1
 30 #define wp_works_ok__is_a_macro /* for versions in ksyms.c */
 31 
 32 /* Whee, this is STACK_TOP + PAGE_SIZE and the lowest kernel address too... 
 33  * That one page is used to protect kernel from intruders, so that
 34  * we can make our access_ok test faster
 35  */
 36 #define TASK_SIZE       PAGE_OFFSET
 37 
 38 struct task_struct;
 39 
 40 #ifdef __KERNEL__
 41 struct fpq {
 42         unsigned long *insn_addr;
 43         unsigned long insn;
 44 };
 45 #endif
 46 
 47 typedef struct {
 48         int seg;
 49 } mm_segment_t;
 50 
 51 /* The Sparc processor specific thread struct. */
 52 struct thread_struct {
 53         struct pt_regs *kregs;
 54         unsigned int _pad1;
 55 
 56         /* Special child fork kpsr/kwim values. */
 57         unsigned long fork_kpsr __attribute__ ((aligned (8)));
 58         unsigned long fork_kwim;
 59 
 60         /* Floating point regs */
 61         unsigned long   float_regs[32] __attribute__ ((aligned (8)));
 62         unsigned long   fsr;
 63         unsigned long   fpqdepth;
 64         struct fpq      fpqueue[16];
 65         unsigned long flags;
 66         mm_segment_t current_ds;
 67         struct exec core_exec;     /* just what it says. */
 68         int new_signal;
 69 };
 70 
 71 #define SPARC_FLAG_KTHREAD      0x1    /* task is a kernel thread */
 72 #define SPARC_FLAG_UNALIGNED    0x2    /* is allowed to do unaligned accesses */
 73 
 74 #define INIT_THREAD  { \
 75         .flags = SPARC_FLAG_KTHREAD, \
 76         .current_ds = KERNEL_DS, \
 77 }
 78 
 79 /* Return saved PC of a blocked thread. */
 80 extern unsigned long thread_saved_pc(struct task_struct *t);
 81 
 82 /* Do necessary setup to start up a newly executed thread. */
 83 extern __inline__ void start_thread(struct pt_regs * regs, unsigned long pc,
 84                                     unsigned long sp)
 85 {
 86         register unsigned long zero asm("g1");
 87 
 88         regs->psr = (regs->psr & (PSR_CWP)) | PSR_S;
 89         regs->pc = ((pc & (~3)) - 4);
 90         regs->npc = regs->pc + 4;
 91         regs->y = 0;
 92         zero = 0;
 93         __asm__ __volatile__("std\t%%g0, [%0 + %3 + 0x00]\n\t"
 94                              "std\t%%g0, [%0 + %3 + 0x08]\n\t"
 95                              "std\t%%g0, [%0 + %3 + 0x10]\n\t"
 96                              "std\t%%g0, [%0 + %3 + 0x18]\n\t"
 97                              "std\t%%g0, [%0 + %3 + 0x20]\n\t"
 98                              "std\t%%g0, [%0 + %3 + 0x28]\n\t"
 99                              "std\t%%g0, [%0 + %3 + 0x30]\n\t"
100                              "st\t%1, [%0 + %3 + 0x38]\n\t"
101                              "st\t%%g0, [%0 + %3 + 0x3c]"
102                              : /* no outputs */
103                              : "r" (regs),
104                                "r" (sp - sizeof(struct reg_window)),
105                                "r" (zero),
106                                "i" ((const unsigned long)(&((struct pt_regs *)0)->u_regs[0]))
107                              : "memory");
108 }
109 
110 /* Free all resources held by a thread. */
111 #define release_thread(tsk)             do { } while(0)
112 extern pid_t kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
113 
114 /* Prepare to copy thread state - unlazy all lazy status */
115 #define prepare_to_copy(tsk)    do { } while (0)
116 
117 extern unsigned long get_wchan(struct task_struct *);
118 
119 #define KSTK_EIP(tsk)  ((tsk)->thread.kregs->pc)
120 #define KSTK_ESP(tsk)  ((tsk)->thread.kregs->u_regs[UREG_FP])
121 
122 #ifdef __KERNEL__
123 
124 extern struct task_struct *last_task_used_math;
125 
126 #define cpu_relax()     barrier()
127 
128 #endif
129 
130 #endif /* __ASM_SPARC_PROCESSOR_H */
131 
  This page was automatically generated by the LXR engine.