]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4util/lib/src/ARCH-amd64/spin.c
Inital import
[l4.git] / l4 / pkg / l4util / lib / src / ARCH-amd64 / spin.c
1 /*
2  * (c) 2008-2009 Technische Universität Dresden
3  * This file is part of TUD:OS and distributed under the terms of the
4  * GNU Lesser General Public License 2.1.
5  * Please see the COPYING-LGPL-2.1 file for details.
6  */
7 #include <l4/util/spin.h>
8
9 static void spin_gen(void*addr,int x,int y){
10   unsigned char c,*p;
11     
12   p=addr+(x+80*y)*2;
13   c=*p;
14   c=(c=='|')?'/':(c=='/')?'-':(c=='-')?'\\':(c=='\\')?'|':'-';
15   *p=c;
16 }
17
18 /****************************************************************************
19 *                                                                           *
20 *  l4_spin()     - spinning wheel at the hercules screen, position is from  *
21 *                  upper left. Each call turns the wheel.                   *
22 *  l4_spin_vga() - the same for vga.                                        *
23 *                                                                           *
24 ****************************************************************************/
25 void l4_spin(int x,int y){
26   spin_gen((void*)0xb0000, x, y);
27 }
28 void l4_spin_vga(int x, int y){
29   spin_gen((void*)0xb8000, x, y);
30 }
31
32 static void spin_n_text_gen(void*addr, int x,int y, int len, const char*s){
33   unsigned char c,*p;
34   int i;
35   
36   p=addr+(x+len+80*y)*2;
37   c=*p;
38   c=(c=='|')?'/':(c=='/')?'-':(c=='-')?'\\':(c=='\\')?'|':'.';
39   if(c=='.'){
40     if(s){
41       p=addr+(x+80*y)*2;
42       for(i=0;i<len;i++){
43         *p++ = *s++;p++;
44       }
45     }
46     c = '-';
47   }
48   *p=c;
49 }
50
51 /****************************************************************************
52 *                                                                           *
53 *  l4_spin_n_text()     - like spin(), but prints a text before the wheel.  *
54 *                         You must specify the length of the text (without  *
55 *                         the 0 at the end). The text is printed if no      *
56 *                         wheel-element is found at the wheel position.     *
57 *                         See macro l4_spin_text() for constant text.       *
58 *  l4_spin_n_text_vga() - same for vga.                                     *
59 *                                                                           *
60 ****************************************************************************/
61 void l4_spin_n_text(int x,int y, int len, const char*s){
62   spin_n_text_gen((void*)0xb0000, x, y, len, s);
63 }
64 void l4_spin_n_text_vga(int x,int y, int len, const char*s){
65   spin_n_text_gen((void*)0xb8000, x, y, len, s);
66 }