-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathstdio.c
More file actions
68 lines (64 loc) · 1.61 KB
/
stdio.c
File metadata and controls
68 lines (64 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
* Copyright (C) 2012 Michael Brown <mbrown@fensystems.co.uk>.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
/**
* @file
*
* Standard Input/Output
*
*/
#include <stdio.h>
#include <string.h>
#include "bootapp.h"
#include "wimboot.h"
/**
* Print character to console
*
* @v character Character to print
*/
int putchar (int character)
{
struct bootapp_callback_params params;
/* Convert LF to CR,LF */
if (character == '\n')
{
putchar ('\r');
}
memset (¶ms, 0, sizeof (params));
params.vector.interrupt = 0x10;
params.eax = (0x0e00 | character);
params.ebx = 0x0007;
call_interrupt (¶ms);
return 0;
}
/**
* Get character from console
*
* @ret character Character
*/
int getchar (void)
{
struct bootapp_callback_params params;
int character;
/* Get character */
memset (¶ms, 0, sizeof (params));
params.vector.interrupt = 0x16;
call_interrupt (¶ms);
character = params.al;
return character;
}