- Timestamp:
- Jun 28, 2017, 2:20:29 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hal/x86_64/core/x86_printf.c
r51 r84 35 35 36 36 #define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) 37 #define CONS_X_SIZE 160 38 #define CONS_Y_SIZE 80 39 37 #define CONS_X_SIZE 80 38 #define CONS_Y_SIZE 26 39 40 static char cons_buffer[CONS_X_SIZE * 2 * CONS_Y_SIZE] __in_kdata; 40 41 extern intptr_t iom_base; 41 42 size_t cons_ptr __in_kdata = 0; … … 49 50 } 50 51 52 static void check_scroll() 53 { 54 char *base = (uint64_t)iom_base + (0xB8000 - IOM_BEGIN); 55 char *src, *dst; 56 size_t i; 57 58 if (cons_ptr < (CONS_X_SIZE * 2) * CONS_Y_SIZE) { 59 return; 60 } 61 62 for (i = 0; i < CONS_Y_SIZE - 1; i++) { 63 dst = (char *)&cons_buffer[0] + i * (CONS_X_SIZE * 2); 64 src = (char *)&cons_buffer[0] + (i + 1) * (CONS_X_SIZE * 2); 65 66 memcpy(dst, src, (CONS_X_SIZE * 2)); 67 } 68 69 memset(base, 0, CONS_X_SIZE * 2 * CONS_Y_SIZE); 70 71 cons_ptr -= (CONS_X_SIZE * 2); 72 memcpy(base, &cons_buffer[0], (CONS_X_SIZE * 2) * (CONS_Y_SIZE - 1)); 73 } 74 51 75 static void x86_putc(char c) 52 76 { 53 77 if (c == '\n') { 54 cons_ptr = roundup(cons_ptr, CONS_X_SIZE); 78 cons_ptr = roundup(cons_ptr, CONS_X_SIZE * 2); 79 check_scroll(); 55 80 return; 56 81 } 57 82 58 83 char *video = (char *)iom_base + (0xB8000 - IOM_BEGIN) + cons_ptr; 84 char *buf = &cons_buffer[cons_ptr]; 59 85 *video = c; 60 cons_ptr++, video++; 86 *buf = c; 87 cons_ptr++, video++, buf++; 61 88 *video = 0x7; 62 cons_ptr++, video++; 89 *buf = 0x7; 90 cons_ptr++, video++, buf++; 91 92 check_scroll(); 63 93 } 64 94
Note: See TracChangeset
for help on using the changeset viewer.