Changeset 925a21e in mainline for uspace/srv/hid/fb/port/kchar.c


Ignore:
Timestamp:
2011-09-24T14:20:29Z (13 years ago)
Author:
Jakub Jermar <jakub@…>
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.
Message:

Merge mainline changes.

File:
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/fb/port/kchar.c

    r867e2555 r925a21e  
    2828 */
    2929
    30 /** @defgroup msimfb MSIM text console
    31  * @brief HelenOS MSIM text console.
    32  * @ingroup fbs
    33  * @{
    34  */
    3530/** @file
    3631 */
    3732
    38 #include <async.h>
    39 #include <libc.h>
     33#include <sys/types.h>
     34#include <errno.h>
    4035#include <sysinfo.h>
     36#include <ddi.h>
    4137#include <as.h>
    42 #include <ddi.h>
    43 #include <errno.h>
     38#include <align.h>
     39#include "../ctl/serial.h"
     40#include "kchar.h"
    4441
    45 #include "serial_console.h"
    46 #include "msim.h"
     42typedef struct {
     43        uint8_t *addr;
     44} kchar_t;
    4745
    48 #define WIDTH 80
    49 #define HEIGHT 24
     46static kchar_t kchar;
    5047
    51 static char *virt_addr;
    52 
    53 static void msim_putc(const char c)
     48static void kchar_putchar(wchar_t ch)
    5449{
    55         *virt_addr = c;
     50        if ((ch >= 0) && (ch < 128))
     51                *kchar.addr = ch;
     52        else
     53                *kchar.addr = '?';
    5654}
    5755
    58 int msim_init(void)
     56static void kchar_control_puts(const char *str)
    5957{
    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
     62int kchar_init(void)
     63{
     64        sysarg_t present;
     65        int rc = sysinfo_get_value("fb", &present);
     66        if (rc != EOK)
     67                present = false;
    6368       
    64         virt_addr = (char *) as_get_mappable_page(1);
     69        if (!present)
     70                return ENOENT;
    6571       
    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;
    6976       
    70         serial_console_init(msim_putc, WIDTH, HEIGHT);
     77        if (kind != 3)
     78                return EINVAL;
    7179       
    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);
    7495}
    7596
Note: See TracChangeset for help on using the changeset viewer.