Skip to content

Commit

Permalink
+ SHIFT_AS_DIV
Browse files Browse the repository at this point in the history
  • Loading branch information
DnCraptor committed Jun 23, 2024
1 parent 818db7e commit 3b87ec4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ram_page.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ static uint16_t last_ram_page = 0;
static uint32_t last_lba_page = 0;

uint32_t get_ram_page_for(const uint32_t addr32) {
const register uint32_t lba_page = addr32 / RAM_PAGE_SIZE; // 4KB page idx
const register uint32_t lba_page = addr32 >> SHIFT_AS_DIV; // page idx
if (last_lba_page == lba_page) {
return last_ram_page;
}
Expand Down
3 changes: 3 additions & 0 deletions src/ram_page.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,19 @@
#ifdef SWAP_BLOCK_1k
#define RAM_PAGE_SIZE_KB 1ul
#define RAM_IN_PAGE_ADDR_MASK (0x000003FF)
#define SHIFT_AS_DIV 10
#endif
// --- select only one of 'em
#ifdef SWAP_BLOCK_2k
#define RAM_PAGE_SIZE_KB 2ul
#define RAM_IN_PAGE_ADDR_MASK (0x000007FF)
#define SHIFT_AS_DIV 11
#endif
// --- select only one of 'em
#ifdef SWAP_BLOCK_4k
#define RAM_PAGE_SIZE_KB 4ul
#define RAM_IN_PAGE_ADDR_MASK (0x00000FFF)
#define SHIFT_AS_DIV 12
#endif
// --- select only one of 'em ^

Expand Down

0 comments on commit 3b87ec4

Please sign in to comment.