Skip to content
This repository has been archived by the owner on Sep 19, 2022. It is now read-only.

Commit

Permalink
fixed stuff, added doc
Browse files Browse the repository at this point in the history
  • Loading branch information
specialfish9 committed Apr 14, 2022
1 parent f314d97 commit 9d1e3ae
Show file tree
Hide file tree
Showing 12 changed files with 631 additions and 256 deletions.
519 changes: 519 additions & 0 deletions Doxyfile

Large diffs are not rendered by default.

15 changes: 14 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ UMPS3_INCLUDE_DIR = $(UMPS3_DIR_PREFIX)/include
SRC_PATH := src
OBJ_PATH := obj
OUT_PATH := output
DOC_PATH := doc

HEADERS := $(foreach x, $(SRC_PATH), $(wildcard $(addprefix $(x)/*,.h)))
SOURCES := $(foreach x, $(SRC_PATH), $(wildcard $(addprefix $(x)/*,.c)))
OBJS := $(addsuffix .o, $(notdir $(basename $(SOURCES))))

CLEAN_LIST := $(OUT_PATH)/* \
$(OBJ_PATH)/* \
$(DOC_PATH)/* \

CFLAGS = -ffreestanding -ansi -Wall -c -mips1 -mabi=32 -mfp32 \
-mno-gpopt -G 0 -fno-pic -mno-abicalls -EL -std=gnu99
Expand All @@ -33,7 +35,7 @@ KERNEL_NAME = ROCM_kernel
DISK_NAME = disk0

#main target
all: figlet kernel.core.umps disk0.umps
all: figlet kernel.core.umps disk0.umps docs
@echo -e "Done :D"

# use umps3-mkdev to create the disk0 device
Expand Down Expand Up @@ -74,6 +76,17 @@ clean:
@echo -e "Cleaning project structure..."
@rm -rf $(CLEAN_LIST)

docs:
@echo -e "*** DOCUMENTATION ***"
@echo -e "Creating documentation..."
@doxygen
@echo -e "Done"
@echo -e "Building pdf"
@make -C doc/latex
@echo -e "Done"
@cp doc/latex/refman.pdf doc/
@echo -e "Outputs in doc folder"

figlet:
@echo -e "\e[0;32moooooooooo ooooooo oooooooo8 oooo oooo "
@echo -e "\e[0;32m 888 888 o888 888o o888 88 8888o 888 "
Expand Down
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@

### Dependences:
1. [umps3](https://github.com/virtualsquare/umps3)
2. __cmake-format__ for formatting the code
2. __cmake-format__ to format code
3. __doxygen__ to generate documentation

### Usage:

Build kernel and create disk image with:
Build kernel, create disk image and documentation with:
```
make all
```
Expand All @@ -16,6 +17,7 @@ or just simply:
make
```
_Note:_ Generated outputs file are stored in __output__ dir.
_Note:_ Generated documentation file are stored in __doc__ dir.

You must then create a machine in the umps3 emulator, using generated files in
your configuration.
Expand All @@ -37,6 +39,12 @@ Format code with:
make format
```

Generate documentation with:
```
make docs
```





Expand Down
169 changes: 0 additions & 169 deletions doc/klog/klog.md

This file was deleted.

Binary file removed doc/klog/klog.png
Binary file not shown.
49 changes: 21 additions & 28 deletions src/exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,6 @@ inline static int create_process(state_t *statep, int prio,

// static void termniate_process(int pid);

/**
Esegue un'operazione P sul semaforo binario.
@param semaddr: puntatore al semaforo.
*/
inline static void passeren(int *semaddr);

/**
Esegue un'operazione V sul semaforo binario.
@param semaddr: puntatore al semaforo.
*/
inline static void verhogen(int *semaddr);

// static int do_io(int *cmd_addr, int cmd_val);

// static int get_cpu_time(void);
Expand Down Expand Up @@ -207,7 +195,7 @@ static int create_process(state_t *statep, int prio, support_t *supportp)
return new_proc->p_pid;
}

void passeren(int *semaddr)
inline void passeren(int *semaddr)
{
/* TODO: forse va modificato il campo p_s->state del pcb per fare lo switch
* tra running e blocked*/
Expand All @@ -233,12 +221,13 @@ void passeren(int *semaddr)
}
}

static void verhogen(int *semaddr)
inline pcb_t *verhogen(int *semaddr)
{
/* Se il valore del semaforo è 0 sblocco il processo, se è 1 lo blocco */
pcb_t *tmp;

if (*semaddr == 1) {
tmp =act_proc;
tmp = act_proc;
// Controlli per bloccare il processo
if (insert_blocked(semaddr, tmp)) {
/* Se ritorna true non possiamo assegnare un semaforo */
Expand All @@ -254,19 +243,21 @@ static void verhogen(int *semaddr)
} else {
*semaddr = 1;
}

return tmp;
}

static void wait_for_clock(void)
{
/* blocco il processo attivo sul semaforo */
insert_blocked((int *)dev_sem[ITINT], act_proc); /* TODO: usare sem_it da interrupts */
insert_blocked(&sem_it, act_proc);
pcb_t *tmp = act_proc;

/*blocco il processo sul semaforo ricevuto come parametro*/
int *dev_sem= get_dev_sem(TIMER_SEM_INDEX);
int *dev_sem = get_dev_sem(TIMER_SEM_INDEX);
insert_blocked(dev_sem, tmp);
tmp = NULL;


*dev_sem = 1;
// TODO scheduler_next()
}
Expand All @@ -280,17 +271,19 @@ static void kill_parent_and_progeny(pcb_t *p)
kill_proc(p);
}


//Trova l'indice che identifica il device a partire dall'indirizzo del suo command register
//Se non si usa esternamente posso non metterla nel .h giusto?
int get_ind_from_cmd(unsigned int cmd_addr){
int index = ((cmd_addr-DEV_REG_START)/DEV_REG_SIZE);
//Se l'offset del registro cmd è 4 possiamo restituire direttamente l'indice calcolato
if( (cmd_addr-DEV_REG_START)%DEV_REG_SIZE==0x4)
// Trova l'indice che identifica il device a partire dall'indirizzo del suo
// command register Se non si usa esternamente posso non metterla nel .h giusto?
int get_ind_from_cmd(unsigned int cmd_addr)
{
int index = ((cmd_addr - DEV_REG_START) / DEV_REG_SIZE);
// Se l'offset del registro cmd è 4 possiamo restituire direttamente l'indice
// calcolato
if ((cmd_addr - DEV_REG_START) % DEV_REG_SIZE == 0x4)
return index;
//Altrimenti se è 0xc stiamo esaminando un sub device di trasmissione di un terminale, e quindi andiamo alla categoria successiva di device (+8)
else if( index>32 && (cmd_addr-DEV_REG_START)%DEV_REG_SIZE==0xc)
return index+DEVPERINT;
// Altrimenti se è 0xc stiamo esaminando un sub device di trasmissione di un
// terminale, e quindi andiamo alla categoria successiva di device (+8)
else if (index > 32 && (cmd_addr - DEV_REG_START) % DEV_REG_SIZE == 0xc)
return index + DEVPERINT;
else
PANIC();
return -1;
Expand Down
11 changes: 11 additions & 0 deletions src/exceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,16 @@
extern int handle_syscall(void);
extern int passup_or_die(size_tt kind);
extern int get_ind_from_cmd(unsigned int);
/**
Esegue un'operazione P sul semaforo binario.
@param semaddr: puntatore al semaforo.
*/
extern void passeren(int *semaddr);

/**
Esegue un'operazione V sul semaforo binario.
@param semaddr: puntatore al semaforo.
*/
extern pcb_t *verhogen(int *semaddr);

#endif
Loading

0 comments on commit 9d1e3ae

Please sign in to comment.