Skip to content

Commit

Permalink
add missing Softswitch files
Browse files Browse the repository at this point in the history
  • Loading branch information
heliosfa committed Oct 25, 2021
1 parent 291e669 commit 9668721
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Source/Softswitch/inc/softswitch_vars.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#ifndef _VARS_H_
#define _VARS_H_
#include <cstdint>
#include "softswitch_common.h"

extern ThreadCtxt_t Thread_0_Context;
extern ThreadCtxt_t Thread_1_Context;
extern ThreadCtxt_t Thread_2_Context;
extern ThreadCtxt_t Thread_3_Context;
extern ThreadCtxt_t Thread_4_Context;
extern ThreadCtxt_t Thread_5_Context;
extern ThreadCtxt_t Thread_6_Context;
extern ThreadCtxt_t Thread_7_Context;
extern ThreadCtxt_t Thread_8_Context;
extern ThreadCtxt_t Thread_9_Context;
extern ThreadCtxt_t Thread_10_Context;
extern ThreadCtxt_t Thread_11_Context;
extern ThreadCtxt_t Thread_12_Context;
extern ThreadCtxt_t Thread_13_Context;
extern ThreadCtxt_t Thread_14_Context;
extern ThreadCtxt_t Thread_15_Context;

#endif /*_VARS_H_*/
9 changes: 9 additions & 0 deletions Source/Softswitch/src/dummy.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "tinsel.h"

int main(int argc, char** argv)
{
// Block on tinselIdle to facilitate hardware idle.
while(true) tinselIdle(1);

return 0;
}
20 changes: 20 additions & 0 deletions Source/Softswitch/src/softswitch_vars.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

#include "softswitch_common.h"
#include "softswitch_vars.h"

ThreadCtxt_t Thread_0_Context __attribute__((weak, section (".thr0_base"))) = {0,PNULL,0,PNULL,PNULL,0,PNULL,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
ThreadCtxt_t Thread_1_Context __attribute__((weak, section (".thr1_base"))) = {0,PNULL,0,PNULL,PNULL,0,PNULL,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
ThreadCtxt_t Thread_2_Context __attribute__((weak, section (".thr2_base"))) = {0,PNULL,0,PNULL,PNULL,0,PNULL,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
ThreadCtxt_t Thread_3_Context __attribute__((weak, section (".thr3_base"))) = {0,PNULL,0,PNULL,PNULL,0,PNULL,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
ThreadCtxt_t Thread_4_Context __attribute__((weak, section (".thr4_base"))) = {0,PNULL,0,PNULL,PNULL,0,PNULL,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
ThreadCtxt_t Thread_5_Context __attribute__((weak, section (".thr5_base"))) = {0,PNULL,0,PNULL,PNULL,0,PNULL,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
ThreadCtxt_t Thread_6_Context __attribute__((weak, section (".thr6_base"))) = {0,PNULL,0,PNULL,PNULL,0,PNULL,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
ThreadCtxt_t Thread_7_Context __attribute__((weak, section (".thr7_base"))) = {0,PNULL,0,PNULL,PNULL,0,PNULL,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
ThreadCtxt_t Thread_8_Context __attribute__((weak, section (".thr8_base"))) = {0,PNULL,0,PNULL,PNULL,0,PNULL,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
ThreadCtxt_t Thread_9_Context __attribute__((weak, section (".thr9_base"))) = {0,PNULL,0,PNULL,PNULL,0,PNULL,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
ThreadCtxt_t Thread_10_Context __attribute__((weak, section (".thr10_base"))) = {0,PNULL,0,PNULL,PNULL,0,PNULL,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
ThreadCtxt_t Thread_11_Context __attribute__((weak, section (".thr11_base"))) = {0,PNULL,0,PNULL,PNULL,0,PNULL,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
ThreadCtxt_t Thread_12_Context __attribute__((weak, section (".thr12_base"))) = {0,PNULL,0,PNULL,PNULL,0,PNULL,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
ThreadCtxt_t Thread_13_Context __attribute__((weak, section (".thr13_base"))) = {0,PNULL,0,PNULL,PNULL,0,PNULL,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
ThreadCtxt_t Thread_14_Context __attribute__((weak, section (".thr14_base"))) = {0,PNULL,0,PNULL,PNULL,0,PNULL,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
ThreadCtxt_t Thread_15_Context __attribute__((weak, section (".thr15_base"))) = {0,PNULL,0,PNULL,PNULL,0,PNULL,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
70 changes: 70 additions & 0 deletions Source/Softswitch/src/threadCtxInitGenerator.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#include "config.h"

#include <string>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>


// Number of bytes per thread partition 2^21 = 2,097,152
uint32_t BytesPerDRAMPartition=1<<TinselLogBytesPerDRAMPartition;

// The number of cores that share a DRAM 2^(2+3) = 32
uint32_t CoresPerDRAM=1<<(TinselLogCoresPerDCache+TinselLogDCachesPerDRAM);

// The number of threads per DRAM 32*16 = 512
uint32_t ThreadsPerDRAM=CoresPerDRAM*TinselThreadsPerCore;

uint32_t InterleavedPartitionOffset=0x80000000;

int main(void)
{
// The output binary
std::ofstream dataBin;

dataBin.open("threadCtxInit_data.v");
if(dataBin.fail()) // Check that the file opened
{ // if it didn't, barf
std::cout << "***ERROR*** FAILED TO OPEN DATA BINARY\n" << std::endl;
return -1;
}

// Populate the bin
uint32_t i = 0;
for(int coreNum = 0; coreNum<CoresPerDRAM; coreNum++)
{
for(int threadNum = 1; threadNum<=TinselThreadsPerCore; threadNum++)
{
uint32_t threadAddr, threadOffset;

threadOffset = ((coreNum << TinselLogThreadsPerCore) + threadNum);
threadOffset *= BytesPerDRAMPartition;

threadAddr = TinselBytesPerDRAM - threadOffset;

threadAddr |= InterleavedPartitionOffset;

// Write the address
dataBin << std::hex << std::uppercase << "@" << threadAddr << "\n";

// Write out the initialiser
dataBin << "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \n";
dataBin << "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \n";
dataBin << "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \n";
dataBin << "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \n";
dataBin << "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \n";
dataBin << "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \n";
dataBin << "00 00 00 00 00 00 00 00 " << std::endl;

i++;
}
}

// And we are done
dataBin.close();

return 0;
}

0 comments on commit 9668721

Please sign in to comment.