-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move peripherals to devices directory
- modify Makefile to enable detect devices directory - decouple PLIC and UART into separate files - Bind RISC-V core to plic_t to enable sending interrupt from PLIC to core
- Loading branch information
1 parent
cfb3c3a
commit ee008f1
Showing
12 changed files
with
150 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* rv32emu is freely redistributable under the MIT License. See the file | ||
* "LICENSE" for information on usage and redistribution of this file. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <stdint.h> | ||
|
||
/* PLIC */ | ||
typedef struct { | ||
uint32_t masked; | ||
uint32_t ip; | ||
uint32_t ie; | ||
/* state of input interrupt lines (level-triggered), set by environment */ | ||
uint32_t active; | ||
/* RISC-V instance to receive PLIC interrupt */ | ||
void *rv; | ||
} plic_t; | ||
|
||
/* update PLIC status */ | ||
void plic_update_interrupts(plic_t *plic); | ||
|
||
/* read a word from PLIC */ | ||
uint32_t plic_read(plic_t *plic, const uint32_t addr); | ||
|
||
/* write a word to PLIC */ | ||
void plic_write(plic_t *plic, const uint32_t addr, uint32_t value); | ||
|
||
/* create a PLIC instance */ | ||
plic_t *plic_new(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* rv32emu is freely redistributable under the MIT License. See the file | ||
* "LICENSE" for information on usage and redistribution of this file. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <stdbool.h> | ||
#include <stdint.h> | ||
|
||
#define IRQ_UART 1 | ||
#define IRQ_UART_BIT (1 << IRQ_UART) | ||
|
||
typedef struct { | ||
uint8_t dll, dlh; /* divisor (ignored) */ | ||
uint8_t lcr; /* UART config */ | ||
uint8_t ier; /* interrupt config */ | ||
uint8_t current_int, pending_ints; /* interrupt status */ | ||
uint8_t mcr; /* other output signals, loopback mode (ignored) */ | ||
int in_fd, out_fd; /* I/O handling */ | ||
bool in_ready; | ||
} u8250_state_t; | ||
|
||
/* update UART status */ | ||
void u8250_update_interrupts(u8250_state_t *uart); | ||
|
||
/* poll UART status */ | ||
void u8250_check_ready(u8250_state_t *uart); | ||
|
||
/* read a word from UART */ | ||
uint32_t u8250_read(u8250_state_t *uart, uint32_t addr); | ||
|
||
/* write a word to UART */ | ||
void u8250_write(u8250_state_t *uart, uint32_t addr, uint32_t value); | ||
|
||
/* create a UART instance */ | ||
u8250_state_t *u8250_new(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters