CS350 COS
COS
Loading...
Searching...
No Matches
sercons.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void Serial_Init (void)
 
void Serial_LateInit (void)
 
void Serial_Interrupt (void *arg)
 
bool Serial_HasData ()
 
char Serial_Getc ()
 
void Serial_Putc (char ch)
 
void Serial_Puts (const char *str)
 

Function Documentation

◆ Serial_Getc()

char Serial_Getc ( )

Definition at line 78 of file sercons.c.

79{
80 while ((inb(base + UART_OFFSET_LSR) & 0x01) == 0)
81 {
82 // Timeout!
83 }
84 return inb(base + UART_OFFSET_DATA);
85}
static INLINE uint8_t inb(uint16_t port)
Definition: amd64op.h:452
#define UART_OFFSET_DATA
Definition: sercons.c:22
static uint16_t base
Definition: sercons.c:37
#define UART_OFFSET_LSR
Definition: sercons.c:29
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Serial_HasData()

bool Serial_HasData ( )

Definition at line 73 of file sercons.c.

74{
75 return (inb(base + UART_OFFSET_LSR) & 0x01) != 0;
76}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Serial_Init()

void Serial_Init ( void  )

Definition at line 40 of file sercons.c.

41{
43 irq = COM1_IRQ;
44
45 // Disable interrupts
47
48 // Enable DLAB
50 outb(base + UART_OFFSET_DIVLO, 1); // 115200 Baud
53
54 // Enable interrupts
55 outb(base + UART_OFFSET_IIR, 0xC7);
56 outb(base + UART_OFFSET_MCR, 0x0B);
57}
static INLINE void outb(uint16_t port, uint8_t data)
Definition: amd64op.h:431
#define UART_OFFSET_DIVLO
Definition: sercons.c:33
#define UART_LCR_8N1
Definition: sercons.c:27
#define COM1_IRQ
Definition: sercons.c:16
#define UART_OFFSET_IER
Definition: sercons.c:23
#define UART_OFFSET_IIR
Definition: sercons.c:24
#define UART_OFFSET_LCR
Definition: sercons.c:25
#define COM1_BASE
Definition: sercons.c:11
#define UART_LCR_DLAB
Definition: sercons.c:26
#define UART_OFFSET_MCR
Definition: sercons.c:28
static uint8_t irq
Definition: sercons.c:38
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Serial_Interrupt()

void Serial_Interrupt ( void *  arg)

Definition at line 68 of file sercons.c.

69{
70 kprintf("Serial interrupt!\n");
71}
int kprintf(const char *fmt,...)
Definition: printf.c:210
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Serial_LateInit()

void Serial_LateInit ( void  )

Definition at line 59 of file sercons.c.

60{
61 handler.irq = irq;
64
66}
void IRQ_Register(int irq, struct IRQHandler *h)
Definition: irq.c:35
static IRQHandler handler
Definition: sercons.c:36
void Serial_Interrupt(void *arg)
Definition: sercons.c:68
#define NULL
Definition: stddef.h:6
void * arg
Definition: irq.h:10
int irq
Definition: irq.h:8
void(* cb)(void *)
Definition: irq.h:9
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Serial_Putc()

void Serial_Putc ( char  ch)

Definition at line 87 of file sercons.c.

88{
89 while ((inb(base + UART_OFFSET_LSR) & 0x20) == 0)
90 {
91 // Timeout!
92 }
94
95 if (ch == '\b') {
96 Serial_Putc(0x1B);
97 Serial_Putc('[');
98 Serial_Putc('P');
99 }
100}
void Serial_Putc(char ch)
Definition: sercons.c:87
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Serial_Puts()

void Serial_Puts ( const char *  str)

Definition at line 102 of file sercons.c.

103{
104 const char *p = str;
105 while (*p != '\0')
106 Serial_Putc(*p++);
107}
Here is the call graph for this function:
Here is the caller graph for this function: