[Krafton Jungle] PintOS 2.0.0
크래프톤 정글 PintOS
 
Loading...
Searching...
No Matches
serial.h File Reference
#include <stdint.h>
Include dependency graph for serial.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void serial_init_queue (void)
 
void serial_putc (uint8_t)
 
void serial_flush (void)
 
void serial_notify (void)
 

Function Documentation

◆ serial_flush()

void serial_flush ( void  )
128 {
129 enum intr_level old_level = intr_disable ();
130 while (!intq_empty (&txq))
132 intr_set_level (old_level);
133}
enum intr_level intr_set_level(enum intr_level)
Definition: interrupt.c:130
enum intr_level intr_disable(void)
Definition: interrupt.c:151
intr_level
Definition: interrupt.h:8
bool intq_empty(const struct intq *q)
Definition: intq.c:19
uint8_t intq_getc(struct intq *q)
Definition: intq.c:36
static void putc_poll(uint8_t)
Definition: serial.c:188
static struct intq txq
Definition: serial.c:55
Here is the call graph for this function:
Here is the caller graph for this function:

◆ serial_init_queue()

void serial_init_queue ( void  )
81 {
82 enum intr_level old_level;
83
84 if (mode == UNINIT)
85 init_poll ();
86 ASSERT (mode == POLL);
87
88 intr_register_ext (0x20 + 4, serial_interrupt, "serial");
89 mode = QUEUE;
90 old_level = intr_disable ();
91 write_ier ();
92 intr_set_level (old_level);
93}
#define ASSERT(CONDITION)
Definition: debug.h:30
void intr_register_ext(uint8_t vec, intr_handler_func *, const char *name)
Definition: interrupt.c:228
@ QUEUE
Definition: serial.c:52
@ UNINIT
Definition: serial.c:52
@ POLL
Definition: serial.c:52
static intr_handler_func serial_interrupt
Definition: serial.c:60
static enum @0 mode
static void init_poll(void)
Definition: serial.c:67
static void write_ier(void)
Definition: serial.c:167
Here is the call graph for this function:
Here is the caller graph for this function:

◆ serial_notify()

void serial_notify ( void  )
140 {
142 if (mode == QUEUE)
143 write_ier ();
144}
@ INTR_OFF
Definition: interrupt.h:9
enum intr_level intr_get_level(void)
Definition: interrupt.c:115
Here is the call graph for this function:
Here is the caller graph for this function:

◆ serial_putc()

void serial_putc ( uint8_t  byte)
97 {
98 enum intr_level old_level = intr_disable ();
99
100 if (mode != QUEUE) {
101 /* If we're not set up for interrupt-driven I/O yet,
102 use dumb polling to transmit a byte. */
103 if (mode == UNINIT)
104 init_poll ();
105 putc_poll (byte);
106 } else {
107 /* Otherwise, queue a byte and update the interrupt enable
108 register. */
109 if (old_level == INTR_OFF && intq_full (&txq)) {
110 /* Interrupts are off and the transmit queue is full.
111 If we wanted to wait for the queue to empty,
112 we'd have to reenable interrupts.
113 That's impolite, so we'll send a character via
114 polling instead. */
116 }
117
118 intq_putc (&txq, byte);
119 write_ier ();
120 }
121
122 intr_set_level (old_level);
123}
void intq_putc(struct intq *q, uint8_t byte)
Definition: intq.c:58
bool intq_full(const struct intq *q)
Definition: intq.c:26
Here is the call graph for this function:
Here is the caller graph for this function: