Skip to content

Commit

Permalink
Pseudo Random number generation update
Browse files Browse the repository at this point in the history
Issue: #236
  • Loading branch information
shubhangi47 committed Jan 3, 2024
1 parent e725432 commit 66f7eb9
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"editor.trimAutoWhitespace": true,
"editor.autoClosingQuotes": "always",
"editor.autoClosingBrackets": "always",
"editor.wordBasedSuggestions": true,
"editor.wordBasedSuggestions": "matchingDocuments",
"editor.insertSpaces": false,
"editor.autoIndent": "advanced",
"editor.detectIndentation": true,
Expand Down
11 changes: 11 additions & 0 deletions src/arch/riscv/32/i/terravisor/arch.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <lock/lock.h>
#include <visor/workers.h>
#include <interrupt.h>
#include <rand.h>

static void arch_vcall_handler()
{
Expand Down Expand Up @@ -160,3 +161,13 @@ _WEAK void arch_unhandled_irq()
while(1)
arch_wfi();
}
/**
* arch_rseed_capture
*
* @brief This function is intended to capture unique seed value
*/
void arch_rseed_capture()
{
extern uintptr_t *_bss_start;
srand(*_bss_start);
}
1 change: 1 addition & 0 deletions src/arch/riscv/32/i/terravisor/include/arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,4 @@ static inline void arch_dmb()
bool arch_suspended_state_was(cpu_sleep_t);
void arch_signal_suspend(cpu_sleep_t);
void arch_signal_resume(void);
void arch_rseed_capture();
3 changes: 2 additions & 1 deletion src/arch/riscv/32/i/terravisor/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ void _NAKED init()
{
arch_di();
asm volatile("la tp, _tls_start");
/* Capture unique seed value before memory initialization */
arch_rseed_capture();
/* Boot framework */

#if CCSMP == 0
engine();
#else
Expand Down
6 changes: 4 additions & 2 deletions src/platform/sifive/common_fe310/platform/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <stdint.h>
#include <status.h>
#include <stdlib.h>
#include <rand.h>
#include <arch.h>
#include <driver.h>
#include <syslog.h>
Expand All @@ -20,15 +21,17 @@
#include <visor/workers.h>
#include <platform.h>


void platform_early_setup()
{
status_t ret = success;

unsigned int temp_randomnumber = rand();
ret |= platform_copy_data();
ret |= platform_copy_itim();
ret |= platform_bss_clear();
ret |= platform_init_heap();
ret |= platform_resources_setup();
srand(temp_randomnumber);
syslog_stdout_disable();
driver_setup("mslog");

Expand Down Expand Up @@ -110,4 +113,3 @@ void platform_cpu_setup()
arch_ei();
return;
}

0 comments on commit 66f7eb9

Please sign in to comment.