mirror of
https://github.com/openpower-cores/a2-code.git
synced 2026-01-12 00:22:44 +00:00
add ops test
This commit is contained in:
parent
23ea9c4c89
commit
71be3958af
10
c/ops/Makefile
Normal file
10
c/ops/Makefile
Normal file
@ -0,0 +1,10 @@
|
||||
.RECIPEPREFIX = !
|
||||
CC = gcc
|
||||
CFLAGS = -std=gnu99 -mno-vsx -nostdlib
|
||||
DEPS = ops.h ./a2lib/a2lib.h ./printf/printf.h
|
||||
|
||||
SRC = ops.c ./a2lib/a2lib.c ./printf/printf.c
|
||||
|
||||
ops: $(SRC) $(DEPS)
|
||||
! $(CC) $(CFLAGS) -I./a2lib -I./printf -o ops $(SRC) --entry main
|
||||
|
||||
78
c/ops/build
Executable file
78
c/ops/build
Executable file
@ -0,0 +1,78 @@
|
||||
#/usr/bin/bash
|
||||
|
||||
pgm="ops"
|
||||
dump1="$pgm.dmp"
|
||||
dump2="obj.dmp"
|
||||
|
||||
kimage=1 # 1=combine kernel and test in image
|
||||
smtflags=1 # 1/3/7/F
|
||||
freq=00000064 # 64=100MHz 32=50MHz
|
||||
|
||||
objdump -f $pgm # info
|
||||
|
||||
# get digits
|
||||
objdump -d $pgm > $dump1 # asm
|
||||
objdump -s $pgm > $dump2 # for parsing
|
||||
|
||||
# create image-test.dmp
|
||||
bin/imagedmp -f $dump2
|
||||
echo
|
||||
|
||||
# prepend boot code if using single mem image
|
||||
if [[ $kimage -eq 1 ]]; then
|
||||
cat asm/boot_prune.dmp image-test.dmp > image.dmp
|
||||
fn=kimage
|
||||
else
|
||||
cp image-test.dmp image.dmp
|
||||
fn=image
|
||||
fi
|
||||
|
||||
if [[ $kimage -eq 1 ]]; then
|
||||
main=`grep "<main>" $dump1`
|
||||
entry=`echo $main | cut -f 1 -d " " | cut -c 9-16`
|
||||
echo "Setting test entry points: 00000A94 00000AD4 00000B14 00000B54"
|
||||
echo "Setting to: $entry in image.dmp"
|
||||
|
||||
rep="s/00000A94 ......../00000A94 $entry/"
|
||||
sed -i -s "$rep" image.dmp
|
||||
rep="s/00000AD4 ......../00000AD4 $entry/"
|
||||
sed -i -s "$rep" image.dmp
|
||||
rep="s/00000B14 ......../00000B14 $entry/"
|
||||
sed -i -s "$rep" image.dmp
|
||||
rep="s/00000B54 ......../00000B54 $entry/"
|
||||
sed -i -s "$rep" image.dmp
|
||||
|
||||
echo "Setting SMT in flags: 00000A04"
|
||||
smt=`grep "00000A04 " image.dmp | cut -c 10-16`
|
||||
smt="$smt$smtflags"
|
||||
echo "Setting to: $smt in image.dmp"
|
||||
rep="s/00000A04 ......../00000A04 $smt/"
|
||||
sed -i -s "$rep" image.dmp
|
||||
|
||||
echo "Setting freq: 00000A10"
|
||||
echo "Setting to: $freq in image.dmp"
|
||||
rep="s/00000A10 ......../00000A10 $freq/"
|
||||
sed -i -s "$rep" image.dmp
|
||||
|
||||
#echo "FreeRTOS needs to run privileged..."
|
||||
#uMSR=8002B000
|
||||
#echo " 00000A80 00000AC0 00000B00 00000B40"
|
||||
#echo "Setting to: $uMSR in image.dmp"
|
||||
#
|
||||
#rep="s/00000A80 ......../00000A80 $uMSR/"
|
||||
#sed -i -s "$rep" image.dmp
|
||||
#rep="s/00000AC0 ......../00000AC0 $uMSR/"
|
||||
#sed -i -s "$rep" image.dmp
|
||||
#rep="s/00000B00 ......../00000B00 $uMSR/"
|
||||
#sed -i -s "$rep" image.dmp
|
||||
#rep="s/00000B40 ......../00000B40 $uMSR/"
|
||||
#sed -i -s "$rep" image.dmp
|
||||
echo
|
||||
fi
|
||||
|
||||
echo "Created memory file image.dmp."
|
||||
echo
|
||||
|
||||
# create tcl script for fpga
|
||||
bin/dmp2tcl -f image.dmp -o "${fn}_${pgm}.tcl"
|
||||
|
||||
5
c/ops/compile
Executable file
5
c/ops/compile
Executable file
@ -0,0 +1,5 @@
|
||||
#/usr/bin/bash
|
||||
|
||||
pgm="ops"
|
||||
gcc -std=gnu99 -mno-vsx -nostdlib -I./a2lib -I./printf -o $pgm $pgm.c ./a2lib/a2lib.c ./printf/printf.c --entry main
|
||||
|
||||
100
c/ops/ops.c
Normal file
100
c/ops/ops.c
Normal file
@ -0,0 +1,100 @@
|
||||
// © IBM Corp. 2020
|
||||
// Licensed under and subject to the terms of the CC-BY 4.0
|
||||
// license (https://creativecommons.org/licenses/by/4.0/legalcode).
|
||||
// Additional rights, including the right to physically implement a softcore
|
||||
// that is compliant with the required sections of the Power ISA
|
||||
// Specification, will be available at no cost via the OpenPOWER Foundation.
|
||||
// This README will be updated with additional information when OpenPOWER's
|
||||
// license is available.
|
||||
|
||||
// test some a2lib calls
|
||||
|
||||
#include "ops.h"
|
||||
|
||||
uint64_t tick_start[4];
|
||||
uint64_t tick_stop[4];
|
||||
uint32_t ticks_per_sec;
|
||||
|
||||
#define LOOPS 1000000
|
||||
#define MSGFREQ 250000
|
||||
|
||||
int main(uint32_t t) {
|
||||
|
||||
int i = 0;
|
||||
int j = 1;
|
||||
uint32_t timer;
|
||||
|
||||
init();
|
||||
printf("[%010u] %sThread: parm says:%i whoami() says:%i\n", tick(), me(), t, whoami());
|
||||
ticks_per_sec = tickspersec() * 1000000;
|
||||
printf("[%010u] %sKernel reports frequency=%u\n", tick(), me(), ticks_per_sec);
|
||||
|
||||
start_time();
|
||||
while (i < LOOPS) {
|
||||
i++;
|
||||
j *= i;
|
||||
if (j == 0) {
|
||||
j = 1;
|
||||
}
|
||||
if ((i % MSGFREQ) == 0) {
|
||||
printf("[%010u] %s Iterations=%i\n", tick(), me(), i);
|
||||
}
|
||||
}
|
||||
|
||||
stop_time();
|
||||
timer = get_time();
|
||||
printf("\n[%010u] %sLoop done. Iterations=%i Res=%u Ticks=%u (%.6lf seconds).\n", tick(), me(), LOOPS, j, timer, ftime_in_secs(timer));
|
||||
|
||||
j = 0; // rc=0 is 'pass'
|
||||
printf("[%010u] T%i done. rc=%i\n", tick(), t, j);
|
||||
return j;
|
||||
}
|
||||
|
||||
char *me(void) {
|
||||
char *id[] = {
|
||||
"T0 [Inky].....",
|
||||
"T1 [Blinky]...",
|
||||
"T2 [Pinky]....",
|
||||
"T3 [Darrell].."
|
||||
};
|
||||
return id[whoami()];
|
||||
}
|
||||
|
||||
void init(void) {
|
||||
char *msg[] = {
|
||||
"kickstart my heart!",
|
||||
"poetry in motion...",
|
||||
"bring me to life...",
|
||||
"walk..............."
|
||||
};
|
||||
uint32_t t = whoami();
|
||||
|
||||
printf("[%010u] %s%s\n", tick(), me(), "You shouldn't see this!!!");
|
||||
printf_reset();
|
||||
|
||||
printf("[%010u] %s%s\n", tick(), me(), msg[t]);
|
||||
}
|
||||
|
||||
void start_time(void) {
|
||||
tick_start[whoami()] = tick();
|
||||
}
|
||||
|
||||
void stop_time(void) {
|
||||
tick_stop[whoami()] = tick();
|
||||
}
|
||||
|
||||
uint32_t get_time(void) {
|
||||
uint32_t id = whoami();
|
||||
return tick_stop[id] - tick_start[id];
|
||||
}
|
||||
|
||||
uint32_t time_in_secs(uint32_t ticks) {
|
||||
uint32_t retval=((uint32_t)ticks) / (uint32_t)ticks_per_sec;
|
||||
return retval;
|
||||
}
|
||||
|
||||
double ftime_in_secs(uint32_t ticks) {
|
||||
double retval=((double)ticks) / (double)ticks_per_sec;
|
||||
return retval;
|
||||
}
|
||||
|
||||
22
c/ops/ops.h
Normal file
22
c/ops/ops.h
Normal file
@ -0,0 +1,22 @@
|
||||
// © IBM Corp. 2020
|
||||
// Licensed under and subject to the terms of the CC-BY 4.0
|
||||
// license (https://creativecommons.org/licenses/by/4.0/legalcode).
|
||||
// Additional rights, including the right to physically implement a softcore
|
||||
// that is compliant with the required sections of the Power ISA
|
||||
// Specification, will be available at no cost via the OpenPOWER Foundation.
|
||||
// This README will be updated with additional information when OpenPOWER's
|
||||
// license is available.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "a2lib.h"
|
||||
#include "printf.h"
|
||||
|
||||
void init(void);
|
||||
char *me(void);
|
||||
void start_time(void);
|
||||
void stop_time(void);
|
||||
uint32_t get_time(void);
|
||||
uint32_t time_in_secs(uint32_t ticks);
|
||||
double ftime_in_secs(uint32_t ticks);
|
||||
|
||||
20
c/ops/readme.md
Normal file
20
c/ops/readme.md
Normal file
@ -0,0 +1,20 @@
|
||||
# ops - simple test for a2lib calls and build process
|
||||
|
||||
## Setup
|
||||
|
||||
### dir with kernel (if creating single mem image kernel+test)
|
||||
```./asm```
|
||||
|
||||
### dir with a2lib (from a2-boot)
|
||||
```./a2lib```
|
||||
|
||||
### dir with printf (needs to use _putchar() from a2lib
|
||||
```./printf```
|
||||
|
||||
### compile and build
|
||||
|
||||
```
|
||||
compile # gcc
|
||||
build # make mem image
|
||||
```
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user