[Krafton Jungle] PintOS 2.0.0
크래프톤 정글 PintOS
 
Loading...
Searching...
No Matches
console.c File Reference
#include <console.h>
#include <stdarg.h>
#include <stdio.h>
#include "devices/serial.h"
#include "devices/vga.h"
#include "threads/init.h"
#include "threads/interrupt.h"
#include "threads/synch.h"
Include dependency graph for console.c:

Functions

static void vprintf_helper (char, void *)
 
static void putchar_have_lock (uint8_t c)
 
void console_init (void)
 
void console_panic (void)
 
void console_print_stats (void)
 
static void acquire_console (void)
 
static void release_console (void)
 
static bool console_locked_by_current_thread (void)
 
int vprintf (const char *format, va_list args)
 
int puts (const char *s)
 
void putbuf (const char *buffer, size_t n)
 
int putchar (int c)
 

Variables

static struct lock console_lock
 
static bool use_console_lock
 
static int console_lock_depth
 
static int64_t write_cnt
 

Function Documentation

◆ acquire_console()

static void acquire_console ( void  )
static
85 {
86 if (!intr_context () && use_console_lock) {
89 else
91 }
92}
bool intr_context(void)
Definition: interrupt.c:258
static bool use_console_lock
Definition: console.c:31
static int console_lock_depth
Definition: console.c:57
static struct lock console_lock
Definition: console.c:18
bool lock_held_by_current_thread(const struct lock *)
Definition: synch.c:258
void lock_acquire(struct lock *)
Definition: synch.c:202
Here is the call graph for this function:
Here is the caller graph for this function:

◆ console_init()

void console_init ( void  )
64 {
66 use_console_lock = true;
67}
void lock_init(struct lock *)
Definition: synch.c:186
Here is the call graph for this function:
Here is the caller graph for this function:

◆ console_locked_by_current_thread()

static bool console_locked_by_current_thread ( void  )
static
108 {
109 return (intr_context ()
112}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ console_panic()

void console_panic ( void  )
73 {
74 use_console_lock = false;
75}
Here is the caller graph for this function:

◆ console_print_stats()

void console_print_stats ( void  )
79 {
80 printf ("Console: %lld characters output\n", write_cnt);
81}
static int64_t write_cnt
Definition: console.c:60
int printf(const char *,...) PRINTF_FORMAT(1
Here is the call graph for this function:
Here is the caller graph for this function:

◆ putbuf()

void putbuf ( const char *  buffer,
size_t  n 
)
143 {
145 while (n-- > 0)
148}
static struct intq buffer
Definition: input.c:7
static void putchar_have_lock(uint8_t c)
Definition: console.c:172
static void acquire_console(void)
Definition: console.c:85
static void release_console(void)
Definition: console.c:96
Here is the call graph for this function:
Here is the caller graph for this function:

◆ putchar()

int putchar ( int  c)
152 {
156
157 return c;
158}
Here is the caller graph for this function:

◆ putchar_have_lock()

static void putchar_have_lock ( uint8_t  c)
static
172 {
174 write_cnt++;
175 serial_putc (c);
176 vga_putc (c);
177}
#define ASSERT(CONDITION)
Definition: debug.h:30
static bool console_locked_by_current_thread(void)
Definition: console.c:108
void serial_putc(uint8_t byte)
Definition: serial.c:97
void vga_putc(int c)
Definition: vga.c:49
Here is the call graph for this function:
Here is the caller graph for this function:

◆ puts()

int puts ( const char *  s)
131 {
133 while (*s != '\0')
134 putchar_have_lock (*s++);
135 putchar_have_lock ('\n');
137
138 return 0;
139}
static uint8_t s[256]
Definition: random.c:17

◆ release_console()

static void release_console ( void  )
static
96 {
97 if (!intr_context () && use_console_lock) {
98 if (console_lock_depth > 0)
100 else
102 }
103}
void lock_release(struct lock *)
Definition: synch.c:243
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vprintf()

int vprintf ( const char *  format,
va_list  args 
)
118 {
119 int char_cnt = 0;
120
122 __vprintf (format, args, vprintf_helper, &char_cnt);
124
125 return char_cnt;
126}
static void vprintf_helper(char, void *)
Definition: console.c:162
void __vprintf(const char *format, va_list args, void(*output)(char, void *), void *aux)
Definition: stdio.c:146
Here is the call graph for this function:

◆ vprintf_helper()

static void vprintf_helper ( char  c,
void *  char_cnt_ 
)
static
162 {
163 int *char_cnt = char_cnt_;
164 (*char_cnt)++;
166}
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ console_lock

struct lock console_lock
static

◆ console_lock_depth

int console_lock_depth
static

◆ use_console_lock

bool use_console_lock
static

◆ write_cnt

int64_t write_cnt
static