Changeset 154 for trunk


Ignore:
Timestamp:
Jul 7, 2017, 9:16:50 AM (7 years ago)
Author:
max@…
Message:

use a demultiplexer to get the channel on the serial port, and
make x86_printf print both on the VGA and COM1

Location:
trunk/hal/x86_64/core
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/hal/x86_64/core/hal_apic.c

    r153 r154  
    179179}
    180180
    181 void hal_com_send(char c)
     181void hal_com_send(uint8_t chan, char c)
    182182{
    183183        uint8_t mcr = in8(RS232_COM1_BASE + RS232_MCR);
     
    185185
    186186        while (!hal_com_transmit_empty());
     187        out8(RS232_COM1_BASE + RS232_DATA, chan | 0x80);
    187188        out8(RS232_COM1_BASE + RS232_DATA, c);
    188189
    189190        out8(RS232_COM1_BASE + RS232_MCR, mcr);
     191}
     192
     193/*
     194 * Called early to provide x86-specific messages. Interrupts disabled.
     195 */
     196void hal_com_init_early()
     197{
     198        /* Disable all interrupts */
     199        out8(RS232_COM1_BASE + RS232_IER, 0x00);
     200
     201        /* Set baudrate */
     202        out8(RS232_COM1_BASE + RS232_LCR, LCR_DLAB);
     203        out8(RS232_COM1_BASE + RS232_DIVLO, BAUDRATE_DIV);
     204        out8(RS232_COM1_BASE + RS232_DIVHI, 0);
     205
     206        /* 8bits, no parity, one stop bit */
     207        out8(RS232_COM1_BASE + RS232_LCR, LCR_DATA8);
     208
     209        /* DTR set, and also DSR */
     210        out8(RS232_COM1_BASE + RS232_MCR, MCR_DTR|MCR_IR);
     211        out8(RS232_COM1_BASE + RS232_MSR, MSR_DSR);
    190212}
    191213
  • trunk/hal/x86_64/core/hal_apic.h

    r152 r154  
    2222#ifndef x86_ASM
    2323char hal_com_read();
    24 void hal_com_send(char c);
     24void hal_com_send(uint8_t chan, char c);
     25void hal_com_init_early();
    2526
    2627void hal_ioapic_disable_entry(uint8_t index);
  • trunk/hal/x86_64/core/hal_init.c

    r152 r154  
    254254        boot_info_t btinfo;
    255255
     256        /* Initialize the serial port */
     257        hal_com_init_early();
     258
    256259        x86_printf("[+] init_x86_64 called\n");
    257260
  • trunk/hal/x86_64/core/hal_interrupt.c

    r152 r154  
    4949void hal_com1_intr(struct trapframe *tf)
    5050{
    51         char c = hal_com_read();
     51        static char prev;
     52        uint8_t chan;
     53        char c;
    5254
    53         x86_printf("-> got com '%c'\n", c);
     55        if (prev & 0x80) {
     56                /* the previous char was the channel number (tty) */
     57                c = hal_com_read();
     58                chan = prev & 0x7F;
     59                x86_printf("-> got com [%z,'%c']\n", (uint64_t)chan, c);
     60                prev = 0;
     61        } else {
     62                prev = hal_com_read();
     63        }
     64
    5465        return;
    5566}
  • trunk/hal/x86_64/core/x86_printf.c

    r145 r154  
    2323#include <hal_boot.h>
    2424#include <hal_internal.h>
     25#include <hal_apic.h>
    2526
    2627#include <memcpy.h>
     
    7576void x86_putc(char c)
    7677{
     78        hal_com_send(0, c);
     79
    7780        if (c == '\n') {
    7881                cons_ptr = roundup(cons_ptr, CONS_X_SIZE * 2);
Note: See TracChangeset for help on using the changeset viewer.