spinconsole.c revision 199857
133965Sjdp/*- 278828Sobrien * spinconsole.c 3218822Sdim * 433965Sjdp * Author: Maksym Sobolyev <sobomax@sippysoft.com> 533965Sjdp * Copyright (c) 2009 Sippy Software, Inc. 633965Sjdp * All rights reserved. 733965Sjdp * 833965Sjdp * Subject to the following obligations and disclaimer of warranty, use and 933965Sjdp * redistribution of this software, in source or object code forms, with or 1033965Sjdp * without modifications are expressly permitted by Whistle Communications; 1133965Sjdp * provided, however, that: 1233965Sjdp * 1. Any and all reproductions of the source or object code must include the 1333965Sjdp * copyright notice above and the following disclaimer of warranties; and 1433965Sjdp * 2. No rights are granted, in any manner or form, to use Whistle 1533965Sjdp * Communications, Inc. trademarks, including the mark "WHISTLE 1633965Sjdp * COMMUNICATIONS" on advertising, endorsements, or otherwise except as 1733965Sjdp * such appears in the above copyright notice or in the software. 1833965Sjdp * 1933965Sjdp * THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND 20218822Sdim * TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO 21218822Sdim * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE, 2233965Sjdp * INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF 2333965Sjdp * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. 2433965Sjdp * WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY 2533965Sjdp * REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS 2660484Sobrien * SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE. 2733965Sjdp * IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES 2833965Sjdp * RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING 2933965Sjdp * WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 3033965Sjdp * PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR 3133965Sjdp * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY 3233965Sjdp * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 3333965Sjdp * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 3433965Sjdp * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY 35130561Sobrien * OF SUCH DAMAGE. 3633965Sjdp */ 3733965Sjdp 3833965Sjdp#include <sys/cdefs.h> 3933965Sjdp__FBSDID("$FreeBSD: head/sys/boot/i386/libi386/spinconsole.c 199857 2009-11-27 04:00:52Z sobomax $"); 4033965Sjdp 4133965Sjdp#include <stand.h> 4233965Sjdp#include <bootstrap.h> 4333965Sjdp 4433965Sjdpextern void get_pos(int *x, int *y); 4533965Sjdpextern void curs_move(int *_x, int *_y, int x, int y); 4633965Sjdpextern void vidc_biosputchar(int c); 4733965Sjdp 4833965Sjdpstatic void spinc_probe(struct console *cp); 4933965Sjdpstatic int spinc_init(int arg); 5033965Sjdpstatic void spinc_putchar(int c); 5133965Sjdpstatic int spinc_getchar(void); 5233965Sjdpstatic int spinc_ischar(void); 5333965Sjdp 5433965Sjdpstruct console spinconsole = { 5577298Sobrien "spinconsole", 5633965Sjdp "spin port", 5733965Sjdp 0, 5833965Sjdp spinc_probe, 59218822Sdim spinc_init, 60218822Sdim spinc_putchar, 61218822Sdim spinc_getchar, 62218822Sdim spinc_ischar 6377298Sobrien}; 6477298Sobrien 6577298Sobrienstatic void 6677298Sobrienspinc_probe(struct console *cp) 6777298Sobrien{ 6877298Sobrien cp->c_flags |= (C_PRESENTIN | C_PRESENTOUT); 6977298Sobrien} 7033965Sjdp 7133965Sjdpstatic int 7277298Sobrienspinc_init(int arg) 7377298Sobrien{ 7477298Sobrien return(0); 7577298Sobrien} 7633965Sjdp 7733965Sjdpstatic void 7833965Sjdpspinc_putchar(int c) 7933965Sjdp{ 8033965Sjdp static int curx, cury; 8133965Sjdp static unsigned tw_chars = 0x5C2D2F7C; /* "\-/|" */ 8260484Sobrien static time_t lasttime; 8360484Sobrien time_t now; 8460484Sobrien 8533965Sjdp now = time(NULL); 8633965Sjdp if (now < (lasttime + 1)) 8733965Sjdp return; 8833965Sjdp lasttime = now; 8933965Sjdp get_pos(&curx, &cury); 9033965Sjdp if (curx > 0) 9133965Sjdp curs_move(&curx, &cury, curx - 1, cury); 9277298Sobrien vidc_biosputchar((char)tw_chars); 9333965Sjdp tw_chars = (tw_chars >> 8) | ((tw_chars & (unsigned long)0xFF) << 24); 9433965Sjdp} 9533965Sjdp 9633965Sjdpstatic int 9777298Sobrienspinc_getchar(void) 9833965Sjdp{ 9933965Sjdp return(-1); 10033965Sjdp} 10133965Sjdp 10277298Sobrienstatic int 10377298Sobrienspinc_ischar(void) 10433965Sjdp{ 10533965Sjdp return(0); 10633965Sjdp} 10733965Sjdp