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 ]

Diff markup

Differences between /linux/arch/i386/mach-voyager/voyager_thread.c (Version 2.6.11.8) and /linux/arch/i386/mach-voyager/voyager_thread.c (Version 2.6.25)


  1 /* -*- mode: c; c-basic-offset: 8 -*- */            1 
  2                                                   
  3 /* Copyright (C) 2001                             
  4  *                                                
  5  * Author: J.E.J.Bottomley@HansenPartnership.c    
  6  *                                                
  7  * linux/arch/i386/kernel/voyager_thread.c        
  8  *                                                
  9  * This module provides the machine status mon    
 10  * voyager architecture.  This allows us to mo    
 11  * environment (temp, voltage, fan function) a    
 12  * internal UPS.  If a fault is detected, this    
 13  * action (usually just informing init)           
 14  * */                                             
 15                                                   
 16 #include <linux/module.h>                         
 17 #include <linux/config.h>                         
 18 #include <linux/mm.h>                             
 19 #include <linux/kernel_stat.h>                    
 20 #include <linux/delay.h>                          
 21 #include <linux/mc146818rtc.h>                    
 22 #include <linux/smp_lock.h>                       
 23 #include <linux/init.h>                           
 24 #include <linux/bootmem.h>                        
 25 #include <linux/kmod.h>                           
 26 #include <linux/completion.h>                     
 27 #include <linux/sched.h>                          
 28 #include <asm/desc.h>                             
 29 #include <asm/voyager.h>                          
 30 #include <asm/vic.h>                              
 31 #include <asm/mtrr.h>                             
 32 #include <asm/msr.h>                              
 33                                                   
 34 #include <linux/irq.h>                            
 35                                                   
 36 #define THREAD_NAME "kvoyagerd"                   
 37                                                   
 38 /* external variables */                          
 39 int kvoyagerd_running = 0;                        
 40 DECLARE_MUTEX_LOCKED(kvoyagerd_sem);              
 41                                                   
 42 static int thread(void *);                        
 43                                                   
 44 static __u8 set_timeout = 0;                      
 45                                                   
 46 /* Start the machine monitor thread.  Return 1    
 47 static int __init                                 
 48 voyager_thread_start(void)                        
 49 {                                                 
 50         if(kernel_thread(thread, NULL, CLONE_K    
 51                 /* This is serious, but not fa    
 52                 printk(KERN_ERR "Voyager: Fail    
 53                 return 1;                         
 54         }                                         
 55         return 0;                                 
 56 }                                                 
 57                                                   
 58 static int                                        
 59 execute(const char *string)                       
 60 {                                                 
 61         int ret;                                  
 62                                                   
 63         char *envp[] = {                          
 64                 "HOME=/",                         
 65                 "TERM=linux",                     
 66                 "PATH=/sbin:/usr/sbin:/bin:/us    
 67                 NULL,                             
 68         };                                        
 69         char *argv[] = {                          
 70                 "/bin/bash",                      
 71                 "-c",                             
 72                 (char *)string,                   
 73                 NULL,                             
 74         };                                        
 75                                                   
 76         if ((ret = call_usermodehelper(argv[0]    
 77                 printk(KERN_ERR "Voyager faile    
 78                        string, ret);              
 79         }                                         
 80         return ret;                               
 81 }                                                 
 82                                                   
 83 static void                                       
 84 check_from_kernel(void)                           
 85 {                                                 
 86         if(voyager_status.switch_off) {           
 87                                                   
 88                 /* FIXME: This should be confi    
 89                 execute("umask 600; echo 0 > /    
 90         } else if(voyager_status.power_fail) {    
 91                 VDEBUG(("Voyager daemon detect    
 92                                                   
 93                 /* FIXME: This should be confi    
 94                 execute("umask 600; echo F > /    
 95                 set_timeout = 1;                  
 96         }                                         
 97 }                                                 
 98                                                   
 99 static void                                       
100 check_continuing_condition(void)                  
101 {                                                 
102         if(voyager_status.power_fail) {           
103                 __u8 data;                        
104                 voyager_cat_psi(VOYAGER_PSI_SU    
105                                 VOYAGER_PSI_AC    
106                 if((data & 0x1f) == 0) {          
107                         /* all power restored     
108                         printk(KERN_NOTICE "VO    
109                         /* FIXME: should be us    
110                         execute("umask 600; ec    
111                         set_timeout = 0;          
112                 }                                 
113         }                                         
114 }                                                 
115                                                   
116 static void                                       
117 wakeup(unsigned long unused)                      
118 {                                                 
119         up(&kvoyagerd_sem);                       
120 }                                                 
121                                                   
122 static int                                        
123 thread(void *unused)                              
124 {                                                 
125         struct timer_list wakeup_timer;           
126                                                   
127         kvoyagerd_running = 1;                    
128                                                   
129         reparent_to_init();                       
130         daemonize(THREAD_NAME);                   
131                                                   
132         set_timeout = 0;                          
133                                                   
134         init_timer(&wakeup_timer);                
135                                                   
136         sigfillset(&current->blocked);            
137         current->signal->tty = NULL;              
138                                                   
139         printk(KERN_NOTICE "Voyager starting m    
140                                                   
141         for(;;) {                                 
142                 down_interruptible(&kvoyagerd_    
143                 VDEBUG(("Voyager Daemon awoken    
144                 if(voyager_status.request_from    
145                         /* probably awoken fro    
146                         check_continuing_condi    
147                 } else {                          
148                         check_from_kernel();      
149                         voyager_status.request    
150                 }                                 
151                 if(set_timeout) {                 
152                         del_timer(&wakeup_time    
153                         wakeup_timer.expires =    
154                         wakeup_timer.function     
155                         add_timer(&wakeup_time    
156                 }                                 
157         }                                         
158 }                                                 
159                                                   
160 static void __exit                                
161 voyager_thread_stop(void)                         
162 {                                                 
163         /* FIXME: do nothing at the moment */     
164 }                                                 
165                                                   
166 module_init(voyager_thread_start);                
167 //module_exit(voyager_thread_stop);               
168                                                   
  This page was automatically generated by the LXR engine.