Skip to content

Commit

Permalink
Remove print.h
Browse files Browse the repository at this point in the history
  • Loading branch information
yhzhang0128 committed Mar 30, 2022
1 parent 4b5a6b3 commit 47b18cf
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 39 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ all: apps
$(RISCV_CC) $(CFLAGS) $(LDFLAGS) $(GRASS_LAYOUT) $(GRASS_SRCS) $(DEFAULT_LDLIBS) $(INCLUDE) -o $(RELEASE_DIR)/grass.elf
$(OBJDUMP) --source --all-headers --demangle --line-numbers --wide $(RELEASE_DIR)/grass.elf > $(DEBUG_DIR)/grass.lst
@echo "$(YELLOW)-------- Compile the Earth Layer --------$(END)"
$(RISCV_CC) $(CFLAGS) $(LDFLAGS) $(EARTH_LAYOUT) $(EARTH_SRCS) $(EARTH_LDLIBS) $(INCLUDE) -Iearth/bus -o $(RELEASE_DIR)/earth.elf
$(RISCV_CC) $(CFLAGS) $(LDFLAGS) $(EARTH_LAYOUT) $(EARTH_SRCS) $(EARTH_LDLIBS) $(INCLUDE) -Iearth/bus -DEARTH -o $(RELEASE_DIR)/earth.elf
$(OBJDUMP) --source --all-headers --demangle --line-numbers --wide $(RELEASE_DIR)/earth.elf > $(DEBUG_DIR)/earth.lst

.PHONY: apps
Expand Down
1 change: 0 additions & 1 deletion apps/app.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once

#include "egos.h"
#include "print.h"
#include "memory.h"
#include "syscall.h"
#include "servers.h"
Expand Down
32 changes: 13 additions & 19 deletions earth/earth.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,29 @@
*/


#include "egos.h"
#include "earth.h"

int earth_init();
void earth_init();
void grass_load();
struct earth *earth = (void*)EARTH_STRUCT;

int main() {
INFO("-----------------------------------");
INFO("Start to initialize the earth layer");

if (earth_init())
FATAL("Failed at initializing the earth layer");

INFO("Start to load the grass layer");
earth_init();
grass_load();

return 0;
}

int earth_init() {
/* Initialize TTY */
void earth_init() {
/* Initialize the print functions */
earth->tty_info = tty_info;
earth->tty_fatal = tty_fatal;
earth->tty_success = tty_success;
earth->tty_highlight = tty_highlight;
INFO("-----------------------------------");
INFO("Start to initialize the earth layer");

/* Initialize tty */
tty_init();
earth->tty_intr = tty_intr;
earth->tty_read = tty_read;
Expand Down Expand Up @@ -58,21 +59,14 @@ int earth_init() {
earth->mmu_map = mmu_map;
earth->mmu_switch = mmu_switch;
SUCCESS("Finished initializing the CPU memory management unit");

/* Initialize the logging functions */
earth->tty_info = tty_info;
earth->tty_fatal = tty_fatal;
earth->tty_success = tty_success;
earth->tty_highlight = tty_highlight;

return 0;
}

static int grass_read(int block_no, char* dst) {
return earth->disk_read(GRASS_EXEC_START + block_no, 1, dst);
}

void grass_load() {
INFO("Start to load the grass layer");
elf_load(0, grass_read, 0, NULL);

/* call the grass kernel entry and never return */
Expand Down
6 changes: 1 addition & 5 deletions earth/earth.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <stdarg.h>
#include <string.h>

#include "egos.h"
#include "elf.h"
#include "disk.h"
#include "memory.h"
Expand Down Expand Up @@ -35,8 +36,3 @@ int tty_info(const char *format, ...);
int tty_highlight(const char *format, ...);
int tty_success(const char *format, ...);
int tty_fatal(const char *format, ...);

#define INFO tty_info
#define HIGHLIGHT tty_highlight
#define SUCCESS tty_success
#define FATAL tty_fatal
1 change: 0 additions & 1 deletion grass/grass.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#include "elf.h"
#include "disk.h"
#include "print.h"
#include "memory.h"
#include "syscall.h"
#include "servers.h"
Expand Down
10 changes: 10 additions & 0 deletions library/egos.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,13 @@ struct grass {
char work_dir[32 * 16];
char work_dir_name[32];
};

extern struct earth *earth;

#define INFO earth->tty_info
#define FATAL earth->tty_fatal
#define SUCCESS earth->tty_success
#define HIGHLIGHT earth->tty_highlight
#ifndef EARTH
#define printf earth->tty_write
#endif
1 change: 0 additions & 1 deletion library/file/disk.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "egos.h"
#include "disk.h"
#include "print.h"
#include "block_store.h"

static int disk_getsize(block_if this_bs, unsigned int ino){
Expand Down
5 changes: 4 additions & 1 deletion library/file/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@
#include <string.h>
#include "file.h"

#ifdef EARTH
#define printf HIGHLIGHT
#endif

#ifdef MKFS
#include <stdio.h>
#define HIGHLIGHT printf
#else
#include "egos.h"
#include "print.h"
#include "memory.h"
#endif

Expand Down
1 change: 0 additions & 1 deletion library/syscall/servers.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include <string.h>

#include "egos.h"
#include "print.h"
#include "syscall.h"
#include "servers.h"

Expand Down
1 change: 0 additions & 1 deletion library/utils/elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "egos.h"
#include "elf.h"
#include "disk.h"
#include "print.h"
#include "memory.h"
#include "servers.h"

Expand Down
8 changes: 0 additions & 8 deletions library/utils/print.h

This file was deleted.

0 comments on commit 47b18cf

Please sign in to comment.