source: mainline/kernel/arch/mips32/src/mach/msim/msim.c@ 260f678

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 260f678 was 260f678, checked in by Jakub Jermar <jakub@…>, 12 years ago

Factor out stdin/stdout initialization into machine ops.

  • Property mode set to 100644
File size: 3.6 KB
Line 
1/*
2 * Copyright (c) 2013 Jakub Jermar
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
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
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup mips32
30 * @{
31 */
32/** @file
33 * @brief msim platform driver.
34 */
35
36#include <arch/mach/msim/msim.h>
37#include <console/console.h>
38#include <sysinfo/sysinfo.h>
39#include <arch/drivers/msim.h>
40#include <genarch/drivers/dsrln/dsrlnin.h>
41#include <genarch/drivers/dsrln/dsrlnout.h>
42#include <genarch/srln/srln.h>
43
44static void msim_init(void);
45static void msim_cpu_halt(void);
46static void msim_get_memory_extents(uintptr_t *, size_t *);
47static void msim_frame_init(void);
48static void msim_output_init(void);
49static void msim_input_init(void);
50static const char *msim_get_platform_name(void);
51
52struct mips32_machine_ops msim_machine_ops = {
53 .machine_init = msim_init,
54 .machine_cpu_halt = msim_cpu_halt,
55 .machine_get_memory_extents = msim_get_memory_extents,
56 .machine_frame_init = msim_frame_init,
57 .machine_output_init = msim_output_init,
58 .machine_input_init = msim_input_init,
59 .machine_get_platform_name = msim_get_platform_name
60};
61
62void msim_init(void)
63{
64}
65
66void msim_cpu_halt(void)
67{
68}
69
70void msim_get_memory_extents(uintptr_t *start, size_t *size)
71{
72}
73
74void msim_frame_init(void)
75{
76}
77
78void msim_output_init(void)
79{
80#ifdef CONFIG_MSIM_PRN
81 outdev_t *dsrlndev = dsrlnout_init((ioport8_t *) MSIM_KBD_ADDRESS);
82 if (dsrlndev)
83 stdout_wire(dsrlndev);
84#endif
85}
86
87void msim_input_init(void)
88{
89#ifdef CONFIG_MSIM_KBD
90 /*
91 * Initialize the msim keyboard port. Then initialize the serial line
92 * module and connect it to the msim keyboard. Enable keyboard
93 * interrupts.
94 */
95 dsrlnin_instance_t *dsrlnin_instance
96 = dsrlnin_init((dsrlnin_t *) MSIM_KBD_ADDRESS, MSIM_KBD_IRQ);
97 if (dsrlnin_instance) {
98 srln_instance_t *srln_instance = srln_init();
99 if (srln_instance) {
100 indev_t *sink = stdin_wire();
101 indev_t *srln = srln_wire(srln_instance, sink);
102 dsrlnin_wire(dsrlnin_instance, srln);
103 cp0_unmask_int(MSIM_KBD_IRQ);
104 }
105 }
106
107 /*
108 * This is the necessary evil until the userspace driver is entirely
109 * self-sufficient.
110 */
111 sysinfo_set_item_val("kbd", NULL, true);
112 sysinfo_set_item_val("kbd.inr", NULL, MSIM_KBD_IRQ);
113 sysinfo_set_item_val("kbd.address.physical", NULL,
114 PA2KA(MSIM_KBD_ADDRESS));
115#endif
116}
117
118const char *msim_get_platform_name(void)
119{
120 return "msim";
121}
122
123/** @}
124 */
Note: See TracBrowser for help on using the repository browser.