Changeset 7c014d1 in mainline for uspace/srv/hid/fb/port


Ignore:
Timestamp:
2011-09-09T15:46:21Z (15 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c69646f8
Parents:
14a60e3
Message:

console and framebuffer server rewrite

Location:
uspace/srv/hid/fb/port
Files:
2 added
8 moved

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/fb/port/ega.h

    r14a60e3 r7c014d1  
    2727 */
    2828
    29 /** @addtogroup egafb
    30  * @brief HelenOS EGA framebuffer.
    31  * @ingroup fbs
    32  * @{
    33  */
    3429/** @file
    3530 */
    3631
    37 #ifndef FB_EGA_H_
    38 #define FB_EGA_H_
     32#ifndef FB_PORT_EGA_H_
     33#define FB_PORT_EGA_H_
    3934
    4035extern int ega_init(void);
  • uspace/srv/hid/fb/port/kchar.c

    r14a60e3 r7c014d1  
    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
  • uspace/srv/hid/fb/port/kchar.h

    r14a60e3 r7c014d1  
    11/*
    22 * Copyright (c) 2006 Ondrej Palkovsky
     3 * Copyright (c) 2008 Martin Decky
    34 * All rights reserved.
    45 *
     
    2728 */
    2829
    29 #ifndef FB_MAIN_H_
    30 #define FB_MAIN_H_
     30/** @file
     31 */
    3132
    32 extern void receive_comm_area(ipc_callid_t, ipc_call_t *, void **);
     33#ifndef FB_PORT_KCHAR_H_
     34#define FB_PORT_KCHAR_H_
     35
     36extern int kchar_init(void);
    3337
    3438#endif
     39
     40/** @}
     41 */
  • uspace/srv/hid/fb/port/kfb.h

    r14a60e3 r7c014d1  
    11/*
    2  * Copyright (c) 2011 Martin Decky
     2 * Copyright (c) 2006 Ondrej Palkovsky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup imgmap
     29/** @addtogroup fb
     30 * @ingroup fbs
    3031 * @{
    3132 */
    32 /**
    33  * @file
     33/** @file
    3434 */
    3535
    36 #ifndef IMGMAP_IMGMAP_H_
    37 #define IMGMAP_IMGMAP_H_
     36#ifndef FB_PORT_KFB_H_
     37#define FB_PORT_KFB_H_
    3838
    39 #include <sys/types.h>
    40 #include <abi/fb/visuals.h>
    41 
    42 typedef struct {
    43         size_t size;
    44         sysarg_t width;
    45         sysarg_t height;
    46         visual_t visual;
    47         uint8_t data[];
    48 } imgmap_t;
    49 
    50 extern imgmap_t *imgmap_decode_tga(void *, size_t);
     39extern int kfb_init(void);
    5140
    5241#endif
  • uspace/srv/hid/fb/port/niagara.c

    r14a60e3 r7c014d1  
    2929 */
    3030
    31 /** @defgroup niagarafb
    32  * @brief       userland driver of the Niagara console output
    33  * @{
    34  */
    3531/** @file
    3632 */
    3733
    38 #include <async.h>
     34#include <sys/types.h>
     35#include <errno.h>
    3936#include <sysinfo.h>
     37#include <ddi.h>
    4038#include <as.h>
    41 #include <errno.h>
    42 #include <stdio.h>
    43 #include <ddi.h>
    44 
    45 #include "serial_console.h"
     39#include <align.h>
     40#include "../ctl/serial.h"
    4641#include "niagara.h"
    4742
    48 #define WIDTH 80
    49 #define HEIGHT 24
     43#define OUTPUT_FIFO_SIZE  ((PAGE_SIZE) - 2 * sizeof(uint64_t))
    5044
    51 /**
    52  * Virtual address mapped to the buffer shared with the kernel counterpart.
    53  */
    54 static uintptr_t output_buffer_addr;
    55 
    56 /*
    57  * Kernel counterpart of the driver reads characters to be printed from here.
    58  * Keep in sync with the definition from
    59  * kernel/arch/sparc64/src/drivers/niagara.c.
    60  */
    61 #define OUTPUT_BUFFER_SIZE      ((PAGE_SIZE) - 2 * 8)
    6245typedef volatile struct {
    6346        uint64_t read_ptr;
    6447        uint64_t write_ptr;
    65         char data[OUTPUT_BUFFER_SIZE];
    66 }
    67         __attribute__ ((packed))
    68         __attribute__ ((aligned(PAGE_SIZE)))
    69         *output_buffer_t;
     48        char data[OUTPUT_FIFO_SIZE];
     49} __attribute__((packed)) output_fifo_t;
    7050
    71 output_buffer_t output_buffer;
     51typedef struct {
     52        output_fifo_t *fifo;
     53} niagara_t;
    7254
    73 /**
    74  * Pushes the character to the Niagara serial.
    75  * @param c     character to be pushed
    76  */
    77 static void niagara_putc(char c)
     55static niagara_t niagara;
     56
     57static void niagara_putc(const char c)
    7858{
    79         while (output_buffer->write_ptr ==
    80                (output_buffer->read_ptr + OUTPUT_BUFFER_SIZE - 1)
    81                % OUTPUT_BUFFER_SIZE)
    82                 ;
    83         output_buffer->data[output_buffer->write_ptr] = (uint64_t) c;
    84         output_buffer->write_ptr =
    85                 ((output_buffer->write_ptr) + 1) % OUTPUT_BUFFER_SIZE;
     59        while (niagara.fifo->write_ptr ==
     60            (niagara.fifo->read_ptr + OUTPUT_FIFO_SIZE - 1)
     61            % OUTPUT_FIFO_SIZE);
     62       
     63        niagara.fifo->data[niagara.fifo->write_ptr] = c;
     64        niagara.fifo->write_ptr =
     65            ((niagara.fifo->write_ptr) + 1) % OUTPUT_FIFO_SIZE;
    8666}
    8767
    88 /**
    89  * Initializes the Niagara serial driver.
    90  */
     68static void niagara_putchar(wchar_t ch)
     69{
     70        if ((ch >= 0) && (ch < 128))
     71                niagara_putc(ch);
     72        else
     73                niagara_putc('?');
     74}
     75
     76static void niagara_control_puts(const char *str)
     77{
     78        while (*str)
     79                niagara_putc(*(str++));
     80}
     81
    9182int niagara_init(void)
    9283{
     84        sysarg_t present;
     85        int rc = sysinfo_get_value("fb", &present);
     86        if (rc != EOK)
     87                present = false;
     88       
     89        if (!present)
     90                return ENOENT;
     91       
     92        sysarg_t kind;
     93        rc = sysinfo_get_value("fb.kind", &kind);
     94        if (rc != EOK)
     95                kind = (sysarg_t) -1;
     96       
     97        if (kind != 5)
     98                return EINVAL;
     99       
    93100        sysarg_t paddr;
    94         if (sysinfo_get_value("niagara.outbuf.address", &paddr) != EOK)
    95                 return -1;
     101        rc = sysinfo_get_value("niagara.outbuf.address", &paddr);
     102        if (rc != EOK)
     103                return rc;
    96104       
    97         output_buffer_addr = (uintptr_t) as_get_mappable_page(PAGE_SIZE);
    98         int result = physmem_map((void *) paddr,
    99             (void *) output_buffer_addr, 1,
     105        niagara.fifo =
     106            (output_fifo_t *) as_get_mappable_page(sizeof(output_fifo_t));
     107        if (niagara.fifo == NULL)
     108                return ENOMEM;
     109       
     110        rc = physmem_map((void *) paddr, (void *) niagara.fifo, 1,
    100111            AS_AREA_READ | AS_AREA_WRITE);
    101 
    102         if (result != 0) {
    103                 printf("Niagara: uspace driver couldn't map physical memory: %d\n",
    104                         result);
    105         }
    106 
    107         output_buffer = (output_buffer_t) output_buffer_addr;
    108 
    109         serial_console_init(niagara_putc, WIDTH, HEIGHT);
    110         async_set_client_connection(serial_client_connection);
    111         return 0;
     112        if (rc != EOK)
     113                return rc;
     114       
     115        return serial_init(niagara_putchar, niagara_control_puts);
    112116}
    113117
    114 /**
    115  * @}
     118/** @}
    116119 */
    117  
  • uspace/srv/hid/fb/port/niagara.h

    r14a60e3 r7c014d1  
    2727 */
    2828
    29 /** @defgroup niagarafb
    30  * @brief       userland driver of the Niagara console output
    31  * @{
    32  */
    33  
    3429/** @file
    3530 */
    3631
    37 #ifndef FB_NIAGARA_H_
    38 #define FB_NIAGARA_H_
     32#ifndef FB_PORT_NIAGARA_H_
     33#define FB_PORT_NIAGARA_H_
    3934
    40 int niagara_init(void);
     35extern int niagara_init(void);
    4136
    4237#endif
    4338
    44 /** 
     39/**
    4540 * @}
    4641 */
  • uspace/srv/hid/fb/port/ski.c

    r14a60e3 r7c014d1  
    11/*
    2  * Copyright (c) 2005 Jakub Jermar
    3  * Copyright (c) 2008 Jiri Svoboda
     2 * Copyright (c) 2006 Ondrej Palkovsky
     3 * Copyright (c) 2008 Martin Decky
    44 * All rights reserved.
    55 *
     
    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>
    41 #include <as.h>
    42 #include <ddi.h>
    43 
    44 #include "serial_console.h"
     36#include "../ctl/serial.h"
    4537#include "ski.h"
    4638
    47 #define SKI_PUTCHAR             31
     39#ifdef UARCH_ia64
    4840
    49 #define WIDTH 80
    50 #define HEIGHT 24
     41#define SKI_PUTCHAR  31
    5142
    5243/** Display character on ski debug console
     
    5546 * display character on debug console.
    5647 *
    57  * @param ch Character to be printed.
     48 * @param c Character to be printed.
     49 *
    5850 */
    59 static void ski_putc(const char ch)
     51static void ski_putc(const char c)
    6052{
    6153        asm volatile (
    6254                "mov r15 = %0\n"
    63                 "mov r32 = %1\n"        /* r32 is in0 */
    64                 "break 0x80000\n"       /* modifies r8 */
     55                "mov r32 = %1\n"   /* r32 is in0 */
     56                "break 0x80000\n"  /* modifies r8 */
    6557                :
    66                 : "i" (SKI_PUTCHAR), "r" (ch)
     58                : "i" (SKI_PUTCHAR), "r" (c)
    6759                : "r15", "in0", "r8"
    6860        );
    6961       
    70         if (ch == '\n')
     62        if (c == '\n')
    7163                ski_putc('\r');
     64}
     65
     66static void ski_putchar(wchar_t ch)
     67{
     68        if ((ch >= 0) && (ch < 128))
     69                ski_putc(ch);
     70        else
     71                ski_putc('?');
     72}
     73
     74static void ski_control_puts(const char *str)
     75{
     76        while (*str)
     77                ski_putc(*(str++));
    7278}
    7379
    7480int ski_init(void)
    7581{
    76         serial_console_init(ski_putc, WIDTH, HEIGHT);
     82        sysarg_t present;
     83        int rc = sysinfo_get_value("fb", &present);
     84        if (rc != EOK)
     85                present = false;
    7786       
    78         async_set_client_connection(serial_client_connection);
    79         return 0;
     87        if (!present)
     88                return ENOENT;
     89       
     90        sysarg_t kind;
     91        rc = sysinfo_get_value("fb.kind", &kind);
     92        if (rc != EOK)
     93                kind = (sysarg_t) -1;
     94       
     95        if (kind != 6)
     96                return EINVAL;
     97       
     98        return serial_init(ski_putchar, ski_control_puts);
    8099}
    81100
    82 /**
    83  * @}
     101#else /* UARCH_ia64 */
     102
     103int ski_init(void)
     104{
     105        return ENOENT;
     106}
     107
     108#endif
     109
     110/** @}
    84111 */
  • uspace/srv/hid/fb/port/ski.h

    r14a60e3 r7c014d1  
    2727 */
    2828
    29 /** @addtogroup skifb
    30  * @brief       HelenOS ski text console.
    31  * @ingroup fbs
    32  * @{
    33  */
    3429/** @file
    3530 */
    3631
    37 #ifndef FB_SKI_H_
    38 #define FB_SKI_H_
     32#ifndef FB_PORT_SKI_H_
     33#define FB_PORT_SKI_H_
    3934
    4035extern int ski_init(void);
     
    4439/** @}
    4540 */
    46 
Note: See TracChangeset for help on using the changeset viewer.