From 6913e9cd75ca710b36b3e7b91bae48d8c549cf7f Mon Sep 17 00:00:00 2001 From: garenchan <1412950785@qq.com> Date: Fri, 23 Nov 2018 22:15:18 +0800 Subject: [PATCH] clear_screen should be a public API function. Since clear_screen has been exposed in the header file, it should be a public API function rather then a private one. --- 16-video-driver/drivers/screen.c | 24 ++++++++++++------------ 17-video-scroll/drivers/screen.c | 24 ++++++++++++------------ 18-interrupts/drivers/screen.c | 24 ++++++++++++------------ 20-interrupts-timer/drivers/screen.c | 24 ++++++++++++------------ 21-shell/drivers/screen.c | 24 ++++++++++++------------ 22-malloc/drivers/screen.c | 24 ++++++++++++------------ 23-fixes/drivers/screen.c | 24 ++++++++++++------------ 7 files changed, 84 insertions(+), 84 deletions(-) diff --git a/16-video-driver/drivers/screen.c b/16-video-driver/drivers/screen.c index a449f20..eeb018a 100644 --- a/16-video-driver/drivers/screen.c +++ b/16-video-driver/drivers/screen.c @@ -13,6 +13,18 @@ int get_offset_col(int offset); * Public Kernel API functions * **********************************************************/ +void clear_screen() { + int screen_size = MAX_COLS * MAX_ROWS; + int i; + char *screen = VIDEO_ADDRESS; + + for (i = 0; i < screen_size; i++) { + screen[i*2] = ' '; + screen[i*2+1] = WHITE_ON_BLACK; + } + set_cursor_offset(get_offset(0, 0)); +} + /** * Print a message on the specified location * If col, row, are negative, we will use the current offset @@ -104,18 +116,6 @@ void set_cursor_offset(int offset) { port_byte_out(REG_SCREEN_DATA, (unsigned char)(offset & 0xff)); } -void clear_screen() { - int screen_size = MAX_COLS * MAX_ROWS; - int i; - char *screen = VIDEO_ADDRESS; - - for (i = 0; i < screen_size; i++) { - screen[i*2] = ' '; - screen[i*2+1] = WHITE_ON_BLACK; - } - set_cursor_offset(get_offset(0, 0)); -} - int get_offset(int col, int row) { return 2 * (row * MAX_COLS + col); } int get_offset_row(int offset) { return offset / (2 * MAX_COLS); } diff --git a/17-video-scroll/drivers/screen.c b/17-video-scroll/drivers/screen.c index 02d4dd7..e818ba3 100644 --- a/17-video-scroll/drivers/screen.c +++ b/17-video-scroll/drivers/screen.c @@ -14,6 +14,18 @@ int get_offset_col(int offset); * Public Kernel API functions * **********************************************************/ +void clear_screen() { + int screen_size = MAX_COLS * MAX_ROWS; + int i; + char *screen = VIDEO_ADDRESS; + + for (i = 0; i < screen_size; i++) { + screen[i*2] = ' '; + screen[i*2+1] = WHITE_ON_BLACK; + } + set_cursor_offset(get_offset(0, 0)); +} + /** * Print a message on the specified location * If col, row, are negative, we will use the current offset @@ -121,18 +133,6 @@ void set_cursor_offset(int offset) { port_byte_out(REG_SCREEN_DATA, (unsigned char)(offset & 0xff)); } -void clear_screen() { - int screen_size = MAX_COLS * MAX_ROWS; - int i; - char *screen = VIDEO_ADDRESS; - - for (i = 0; i < screen_size; i++) { - screen[i*2] = ' '; - screen[i*2+1] = WHITE_ON_BLACK; - } - set_cursor_offset(get_offset(0, 0)); -} - int get_offset(int col, int row) { return 2 * (row * MAX_COLS + col); } int get_offset_row(int offset) { return offset / (2 * MAX_COLS); } diff --git a/18-interrupts/drivers/screen.c b/18-interrupts/drivers/screen.c index 02d4dd7..e818ba3 100644 --- a/18-interrupts/drivers/screen.c +++ b/18-interrupts/drivers/screen.c @@ -14,6 +14,18 @@ int get_offset_col(int offset); * Public Kernel API functions * **********************************************************/ +void clear_screen() { + int screen_size = MAX_COLS * MAX_ROWS; + int i; + char *screen = VIDEO_ADDRESS; + + for (i = 0; i < screen_size; i++) { + screen[i*2] = ' '; + screen[i*2+1] = WHITE_ON_BLACK; + } + set_cursor_offset(get_offset(0, 0)); +} + /** * Print a message on the specified location * If col, row, are negative, we will use the current offset @@ -121,18 +133,6 @@ void set_cursor_offset(int offset) { port_byte_out(REG_SCREEN_DATA, (unsigned char)(offset & 0xff)); } -void clear_screen() { - int screen_size = MAX_COLS * MAX_ROWS; - int i; - char *screen = VIDEO_ADDRESS; - - for (i = 0; i < screen_size; i++) { - screen[i*2] = ' '; - screen[i*2+1] = WHITE_ON_BLACK; - } - set_cursor_offset(get_offset(0, 0)); -} - int get_offset(int col, int row) { return 2 * (row * MAX_COLS + col); } int get_offset_row(int offset) { return offset / (2 * MAX_COLS); } diff --git a/20-interrupts-timer/drivers/screen.c b/20-interrupts-timer/drivers/screen.c index 89fcfeb..f8d0b08 100644 --- a/20-interrupts-timer/drivers/screen.c +++ b/20-interrupts-timer/drivers/screen.c @@ -13,6 +13,18 @@ int get_offset_col(int offset); * Public Kernel API functions * **********************************************************/ +void clear_screen() { + int screen_size = MAX_COLS * MAX_ROWS; + int i; + char *screen = VIDEO_ADDRESS; + + for (i = 0; i < screen_size; i++) { + screen[i*2] = ' '; + screen[i*2+1] = WHITE_ON_BLACK; + } + set_cursor_offset(get_offset(0, 0)); +} + /** * Print a message on the specified location * If col, row, are negative, we will use the current offset @@ -120,18 +132,6 @@ void set_cursor_offset(int offset) { port_byte_out(REG_SCREEN_DATA, (unsigned char)(offset & 0xff)); } -void clear_screen() { - int screen_size = MAX_COLS * MAX_ROWS; - int i; - char *screen = VIDEO_ADDRESS; - - for (i = 0; i < screen_size; i++) { - screen[i*2] = ' '; - screen[i*2+1] = WHITE_ON_BLACK; - } - set_cursor_offset(get_offset(0, 0)); -} - int get_offset(int col, int row) { return 2 * (row * MAX_COLS + col); } int get_offset_row(int offset) { return offset / (2 * MAX_COLS); } diff --git a/21-shell/drivers/screen.c b/21-shell/drivers/screen.c index e955688..890b4a9 100644 --- a/21-shell/drivers/screen.c +++ b/21-shell/drivers/screen.c @@ -14,6 +14,18 @@ int get_offset_col(int offset); * Public Kernel API functions * **********************************************************/ +void clear_screen() { + int screen_size = MAX_COLS * MAX_ROWS; + int i; + u8 *screen = (u8*) VIDEO_ADDRESS; + + for (i = 0; i < screen_size; i++) { + screen[i*2] = ' '; + screen[i*2+1] = WHITE_ON_BLACK; + } + set_cursor_offset(get_offset(0, 0)); +} + /** * Print a message on the specified location * If col, row, are negative, we will use the current offset @@ -131,18 +143,6 @@ void set_cursor_offset(int offset) { port_byte_out(REG_SCREEN_DATA, (u8)(offset & 0xff)); } -void clear_screen() { - int screen_size = MAX_COLS * MAX_ROWS; - int i; - u8 *screen = (u8*) VIDEO_ADDRESS; - - for (i = 0; i < screen_size; i++) { - screen[i*2] = ' '; - screen[i*2+1] = WHITE_ON_BLACK; - } - set_cursor_offset(get_offset(0, 0)); -} - int get_offset(int col, int row) { return 2 * (row * MAX_COLS + col); } int get_offset_row(int offset) { return offset / (2 * MAX_COLS); } diff --git a/22-malloc/drivers/screen.c b/22-malloc/drivers/screen.c index e955688..890b4a9 100644 --- a/22-malloc/drivers/screen.c +++ b/22-malloc/drivers/screen.c @@ -14,6 +14,18 @@ int get_offset_col(int offset); * Public Kernel API functions * **********************************************************/ +void clear_screen() { + int screen_size = MAX_COLS * MAX_ROWS; + int i; + u8 *screen = (u8*) VIDEO_ADDRESS; + + for (i = 0; i < screen_size; i++) { + screen[i*2] = ' '; + screen[i*2+1] = WHITE_ON_BLACK; + } + set_cursor_offset(get_offset(0, 0)); +} + /** * Print a message on the specified location * If col, row, are negative, we will use the current offset @@ -131,18 +143,6 @@ void set_cursor_offset(int offset) { port_byte_out(REG_SCREEN_DATA, (u8)(offset & 0xff)); } -void clear_screen() { - int screen_size = MAX_COLS * MAX_ROWS; - int i; - u8 *screen = (u8*) VIDEO_ADDRESS; - - for (i = 0; i < screen_size; i++) { - screen[i*2] = ' '; - screen[i*2+1] = WHITE_ON_BLACK; - } - set_cursor_offset(get_offset(0, 0)); -} - int get_offset(int col, int row) { return 2 * (row * MAX_COLS + col); } int get_offset_row(int offset) { return offset / (2 * MAX_COLS); } diff --git a/23-fixes/drivers/screen.c b/23-fixes/drivers/screen.c index 1aed626..8f4226e 100644 --- a/23-fixes/drivers/screen.c +++ b/23-fixes/drivers/screen.c @@ -15,6 +15,18 @@ int get_offset_col(int offset); * Public Kernel API functions * **********************************************************/ +void clear_screen() { + int screen_size = MAX_COLS * MAX_ROWS; + int i; + uint8_t *screen = (uint8_t*) VIDEO_ADDRESS; + + for (i = 0; i < screen_size; i++) { + screen[i*2] = ' '; + screen[i*2+1] = WHITE_ON_BLACK; + } + set_cursor_offset(get_offset(0, 0)); +} + /** * Print a message on the specified location * If col, row, are negative, we will use the current offset @@ -132,18 +144,6 @@ void set_cursor_offset(int offset) { port_byte_out(REG_SCREEN_DATA, (uint8_t)(offset & 0xff)); } -void clear_screen() { - int screen_size = MAX_COLS * MAX_ROWS; - int i; - uint8_t *screen = (uint8_t*) VIDEO_ADDRESS; - - for (i = 0; i < screen_size; i++) { - screen[i*2] = ' '; - screen[i*2+1] = WHITE_ON_BLACK; - } - set_cursor_offset(get_offset(0, 0)); -} - int get_offset(int col, int row) { return 2 * (row * MAX_COLS + col); } int get_offset_row(int offset) { return offset / (2 * MAX_COLS); }