xinyangli
8e4feb4010
NJU-ProjectN/abstract-machine 3348db971fd860be5cb28e21c18f9d0e65d0c96a Merge pull request #8 from Jasonyanyusong/master
24 lines
933 B
C
24 lines
933 B
C
#ifndef LOONGARCH32R_H__
|
|
#define LOONGARCH32R_H__
|
|
|
|
#include <stdint.h>
|
|
|
|
static inline uint8_t inb(uintptr_t addr) { return *(volatile uint8_t *)addr; }
|
|
static inline uint16_t inw(uintptr_t addr) { return *(volatile uint16_t *)addr; }
|
|
static inline uint32_t inl(uintptr_t addr) { return *(volatile uint32_t *)addr; }
|
|
|
|
static inline void outb(uintptr_t addr, uint8_t data) { *(volatile uint8_t *)addr = data; }
|
|
static inline void outw(uintptr_t addr, uint16_t data) { *(volatile uint16_t *)addr = data; }
|
|
static inline void outl(uintptr_t addr, uint32_t data) { *(volatile uint32_t *)addr = data; }
|
|
|
|
#define PTE_V 0x1
|
|
#define PTE_D 0x2
|
|
|
|
// Page directory and page table constants
|
|
#define PTXSHFT 12 // Offset of PTX in a linear address
|
|
#define PDXSHFT 22 // Offset of PDX in a linear address
|
|
|
|
#define PDX(va) (((uint32_t)(va) >> PDXSHFT) & 0x3ff)
|
|
#define PTX(va) (((uint32_t)(va) >> PTXSHFT) & 0x3ff)
|
|
|
|
#endif
|