spinconsole.c revision 199856
1119482Sobrien/*- 2199855Ssobomax * spinconsole.c 366133Sarchie * 4199855Ssobomax * Author: Maksym Sobolyev <sobomax@sippysoft.com> 5199855Ssobomax * Copyright (c) 2009 Sippy Software, Inc. 666133Sarchie * All rights reserved. 766133Sarchie * 866133Sarchie * Subject to the following obligations and disclaimer of warranty, use and 966133Sarchie * redistribution of this software, in source or object code forms, with or 1066133Sarchie * without modifications are expressly permitted by Whistle Communications; 1166133Sarchie * provided, however, that: 1266133Sarchie * 1. Any and all reproductions of the source or object code must include the 1366133Sarchie * copyright notice above and the following disclaimer of warranties; and 1466133Sarchie * 2. No rights are granted, in any manner or form, to use Whistle 1566133Sarchie * Communications, Inc. trademarks, including the mark "WHISTLE 1666133Sarchie * COMMUNICATIONS" on advertising, endorsements, or otherwise except as 1766133Sarchie * such appears in the above copyright notice or in the software. 1866133Sarchie * 1966133Sarchie * THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND 2066133Sarchie * TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO 2166133Sarchie * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE, 2266133Sarchie * INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF 2366133Sarchie * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. 2466133Sarchie * WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY 2566133Sarchie * REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS 2666133Sarchie * SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE. 2766133Sarchie * IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES 2866133Sarchie * RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING 2966133Sarchie * WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 3066133Sarchie * PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR 3166133Sarchie * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY 3266133Sarchie * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 3366133Sarchie * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 3466133Sarchie * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY 3566133Sarchie * OF SUCH DAMAGE. 3666133Sarchie */ 3766133Sarchie 38119482Sobrien#include <sys/cdefs.h> 39119482Sobrien__FBSDID("$FreeBSD: head/sys/boot/i386/libi386/spinconsole.c 199856 2009-11-27 03:58:21Z sobomax $"); 40119482Sobrien 4166133Sarchie#include <stand.h> 4266133Sarchie#include <bootstrap.h> 4366133Sarchie 44199855Ssobomaxextern void get_pos(int *x, int *y); 45199855Ssobomaxextern void curs_move(int *_x, int *_y, int x, int y); 46199855Ssobomaxextern void vidc_biosputchar(int c); 4766133Sarchie 48199855Ssobomaxstatic void spinc_probe(struct console *cp); 49199855Ssobomaxstatic int spinc_init(int arg); 50199855Ssobomaxstatic void spinc_putchar(int c); 51199855Ssobomaxstatic int spinc_getchar(void); 52199855Ssobomaxstatic int spinc_ischar(void); 53199855Ssobomax 54199855Ssobomaxstruct console spinconsole = { 55199855Ssobomax "spinconsole", 56199855Ssobomax "spin port", 5766133Sarchie 0, 58199855Ssobomax spinc_probe, 59199855Ssobomax spinc_init, 60199855Ssobomax spinc_putchar, 61199855Ssobomax spinc_getchar, 62199855Ssobomax spinc_ischar 6366133Sarchie}; 6466133Sarchie 6566133Sarchiestatic void 66199855Ssobomaxspinc_probe(struct console *cp) 6766133Sarchie{ 6866133Sarchie cp->c_flags |= (C_PRESENTIN | C_PRESENTOUT); 6966133Sarchie} 7066133Sarchie 7166133Sarchiestatic int 72199855Ssobomaxspinc_init(int arg) 7366133Sarchie{ 7466133Sarchie return(0); 7566133Sarchie} 7666133Sarchie 7766133Sarchiestatic void 78199855Ssobomaxspinc_putchar(int c) 7966133Sarchie{ 80199855Ssobomax static int curx, cury; 81199855Ssobomax static unsigned tw_chars = 0x5C2D2F7C; /* "\-/|" */ 82199855Ssobomax static time_t lasttime; 83199855Ssobomax time_t now; 84199855Ssobomax 85199856Ssobomax now = time(NULL); 86199856Ssobomax if (now < (lasttime + 1)) 87199856Ssobomax return; 88199856Ssobomax lasttime = now; 89199855Ssobomax get_pos(&curx, &cury); 90199855Ssobomax if (curx > 0) 91199855Ssobomax curs_move(&curx, &cury, curx - 1, cury); 92199855Ssobomax vidc_biosputchar((char)tw_chars); 93199855Ssobomax tw_chars = (tw_chars >> 8) | ((tw_chars & (unsigned long)0xFF) << 24); 9466133Sarchie} 9566133Sarchie 9666133Sarchiestatic int 97199855Ssobomaxspinc_getchar(void) 9866133Sarchie{ 9966133Sarchie return(-1); 10066133Sarchie} 10166133Sarchie 10266133Sarchiestatic int 103199855Ssobomaxspinc_ischar(void) 10466133Sarchie{ 10566133Sarchie return(0); 10666133Sarchie} 107