|
|
1.1 root 1: /*
2: * Creation Date: <2004/08/28 18:38:22 greg>
3: * Time-stamp: <2004/08/28 18:38:22 greg>
4: *
5: * <methods.c>
6: *
7: * Misc device node methods
8: *
9: * Copyright (C) 2004 Greg Watson
10: *
11: * Based on MOL specific code which is
12: *
13: * Copyright (C) 2003, 2004 Samuel Rydh ([email protected])
14: *
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
18: *
19: */
20:
21: #include "config.h"
22: #include "libopenbios/bindings.h"
23: #include "libc/string.h"
24: // #include "libopenbios/ofmem.h"
25:
26: /************************************************************************/
27: /* stdout */
28: /************************************************************************/
29:
30: DECLARE_NODE( video_stdout, INSTALL_OPEN, 0, "Tdisplay" );
31:
32: /* ( addr len -- actual ) */
33: static void
34: stdout_write( void )
35: {
36: int len = POP();
37: char *addr = (char*)POP();
38:
39: printk( "%s", s );
40: //vfd_draw_str( s );
41: console_draw_fstr(addr, len);
42:
43: PUSH( len );
44: }
45:
46: NODE_METHODS( video_stdout ) = {
47: { "write", stdout_write },
48: };
49:
50:
51: /************************************************************************/
52: /* tty */
53: /************************************************************************/
54:
55: DECLARE_NODE( tty, INSTALL_OPEN, 0, "/packages/terminal-emulator" );
56:
57: /* ( addr len -- actual ) */
58: static void
59: tty_read( void )
60: {
61: int ch, len = POP();
62: char *p = (char*)POP();
63: int ret=0;
64:
65: if( len > 0 ) {
66: ret = 1;
67: ch = getchar();
68: if( ch >= 0 ) {
69: *p = ch;
70: } else {
71: ret = 0;
72: }
73: }
74: PUSH( ret );
75: }
76:
77: /* ( addr len -- actual ) */
78: static void
79: tty_write( void )
80: {
81: int i, len = POP();
82: char *p = (char*)POP();
83: for( i=0; i<len; i++ )
84: putchar( *p++ );
85: RET( len );
86: }
87:
88: NODE_METHODS( tty ) = {
89: { "read", tty_read },
90: { "write", tty_write },
91: };
92:
93: /************************************************************************/
94: /* init */
95: /************************************************************************/
96:
97: void
98: node_methods_init( void )
99: {
100: REGISTER_NODE( video_stdout );
101: REGISTER_NODE( tty );
102: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.