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: stable/11/stand/i386/libi386/spinconsole.c 329114 2018-02-11 02:27:50Z kevans $"); 40119482Sobrien 4166133Sarchie#include <stand.h> 4266133Sarchie#include <bootstrap.h> 4366133Sarchie 44199855Ssobomaxstatic void spinc_probe(struct console *cp); 45199855Ssobomaxstatic int spinc_init(int arg); 46199855Ssobomaxstatic void spinc_putchar(int c); 47199855Ssobomaxstatic int spinc_getchar(void); 48199855Ssobomaxstatic int spinc_ischar(void); 49199855Ssobomax 50329114Skevansextern struct console *consoles[]; 51329114Skevans 52199855Ssobomaxstruct console spinconsole = { 53199855Ssobomax "spinconsole", 54199855Ssobomax "spin port", 5566133Sarchie 0, 56199855Ssobomax spinc_probe, 57199855Ssobomax spinc_init, 58199855Ssobomax spinc_putchar, 59199855Ssobomax spinc_getchar, 60199855Ssobomax spinc_ischar 6166133Sarchie}; 6266133Sarchie 63329114Skevansstatic struct console *parent = NULL; 64329114Skevans 6566133Sarchiestatic void 66199855Ssobomaxspinc_probe(struct console *cp) 6766133Sarchie{ 68329114Skevans 69329114Skevans if (parent == NULL) 70329114Skevans parent = consoles[0]; 71329114Skevans parent->c_probe(cp); 7266133Sarchie} 7366133Sarchie 7466133Sarchiestatic int 75199855Ssobomaxspinc_init(int arg) 7666133Sarchie{ 77329114Skevans 78329114Skevans return(parent->c_init(arg)); 7966133Sarchie} 8066133Sarchie 8166133Sarchiestatic void 82199855Ssobomaxspinc_putchar(int c) 8366133Sarchie{ 84199855Ssobomax static unsigned tw_chars = 0x5C2D2F7C; /* "\-/|" */ 85329114Skevans static time_t lasttime = 0; 86199855Ssobomax time_t now; 87199855Ssobomax 88329114Skevans now = time(0); 89199856Ssobomax if (now < (lasttime + 1)) 90199856Ssobomax return; 91276074Simp#ifdef TERM_EMU 92329114Skevans if (lasttime > 0) 93329114Skevans parent->c_out('\b'); 94276074Simp#endif 95329114Skevans lasttime = now; 96329114Skevans parent->c_out((char)tw_chars); 97199855Ssobomax tw_chars = (tw_chars >> 8) | ((tw_chars & (unsigned long)0xFF) << 24); 9866133Sarchie} 9966133Sarchie 10066133Sarchiestatic int 101199855Ssobomaxspinc_getchar(void) 10266133Sarchie{ 103329114Skevans 10466133Sarchie return(-1); 10566133Sarchie} 10666133Sarchie 10766133Sarchiestatic int 108199855Ssobomaxspinc_ischar(void) 10966133Sarchie{ 110329114Skevans 11166133Sarchie return(0); 11266133Sarchie} 113