Changeset 481c520 in mainline


Ignore:
Timestamp:
2006-02-27T12:30:11Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
02f441c0
Parents:
4a2b52f
Message:

sparc64 work.
Revive OFW console code and use it before the kernel switches to standalone console.

ia32 + ia64 cosmetic changes.

Location:
arch
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • arch/ia32/src/drivers/i8042.c

    r4a2b52f r481c520  
    4646 */
    4747
    48 #define i8042_DATA              0x60
    49 #define i8042_STATUS            0x64
     48#define i8042_DATA                      0x60
     49#define i8042_STATUS                    0x64
    5050#define i8042_BUFFER_FULL_MASK          0x01
    51 
    5251
    5352/** Keyboard commands. */
     
    5756
    5857/*
    59  60   Write 8042 Command Byte: next data byte written to port 60h is
    60       placed in 8042 command register.Format:
    61 
    62      |7|6|5|4|3|2|1|0|8042 Command Byte
    63       | | | | | | | `---- 1=enable output register full interrupt
    64       | | | | | | `----- should be 0
    65       | | | | | `------ 1=set status register system, 0=clear
    66       | | | | `------- 1=override keyboard inhibit, 0=allow inhibit
    67       | | | `-------- disable keyboard I/O by driving clock line low
    68       | | `--------- disable auxiliary device, drives clock line low
    69       | `---------- IBM scancode translation 0=AT, 1=PC/XT
    70       `----------- reserved, should be 0
    71 */
    72 
    73 #define i8042_SET_COMMAND 0x60
    74 #define i8042_COMMAND 0x49
    75 #define i8042_WAIT_MASK 0x02
    76 
     58 * 60  Write 8042 Command Byte: next data byte written to port 60h is
     59 *     placed in 8042 command register.Format:
     60 *
     61 *    |7|6|5|4|3|2|1|0|8042 Command Byte
     62 *     | | | | | | | `---- 1=enable output register full interrupt
     63 *     | | | | | | `----- should be 0
     64 *     | | | | | `------ 1=set status register system, 0=clear
     65 *     | | | | `------- 1=override keyboard inhibit, 0=allow inhibit
     66 *     | | | `-------- disable keyboard I/O by driving clock line low
     67 *     | | `--------- disable auxiliary device, drives clock line low
     68 *     | `---------- IBM scancode translation 0=AT, 1=PC/XT
     69 *     `----------- reserved, should be 0
     70 */
     71
     72#define i8042_SET_COMMAND       0x60
     73#define i8042_COMMAND           0x49
     74#define i8042_WAIT_MASK         0x02
    7775
    7876#define SPECIAL         '?'
     
    8886
    8987#define ACTIVE_READ_BUFF_SIZE 16 /*Must be power of 2*/
    90 
    9188
    9289__u8 active_read_buff[ACTIVE_READ_BUFF_SIZE]={0};
     
    272269{
    273270        exc_register(VECTOR_KBD, "i8042_interrupt", i8042_interrupt);
    274         while (inb(i8042_STATUS)&i8042_WAIT_MASK);     /*Wait*/
     271        while (inb(i8042_STATUS)&i8042_WAIT_MASK) {
     272                /* wait */
     273        }
    275274        outb(i8042_STATUS,i8042_SET_COMMAND);
    276         while (inb(i8042_STATUS)&i8042_WAIT_MASK);     /*Wait*/
     275        while (inb(i8042_STATUS)&i8042_WAIT_MASK) {
     276                /* wait */
     277        }
    277278        outb(i8042_DATA,i8042_COMMAND);
    278279
     
    406407}
    407408
    408 
    409409static __u8 active_read_buff_read(void)
    410410{
     
    428428
    429429
    430 static void active_readed_key_pressed(__u8 sc)
     430static void active_read_key_pressed(__u8 sc)
    431431{
    432432        char *map = sc_primary_map;
     
    497497}
    498498
    499 
    500499static char key_read(chardev_t *d)
    501500{
    502501        char ch;       
    503        
    504502
    505503        while(!(ch=active_read_buff_read()))
     
    511509                        key_released(x ^ KEY_RELEASE);
    512510                else
    513                         active_readed_key_pressed(x);
     511                        active_read_key_pressed(x);
    514512        }
    515513        return ch;
    516514}
    517 
    518 
  • arch/ia64/src/ski/ski.c

    r4a2b52f r481c520  
    8787
    8888/**
    89         This is blocking wrap function of ski_getchar
    90         It active waits ... for using with non-stable kernel
    91 */
     89 * This is a blocking wrapper for ski_getchar().
     90 * To be used when the kernel crashes.
     91 */
    9292static char ski_getchar_blocking(chardev_t *d)
    9393{
    94         volatile int ch;
    95         while(!(ch=ski_getchar()));
    96         if(ch == '\r') ch = '\n';
     94        int ch;
     95
     96        while(!(ch=ski_getchar()))
     97                ;
     98        if(ch == '\r')
     99                ch = '\n';
    97100        return (char) ch;
    98101}
    99 
    100102
    101103/** Ask keyboard if a key was pressed. */
  • arch/ia64/src/start.S

    r4a2b52f r481c520  
    2727#
    2828
    29 
    3029#include <arch/register.h>
    3130#include <arch/mm/page.h>
     
    3332#include <mm/asid.h>
    3433
    35 
    3634#define RR_MASK (0xFFFFFFFF00000002)
    3735#define RID_SHIFT 8
    3836#define PS_SHIFT 2
    3937
    40 
    4138#define KERNEL_TRANSLATION_I 0x0010000000000661
    4239#define KERNEL_TRANSLATION_D 0x0010000000000661
    43 
    4440
    4541.section K_TEXT_START
     
    5147        .auto
    5248
    53         #Fill TR.i and TR.d using Region Register #VRN_KERNEL
     49        # Fill TR.i and TR.d using Region Register #VRN_KERNEL
    5450
    5551        movl r8=(VRN_KERNEL<<VRN_SHIFT)
     
    6157        mov rr[r8]=r9
    6258
    63 
    6459        movl r8=(VRN_KERNEL<<VRN_SHIFT)
    6560        mov cr.ifa=r8
     
    6863        movl r10=(KERNEL_TRANSLATION_I)
    6964        itr.i itr[r0]=r10
    70 
    7165        movl r10=(KERNEL_TRANSLATION_D)
    7266        itr.d dtr[r0]=r10
    73 
    7467
    7568        # initialize PSR
     
    7770        srlz.i
    7871        srlz.d
    79         movl r10=(PSR_DT_MASK|PSR_RT_MASK|PSR_IT_MASK|PSR_IC_MASK)  /*Enable paging*/
     72        movl r10=(PSR_DT_MASK|PSR_RT_MASK|PSR_IT_MASK|PSR_IC_MASK)  /* Enable paging */
    8073        mov r9=psr
    8174        or r10=r10,r9
     
    8679        srlz.d
    8780        srlz.i
    88 .explicit
    8981
    90         /*Return from interupt is only the way how to fill upper half word of PSR*/
    91         {rfi;;}
     82        .explicit
     83        /*
     84         * Return From Interupt is the only the way to fill upper half word of PSR.
     85         */
     86        rfi;;
    9287        {nop 0;;}
    9388        {nop 0;;}
     
    10095
    10196.global paging_start
    102         /*Now we are paging*/
    10397paging_start:
     98
     99        /*
     100         * Now we are paging.
     101         */
     102
    104103        {nop 0;;}
    105104        {nop 0;;}
     
    111110        {nop 0;;}
    112111
    113 .auto
    114        
    115112        # switch to register bank 1
    116113        bsw.1
     
    118115        # initialize register stack
    119116        mov ar.rsc = r0
    120         movl r8=(VRN_KERNEL<<VRN_SHIFT)
     117        movl r8=(VRN_KERNEL<<VRN_SHIFT) ;;
    121118        mov ar.bspstore = r8
    122119        loadrs
    123120
    124         .explicit
    125121        # initialize memory stack to some sane value
    126122        movl r12 = stack0;;
     
    131127        movl r1 = _hardcoded_load_address       ;;
    132128
    133        
    134 
    135         #
    136         # Initialize hardcoded_* variables.
    137         #
     129        /*
     130         * Initialize hardcoded_* variables.
     131         */
    138132        movl r14 = _hardcoded_ktext_size
    139133        movl r15 = _hardcoded_kdata_size
     
    147141        st8 [r19] = r16
    148142
    149 
    150 .auto
    151        
    152         movl r18=main_bsp
    153         mov b1=r18
     143        movl r18=main_bsp ;;
     144        mov b1=r18 ;;
    154145        br.call.sptk.many b0=b1
    155 
    156146
    1571470:
  • arch/sparc64/include/console.h

    r4a2b52f r481c520  
    3030#define __sparc64_CONSOLE_H__
    3131
    32 extern void fb_sparc64_console_init(void);
     32extern void kofwinput(void *arg);
     33extern void ofw_sparc64_console_init(void);
     34extern void standalone_sparc64_console_init(void);
    3335
    3436#endif
  • arch/sparc64/src/console.c

    r4a2b52f r481c520  
    3232#include <genarch/fb/fb.h>
    3333#include <arch/drivers/fb.h>
     34#include <genarch/ofw/ofw.h>
     35#include <console/chardev.h>
     36#include <console/console.h>
     37#include <arch/asm.h>
     38#include <arch/register.h>
     39#include <proc/thread.h>
     40#include <synch/mutex.h>
    3441
    35 void fb_sparc64_console_init(void)
     42static void ofw_sparc64_putchar(chardev_t *d, const char ch);
     43static char ofw_sparc64_getchar(chardev_t *d);
     44static void ofw_sparc64_suspend(chardev_t *d);
     45static void ofw_sparc64_resume(chardev_t *d);
     46
     47mutex_t canwork;
     48
     49static volatile int ofw_console_active;
     50
     51static chardev_t ofw_sparc64_console;
     52static chardev_operations_t ofw_sparc64_console_ops = {
     53        .write = ofw_sparc64_putchar,
     54        .read = ofw_sparc64_getchar,
     55        .resume = ofw_sparc64_resume,
     56        .suspend = ofw_sparc64_suspend
     57};
     58
     59/** Initialize kernel console to use OpenFirmware services. */
     60void ofw_sparc64_console_init(void)
    3661{
     62        chardev_initialize("ofw_sparc64_console", &ofw_sparc64_console, &ofw_sparc64_console_ops);
     63        stdin = &ofw_sparc64_console;
     64        stdout = &ofw_sparc64_console;
     65        mutex_initialize(&canwork);
     66        ofw_console_active = 1;
     67}
     68
     69/** Initialize kernel console to use framebuffer and keyboard directly. */
     70void standalone_sparc64_console_init(void)
     71{
     72        ofw_console_active = 0;
     73        stdin = NULL;
    3774        fb_init(FB_VIRT_ADDRESS, FB_X_RES, FB_Y_RES, FB_COLOR_DEPTH/8);
    3875}
     76
     77/** Write one character using OpenFirmware.
     78 *
     79 * @param d Character device (ignored).
     80 * @param ch Character to be written.
     81 */
     82void ofw_sparc64_putchar(chardev_t *d, const char ch)
     83{
     84        pstate_reg_t pstate;
     85
     86        /*
     87         * 32-bit OpenFirmware depends on PSTATE.AM bit set.
     88         */     
     89        pstate.value = pstate_read();
     90        pstate.am = true;
     91        pstate_write(pstate.value);
     92
     93        if (ch == '\n')
     94                ofw_putchar('\r');
     95        ofw_putchar(ch);
     96       
     97        pstate.am = false;
     98        pstate_write(pstate.value);
     99}
     100
     101/** Read one character using OpenFirmware.
     102 *
     103 * The call is non-blocking.
     104 *
     105 * @param d Character device (ignored).
     106 * @return Character read or zero if no character was read.
     107 */
     108char ofw_sparc64_getchar(chardev_t *d)
     109{
     110        char ch;
     111        pstate_reg_t pstate;
     112
     113        /*
     114         * 32-bit OpenFirmware depends on PSTATE.AM bit set.
     115         */     
     116        pstate.value = pstate_read();
     117        pstate.am = true;
     118        pstate_write(pstate.value);
     119
     120        ch = ofw_getchar();
     121       
     122        pstate.am = false;
     123        pstate_write(pstate.value);
     124       
     125        return ch;
     126}
     127
     128void ofw_sparc64_suspend(chardev_t *d)
     129{
     130        mutex_lock(&canwork);
     131}
     132
     133void ofw_sparc64_resume(chardev_t *d)
     134{
     135        mutex_unlock(&canwork);
     136}
     137
     138/** Kernel thread for pushing characters read from OFW to input buffer.
     139 *
     140 * @param arg Ignored.
     141 */
     142void kofwinput(void *arg)
     143{
     144
     145        while (ofw_console_active) {
     146                char ch = 0;
     147               
     148                mutex_lock(&canwork);
     149                mutex_unlock(&canwork);
     150               
     151                ch = ofw_sparc64_getchar(NULL);
     152                if (ch) {
     153                        if (ch == '\r')
     154                                ch = '\n';
     155                        chardev_push_character(&ofw_sparc64_console, ch);
     156                }
     157                thread_usleep(25000);
     158        }
     159}
  • arch/sparc64/src/sparc64.c

    r4a2b52f r481c520  
    3737{
    3838        interrupts_disable();
     39        ofw_sparc64_console_init();
    3940        trap_init();
    4041        tick_init();
     
    4344void arch_post_mm_init(void)
    4445{
    45         fb_sparc64_console_init();
     46        standalone_sparc64_console_init();
    4647}
    4748
     
    5253void arch_post_smp_init(void)
    5354{
     55        thread_t *t;
     56
     57        /*
     58         * Create thread that reads characters from OFW's input.
     59         */
     60        t = thread_create(kofwinput, NULL, TASK, 0);
     61        if (!t)
     62                panic("cannot create kofwinput\n");
     63        thread_ready(t);
    5464}
    5565
Note: See TracChangeset for help on using the changeset viewer.