~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/x86/boot/tty.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /arch/x86/boot/tty.c (Architecture sparc) and /arch/mips/boot/tty.c (Architecture mips)


  1 // SPDX-License-Identifier: GPL-2.0-only            1 
  2 /* -*- linux-c -*- ---------------------------    
  3  *                                                
  4  *   Copyright (C) 1991, 1992 Linus Torvalds      
  5  *   Copyright 2007 rPath, Inc. - All Rights R    
  6  *   Copyright 2009 Intel Corporation; author     
  7  *                                                
  8  * -------------------------------------------    
  9                                                   
 10 /*                                                
 11  * Very simple screen and serial I/O              
 12  */                                               
 13                                                   
 14 #include "boot.h"                                 
 15                                                   
 16 int early_serial_base;                            
 17                                                   
 18 #define XMTRDY          0x20                      
 19                                                   
 20 #define TXR             0       /*  Transmit r    
 21 #define LSR             5       /*  Line Statu    
 22                                                   
 23 /*                                                
 24  * These functions are in .inittext so they ca    
 25  * error during initialization.                   
 26  */                                               
 27                                                   
 28 static void __section(".inittext") serial_putc    
 29 {                                                 
 30         unsigned timeout = 0xffff;                
 31                                                   
 32         while ((inb(early_serial_base + LSR) &    
 33                 cpu_relax();                      
 34                                                   
 35         outb(ch, early_serial_base + TXR);        
 36 }                                                 
 37                                                   
 38 static void __section(".inittext") bios_putcha    
 39 {                                                 
 40         struct biosregs ireg;                     
 41                                                   
 42         initregs(&ireg);                          
 43         ireg.bx = 0x0007;                         
 44         ireg.cx = 0x0001;                         
 45         ireg.ah = 0x0e;                           
 46         ireg.al = ch;                             
 47         intcall(0x10, &ireg, NULL);               
 48 }                                                 
 49                                                   
 50 void __section(".inittext") putchar(int ch)       
 51 {                                                 
 52         if (ch == '\n')                           
 53                 putchar('\r');  /* \n -> \r\n     
 54                                                   
 55         bios_putchar(ch);                         
 56                                                   
 57         if (early_serial_base != 0)               
 58                 serial_putchar(ch);               
 59 }                                                 
 60                                                   
 61 void __section(".inittext") puts(const char *s    
 62 {                                                 
 63         while (*str)                              
 64                 putchar(*str++);                  
 65 }                                                 
 66                                                   
 67 /*                                                
 68  * Read the CMOS clock through the BIOS, and r    
 69  * seconds in BCD.                                
 70  */                                               
 71                                                   
 72 static u8 gettime(void)                           
 73 {                                                 
 74         struct biosregs ireg, oreg;               
 75                                                   
 76         initregs(&ireg);                          
 77         ireg.ah = 0x02;                           
 78         intcall(0x1a, &ireg, &oreg);              
 79                                                   
 80         return oreg.dh;                           
 81 }                                                 
 82                                                   
 83 /*                                                
 84  * Read from the keyboard                         
 85  */                                               
 86 int getchar(void)                                 
 87 {                                                 
 88         struct biosregs ireg, oreg;               
 89                                                   
 90         initregs(&ireg);                          
 91         /* ireg.ah = 0x00; */                     
 92         intcall(0x16, &ireg, &oreg);              
 93                                                   
 94         return oreg.al;                           
 95 }                                                 
 96                                                   
 97 static int kbd_pending(void)                      
 98 {                                                 
 99         struct biosregs ireg, oreg;               
100                                                   
101         initregs(&ireg);                          
102         ireg.ah = 0x01;                           
103         intcall(0x16, &ireg, &oreg);              
104                                                   
105         return !(oreg.eflags & X86_EFLAGS_ZF);    
106 }                                                 
107                                                   
108 void kbd_flush(void)                              
109 {                                                 
110         for (;;) {                                
111                 if (!kbd_pending())               
112                         break;                    
113                 getchar();                        
114         }                                         
115 }                                                 
116                                                   
117 int getchar_timeout(void)                         
118 {                                                 
119         int cnt = 30;                             
120         int t0, t1;                               
121                                                   
122         t0 = gettime();                           
123                                                   
124         while (cnt) {                             
125                 if (kbd_pending())                
126                         return getchar();         
127                                                   
128                 t1 = gettime();                   
129                 if (t0 != t1) {                   
130                         cnt--;                    
131                         t0 = t1;                  
132                 }                                 
133         }                                         
134                                                   
135         return 0;               /* Timeout! */    
136 }                                                 
137                                                   
138                                                   

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php