Changeset 925a21e in mainline for uspace/srv/hid/fb/port/kchar.c
- Timestamp:
- 2011-09-24T14:20:29Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5bf76c1
- Parents:
- 867e2555 (diff), 1ab4aca (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/fb/port/kchar.c
r867e2555 r925a21e 28 28 */ 29 29 30 /** @defgroup msimfb MSIM text console31 * @brief HelenOS MSIM text console.32 * @ingroup fbs33 * @{34 */35 30 /** @file 36 31 */ 37 32 38 #include < async.h>39 #include < libc.h>33 #include <sys/types.h> 34 #include <errno.h> 40 35 #include <sysinfo.h> 36 #include <ddi.h> 41 37 #include <as.h> 42 #include <ddi.h> 43 #include <errno.h> 38 #include <align.h> 39 #include "../ctl/serial.h" 40 #include "kchar.h" 44 41 45 #include "serial_console.h" 46 #include "msim.h" 42 typedef struct { 43 uint8_t *addr; 44 } kchar_t; 47 45 48 #define WIDTH 80 49 #define HEIGHT 24 46 static kchar_t kchar; 50 47 51 static char *virt_addr; 52 53 static void msim_putc(const char c) 48 static void kchar_putchar(wchar_t ch) 54 49 { 55 *virt_addr = c; 50 if ((ch >= 0) && (ch < 128)) 51 *kchar.addr = ch; 52 else 53 *kchar.addr = '?'; 56 54 } 57 55 58 int msim_init(void)56 static void kchar_control_puts(const char *str) 59 57 { 60 sysarg_t phys_addr; 61 if (sysinfo_get_value("fb.address.physical", &phys_addr) != EOK) 62 return -1; 58 while (*str) 59 *kchar.addr = *(str++); 60 } 61 62 int kchar_init(void) 63 { 64 sysarg_t present; 65 int rc = sysinfo_get_value("fb", &present); 66 if (rc != EOK) 67 present = false; 63 68 64 virt_addr = (char *) as_get_mappable_page(1); 69 if (!present) 70 return ENOENT; 65 71 66 if (physmem_map((void *) phys_addr, virt_addr, 1, 67 AS_AREA_READ | AS_AREA_WRITE) != 0) 68 return -1; 72 sysarg_t kind; 73 rc = sysinfo_get_value("fb.kind", &kind); 74 if (rc != EOK) 75 kind = (sysarg_t) -1; 69 76 70 serial_console_init(msim_putc, WIDTH, HEIGHT); 77 if (kind != 3) 78 return EINVAL; 71 79 72 async_set_client_connection(serial_client_connection); 73 return 0; 80 sysarg_t paddr; 81 rc = sysinfo_get_value("fb.address.physical", &paddr); 82 if (rc != EOK) 83 return rc; 84 85 kchar.addr = as_get_mappable_page(1); 86 if (kchar.addr == NULL) 87 return ENOMEM; 88 89 rc = physmem_map((void *) paddr, kchar.addr, 90 ALIGN_UP(1, PAGE_SIZE) >> PAGE_WIDTH, AS_AREA_READ | AS_AREA_WRITE); 91 if (rc != EOK) 92 return rc; 93 94 return serial_init(kchar_putchar, kchar_control_puts); 74 95 } 75 96
Note:
See TracChangeset
for help on using the changeset viewer.