Changeset 7cb53f62 in mainline for arch/sparc64/src/console.c
- Timestamp:
- 2006-02-26T12:02:25Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4767721
- Parents:
- 7a255e69
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
arch/sparc64/src/console.c
r7a255e69 r7cb53f62 28 28 29 29 #include <arch/console.h> 30 #include <genarch/ofw/ofw.h>31 #include <console/chardev.h>32 #include <console/console.h>33 #include <arch/asm.h>34 #include <arch/register.h>35 30 #include <arch/types.h> 36 31 #include <typedefs.h> 37 #include < proc/thread.h>38 #include < synch/mutex.h>32 #include <genarch/fb/fb.h> 33 #include <arch/drivers/fb.h> 39 34 40 static void ofw_sparc64_putchar(chardev_t *d, const char ch); 41 static char ofw_sparc64_getchar(chardev_t *d); 42 static void ofw_sparc64_suspend(chardev_t *d); 43 static void ofw_sparc64_resume(chardev_t *d); 44 45 mutex_t canwork; 46 47 static chardev_t ofw_sparc64_console; 48 static chardev_operations_t ofw_sparc64_console_ops = { 49 .write = ofw_sparc64_putchar, 50 .read = ofw_sparc64_getchar, 51 .resume = ofw_sparc64_resume, 52 .suspend = ofw_sparc64_suspend 53 }; 54 55 void ofw_sparc64_console_init(void) 35 void fb_sparc64_console_init(void) 56 36 { 57 chardev_initialize("ofw_sparc64_console", &ofw_sparc64_console, &ofw_sparc64_console_ops); 58 stdin = &ofw_sparc64_console; 59 stdout = &ofw_sparc64_console; 60 mutex_initialize(&canwork); 37 fb_init(FB_VIRT_ADDRESS, FB_X_RES, FB_Y_RES, FB_COLOR_DEPTH/8); 61 38 } 62 63 /** Write one character.64 *65 * @param d Character device (ignored).66 * @param ch Character to be written.67 */68 void ofw_sparc64_putchar(chardev_t *d, const char ch)69 {70 pstate_reg_t pstate;71 72 /*73 * 32-bit OpenFirmware depends on PSTATE.AM bit set.74 */75 pstate.value = pstate_read();76 pstate.am = true;77 pstate_write(pstate.value);78 79 if (ch == '\n')80 ofw_putchar('\r');81 ofw_putchar(ch);82 83 pstate.am = false;84 pstate_write(pstate.value);85 }86 87 /** Read one character.88 *89 * The call is non-blocking.90 *91 * @param d Character device (ignored).92 * @return Character read or zero if no character was read.93 */94 char ofw_sparc64_getchar(chardev_t *d)95 {96 char ch;97 pstate_reg_t pstate;98 99 /*100 * 32-bit OpenFirmware depends on PSTATE.AM bit set.101 */102 pstate.value = pstate_read();103 pstate.am = true;104 pstate_write(pstate.value);105 106 ch = ofw_getchar();107 108 pstate.am = false;109 pstate_write(pstate.value);110 111 return ch;112 }113 114 void ofw_sparc64_suspend(chardev_t *d)115 {116 mutex_lock(&canwork);117 }118 119 void ofw_sparc64_resume(chardev_t *d)120 {121 mutex_unlock(&canwork);122 }123 124 /** Kernel thread for pushing characters read from OFW to input buffer.125 *126 * @param arg Ignored.127 */128 void kofwinput(void *arg)129 {130 131 while (1) {132 char ch = 0;133 134 mutex_lock(&canwork);135 mutex_unlock(&canwork);136 137 ch = ofw_sparc64_getchar(NULL);138 if (ch) {139 if (ch == '\r')140 ch = '\n';141 chardev_push_character(&ofw_sparc64_console, ch);142 }143 thread_usleep(25000);144 }145 }
Note:
See TracChangeset
for help on using the changeset viewer.