Subversion Repositories HelenOS

Rev

Rev 3022 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3022 Rev 4055
Line 24... Line 24...
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
27
 */
28
 
28
 
29
/** @addtogroup mips32 
29
/** @addtogroup mips32
30
 * @{
30
 * @{
31
 */
31
 */
32
/** @file
32
/** @file
33
 */
33
 */
34
 
34
 
35
#include <interrupt.h>
35
#include <interrupt.h>
36
#include <ipc/irq.h>
-
 
37
#include <console/chardev.h>
36
#include <console/chardev.h>
38
#include <arch/drivers/msim.h>
37
#include <arch/drivers/msim.h>
39
#include <arch/cp0.h>
38
#include <arch/cp0.h>
40
#include <console/console.h>
39
#include <console/console.h>
41
#include <sysinfo/sysinfo.h>
40
#include <sysinfo/sysinfo.h>
42
 
-
 
43
/** Address of devices. */
41
#include <ddi/ddi.h>
44
#define MSIM_VIDEORAM       0xB0000000
-
 
45
#define MSIM_KBD_ADDRESS    0xB0000000
-
 
46
#define MSIM_KBD_IRQ        2
-
 
47
 
42
 
48
static chardev_t console;
43
static chardev_t console;
49
static irq_t msim_irq;
44
static irq_t msim_irq;
50
 
45
 
51
static void msim_write(chardev_t *dev, const char ch);
46
static void msim_write(chardev_t *dev, const char ch, bool silent);
52
static void msim_enable(chardev_t *dev);
47
static void msim_enable(chardev_t *dev);
53
static void msim_disable(chardev_t *dev);
48
static void msim_disable(chardev_t *dev);
54
static char msim_do_read(chardev_t *dev);
49
static char msim_do_read(chardev_t *dev);
55
 
50
 
56
static chardev_operations_t msim_ops = {
51
static chardev_operations_t msim_ops = {
Line 59... Line 54...
59
    .write = msim_write,
54
    .write = msim_write,
60
    .read = msim_do_read,
55
    .read = msim_do_read,
61
};
56
};
62
 
57
 
63
/** Putchar that works with MSIM & gxemul */
58
/** Putchar that works with MSIM & gxemul */
64
void msim_write(chardev_t *dev, const char ch)
59
void msim_write(chardev_t *dev, const char ch, bool silent)
65
{
60
{
-
 
61
    if (!silent)
66
    *((char *) MSIM_VIDEORAM) = ch;
62
        *((char *) MSIM_VIDEORAM) = ch;
67
}
63
}
68
 
64
 
69
/* Called from getc(). */
65
/* Called from getc(). */
70
void msim_enable(chardev_t *dev)
66
void msim_enable(chardev_t *dev)
71
{
67
{
Line 76... Line 72...
76
void msim_disable(chardev_t *dev)
72
void msim_disable(chardev_t *dev)
77
{
73
{
78
    cp0_mask_int(MSIM_KBD_IRQ);
74
    cp0_mask_int(MSIM_KBD_IRQ);
79
}
75
}
80
 
76
 
81
#include <print.h>
-
 
82
/** Read character using polling, assume interrupts disabled */
77
/** Read character using polling, assume interrupts disabled */
83
static char msim_do_read(chardev_t *dev)
78
static char msim_do_read(chardev_t *dev)
84
{
79
{
85
    char ch;
80
    char ch;
86
 
81
   
87
    while (1) {
82
    while (1) {
88
        ch = *((volatile char *) MSIM_KBD_ADDRESS);
83
        ch = *((volatile char *) MSIM_KBD_ADDRESS);
89
        if (ch) {
84
        if (ch) {
90
            if (ch == '\r')
85
            if (ch == '\r')
91
                return '\n';
86
                return '\n';
Line 95... Line 90...
95
        }
90
        }
96
    }
91
    }
97
}
92
}
98
 
93
 
99
/** Process keyboard interrupt. */
94
/** Process keyboard interrupt. */
100
static void msim_irq_handler(irq_t *irq, void *arg, ...)
95
static void msim_irq_handler(irq_t *irq)
101
{
96
{
102
    if ((irq->notif_cfg.notify) && (irq->notif_cfg.answerbox))
-
 
103
        ipc_irq_send_notif(irq);
-
 
104
    else {
-
 
105
        char ch = 0;
97
    char ch = 0;
106
       
98
       
107
            ch = *((char *) MSIM_KBD_ADDRESS);
99
    ch = *((char *) MSIM_KBD_ADDRESS);
108
            if (ch =='\r')
100
    if (ch =='\r')
109
                ch = '\n';
101
        ch = '\n';
110
            if (ch == 0x7f)
102
    if (ch == 0x7f)
111
                ch = '\b';
103
        ch = '\b';
112
            chardev_push_character(&console, ch);
104
    chardev_push_character(&console, ch);
113
    }
-
 
114
}
105
}
115
 
106
 
116
static irq_ownership_t msim_claim(void)
107
static irq_ownership_t msim_claim(irq_t *irq)
117
{
108
{
118
    return IRQ_ACCEPT;
109
    return IRQ_ACCEPT;
119
}
110
}
120
 
111
 
121
void msim_kbd_grab(void)
112
void msim_kbd_grab(void)
Line 156... Line 147...
156
   
147
   
157
    sysinfo_set_item_val("kbd", NULL, true);
148
    sysinfo_set_item_val("kbd", NULL, true);
158
    sysinfo_set_item_val("kbd.devno", NULL, devno);
149
    sysinfo_set_item_val("kbd.devno", NULL, devno);
159
    sysinfo_set_item_val("kbd.inr", NULL, MSIM_KBD_IRQ);
150
    sysinfo_set_item_val("kbd.inr", NULL, MSIM_KBD_IRQ);
160
    sysinfo_set_item_val("kbd.address.virtual", NULL, MSIM_KBD_ADDRESS);
151
    sysinfo_set_item_val("kbd.address.virtual", NULL, MSIM_KBD_ADDRESS);
-
 
152
   
-
 
153
    sysinfo_set_item_val("fb", NULL, true);
-
 
154
    sysinfo_set_item_val("fb.kind", NULL, 3);
-
 
155
    sysinfo_set_item_val("fb.address.physical", NULL, KA2PA(MSIM_VIDEORAM));
161
}
156
}
162
 
157
 
163
/** @}
158
/** @}
164
 */
159
 */