Switch SPARC32 page tables over to use OFMEM's ofmem_posix_memalign() rather than...
[openbios.git] / arch / x86 / xbox / methods.c
blob741d15c085c2b2edaab5b8a47fd65ab640119b44
1 /*
2 * Creation Date: <2004/08/28 18:38:22 greg>
3 * Time-stamp: <2004/08/28 18:38:22 greg>
5 * <methods.c>
7 * Misc device node methods
9 * Copyright (C) 2004 Greg Watson
11 * Based on MOL specific code which is
13 * Copyright (C) 2003, 2004 Samuel Rydh (samuel@ibrium.se)
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * version 2
21 #include "config.h"
22 #include "libopenbios/bindings.h"
23 #include "libc/string.h"
24 // #include "libopenbios/ofmem.h"
26 /************************************************************************/
27 /* stdout */
28 /************************************************************************/
30 DECLARE_NODE( video_stdout, INSTALL_OPEN, 0, "Tdisplay" );
32 /* ( addr len -- actual ) */
33 static void
34 stdout_write( void )
36 int len = POP();
37 char *addr = (char*)POP();
39 printk( "%s", s );
40 //vfd_draw_str( s );
41 console_draw_fstr(addr, len);
43 PUSH( len );
46 NODE_METHODS( video_stdout ) = {
47 { "write", stdout_write },
51 /************************************************************************/
52 /* tty */
53 /************************************************************************/
55 DECLARE_NODE( tty, INSTALL_OPEN, 0, "/packages/terminal-emulator" );
57 /* ( addr len -- actual ) */
58 static void
59 tty_read( void )
61 int ch, len = POP();
62 char *p = (char*)POP();
63 int ret=0;
65 if( len > 0 ) {
66 ret = 1;
67 ch = getchar();
68 if( ch >= 0 ) {
69 *p = ch;
70 } else {
71 ret = 0;
74 PUSH( ret );
77 /* ( addr len -- actual ) */
78 static void
79 tty_write( void )
81 int i, len = POP();
82 char *p = (char*)POP();
83 for( i=0; i<len; i++ )
84 putchar( *p++ );
85 RET( len );
88 NODE_METHODS( tty ) = {
89 { "read", tty_read },
90 { "write", tty_write },
93 /************************************************************************/
94 /* init */
95 /************************************************************************/
97 void
98 node_methods_init( void )
100 REGISTER_NODE( video_stdout );
101 REGISTER_NODE( tty );