Skip to content

Commit

Permalink
sw: Add LLC functions
Browse files Browse the repository at this point in the history
  • Loading branch information
CyrilKoe committed Jan 5, 2025
1 parent 04c05a8 commit ffdc3e2
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
13 changes: 13 additions & 0 deletions sw/include/dif/axi_llc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright 2022 ETH Zurich and University of Bologna.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
//
// Cyril Koenig <[email protected]>

#pragma once

void llc_enable();

void llc_flush();

void llc_disable();
37 changes: 37 additions & 0 deletions sw/lib/dif/llc.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright 2022 ETH Zurich and University of Bologna.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
//
// Cyril Koenig <[email protected]>

#include "dif/axi_llc.h"
#include "regs/axi_llc.h"
#include "util.h"
#include "params.h"

void llc_enable() {
*reg32(&__base_llc, AXI_LLC_CFG_SPM_LOW_REG_OFFSET ) = 0x00000000;
*reg32(&__base_llc, AXI_LLC_CFG_SPM_HIGH_REG_OFFSET) = 0x00000000;
fence();
*reg32(&__base_llc, AXI_LLC_COMMIT_CFG_REG_OFFSET) = 0x1;
fence();
}

void llc_flush() {
*reg32(&__base_llc, AXI_LLC_CFG_FLUSH_LOW_REG_OFFSET ) = 0xffffffff;
*reg32(&__base_llc, AXI_LLC_CFG_FLUSH_HIGH_REG_OFFSET) = 0xffffffff;
fence();
*reg32(&__base_llc, AXI_LLC_COMMIT_CFG_REG_OFFSET) = 0x1;
fence();
while(*reg32(&__base_llc, AXI_LLC_COMMIT_CFG_REG_OFFSET) != 0);
}

void llc_disable() {
*reg32(&__base_llc, AXI_LLC_CFG_SPM_LOW_REG_OFFSET ) = 0xffffffff;
*reg32(&__base_llc, AXI_LLC_CFG_SPM_HIGH_REG_OFFSET) = 0xffffffff;
*reg32(&__base_llc, AXI_LLC_CFG_FLUSH_LOW_REG_OFFSET ) = 0xffffffff;
*reg32(&__base_llc, AXI_LLC_CFG_FLUSH_HIGH_REG_OFFSET) = 0xffffffff;
fence();
*reg32(&__base_llc, AXI_LLC_COMMIT_CFG_REG_OFFSET) = 0x1;
fence();
}

0 comments on commit ffdc3e2

Please sign in to comment.