Ver Fonte

5.063u-graphic: using more colors

rain há 5 anos atrás
pai
commit
13ff17a953
5 ficheiros alterados com 31 adições e 2 exclusões
  1. 1 0
      LINES
  2. 4 0
      README.md
  3. 10 1
      include/kernel/graphic.h
  4. 8 1
      include/kernel/init.h
  5. 8 0
      init/main.c

+ 1 - 0
LINES

@@ -22,4 +22,5 @@
 2021-7-21 4.682: 4682 lines, 39 files, rain
 2021-7-21 5.011: 5011 lines, 41 files, rain
 2021-7-26 5.039: 5039 lines, 41 files, rain
+2021-7-28 5.063: 5063 lines, 41 files, rain
 

+ 4 - 0
README.md

@@ -93,3 +93,7 @@ source software, you can get its source code from <https://gitee.com/pengruiyang
 5.039u-sched:  
 &nbsp;&nbsp;&nbsp;&nbsp;write `do_fork()` again and do it easier (and also fixed a bug of kmalloc() - didn't be zero before used). default <br/>
 &nbsp;&nbsp;&nbsp;&nbsp;stack size is 64KB. 
+
+5.063u-graphic:  
+&nbsp;&nbsp;&nbsp;&nbsp;using more colors (very beautiful! ) :-)
+

+ 10 - 1
include/kernel/graphic.h

@@ -32,6 +32,15 @@
 
 #define TAB_SIZE  8
 
+#define rgb(r, g, b) ((b) + ((g) << 8) + ((r) << 16))
+
+#define black 0x00000000
+#define red     rgb(255, 0, 0)
+#define success rgb(114, 176, 161)
+#define error   rgb(244, 130, 100)
+#define yellow  rgb(0, 255, 255)
+#define green   rgb(0, 255, 0)
+#define white   rgb(255, 255, 255)
 
 void putblock(__uint32_t, int, int, int, int);
 void putc(char, __uint32_t, __uint32_t);
@@ -41,7 +50,7 @@ void syslog(const char *);
 
 
 /* 
- * we supports PSF format in XNIX. 
+ * we support PSF format in XNIX. 
  * in linux, PSF fonts are in /usr/share/kbd/consolefonts, and they are always compressed. 
  * */
 

+ 8 - 1
include/kernel/init.h

@@ -43,9 +43,16 @@
 /* slowest: schk will display function info in this mode */
 #define DEBUG_LEVEL		TEST_DEBUG_LEVEL
 
-#define trappoint() 			\
+#include <kernel/graphic.h>
+
+#define trappoint() \
 	printk(0x0000ff00, 0x00000000, "system runs at %s:%s.%d\n", __FILE__, __FUNCTION__, __LINE__);
 
+#define emerg(s, ...) printk(red, black, s, __VA_ARGS__)
+#define log(s, ...)   printk(green, black, s, __VA_ARGS__)
+#define warn(s, ...)  printk(yellow, black, s, __VA_ARGS__)
+#define mesg(s, ...)  printk(white, black, s, __VA_ARGS__)
+
 
 #include <kernel/types.h>
 #include <kernel/errno.h>

+ 8 - 0
init/main.c

@@ -59,6 +59,14 @@ struct bootarg *bootarg = (struct bootarg *) 0x7c00;
 int init(void) {
 	print(0x00ffffff, 0x00000000, "XNIX kernel is starting...\n");
 
+	emerg("emergency: %s %x\n", "test", 0xabcdef0123456789);
+	log("log: %s %x\n", "test", 0xabcdef0123456789);
+	warn("warn: %s %x\n", "test", 0xabcdef0123456789);
+	mesg("mesg: %s %x\n", "test", 0xabcdef0123456789);
+
+	print(success, black, "test for color success. \n");
+	print(error, black, "test for color black. \n");
+
 	int_init();
 	mm_init();