[a522999] | 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>
|
---|
[260f678] | 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>
|
---|
[a522999] | 43 |
|
---|
| 44 | static void msim_init(void);
|
---|
| 45 | static void msim_cpu_halt(void);
|
---|
| 46 | static void msim_get_memory_extents(uintptr_t *, size_t *);
|
---|
| 47 | static void msim_frame_init(void);
|
---|
| 48 | static void msim_output_init(void);
|
---|
| 49 | static void msim_input_init(void);
|
---|
| 50 | static const char *msim_get_platform_name(void);
|
---|
| 51 |
|
---|
| 52 | struct 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 |
|
---|
| 62 | void msim_init(void)
|
---|
| 63 | {
|
---|
| 64 | }
|
---|
| 65 |
|
---|
| 66 | void msim_cpu_halt(void)
|
---|
| 67 | {
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 | void msim_get_memory_extents(uintptr_t *start, size_t *size)
|
---|
| 71 | {
|
---|
| 72 | }
|
---|
| 73 |
|
---|
| 74 | void msim_frame_init(void)
|
---|
| 75 | {
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | void msim_output_init(void)
|
---|
| 79 | {
|
---|
[260f678] | 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
|
---|
[a522999] | 85 | }
|
---|
| 86 |
|
---|
| 87 | void msim_input_init(void)
|
---|
| 88 | {
|
---|
[260f678] | 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
|
---|
[a522999] | 116 | }
|
---|
| 117 |
|
---|
| 118 | const char *msim_get_platform_name(void)
|
---|
| 119 | {
|
---|
| 120 | return "msim";
|
---|
| 121 | }
|
---|
| 122 |
|
---|
| 123 | /** @}
|
---|
| 124 | */
|
---|