<div dir="auto"><div><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Aug 19, 2022, 8:28 AM Hesham Almatary <<a href="mailto:Hesham.Almatary@cl.cam.ac.uk">Hesham.Almatary@cl.cam.ac.uk</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><br></div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, 19 Aug 2022 at 13:36, Daniel Cederman <<a href="mailto:cederman@gaisler.com" target="_blank" rel="noreferrer">cederman@gaisler.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)">On 2022-08-19 11:16, Hesham Almatary wrote:<br>
> On Thu, 18 Aug 2022 at 13:55, Daniel Cederman <<a href="mailto:cederman@gaisler.com" target="_blank" rel="noreferrer">cederman@gaisler.com</a>> wrote:<br>
>> I missed your comment, but have made the change now. Are there any instructions on how to run the RISCV BSP tests on QEMU or Spike? I could not get it to work. Do I need a special version of QEMU or Spike?<br>
>><br>
> Thanks! AFAIR, you need to run the "medany" RISC-V variants for QEMU,<br>
> I'd use rtems-tester. No special QEMU version is needed.<br>
<br>
Thanks! I had to change "-m 64M -kernel" to "-m 128M -bios" to get it to <br>
run. Got the same result both with and without the patch for <br>
rv64imafd_medany:<br>
</blockquote><div dir="auto">Great! Thanks for testing. A patch to fix that in tester will be greatly appreciated. I thought I submitted the -bios change before but apparently not. </div></div></div></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Include it as part of this patch sweep please. And make sure results from the  OAR build machines are in the build@ mailing list archives. If not, that will need to be looked into.</div><div dir="auto"><br></div><div dir="auto">I'm glad this is coming together.</div><div dir="auto"><br></div><div dir="auto">Make sure the license text formatting matches other files.</div><div dir="auto"><br></div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)"><br>
Passed:        653<br>
Failed:         16<br>
User Input:      5<br>
Expected Fail:   0<br>
Indeterminate:   0<br>
Benchmark:       3<br>
Timeout:         5<br>
Test too long:   0<br>
Invalid:         0<br>
Wrong Version:   0<br>
Wrong Build:     0<br>
Wrong Tools:     0<br>
Wrong Header:    0<br>
------------------<br>
Total:         682<br>
Failures:<br>
  exit03.exe<br>
  ttest02.exe<br>
  psx12.exe<br>
  smpirqs01.exe<br>
  sp69.exe<br>
  spintrcritical24.exe<br>
  spsysinit01.exe<br>
  ts-fatal-scheduler-requires-exactly-one-processor.exe<br>
  ts-fatal-start-of-mandatory-processor-failed.exe<br>
  ts-validation-1.exe<br>
  ts-validation-one-cpu-0.exe<br>
  minimum.exe<br>
  smpstart01.exe<br>
  ts-fatal-smp.exe<br>
  ts-performance-no-clock-0.exe<br>
  ts-validation-intr.exe<br>
User Input:<br>
  monitor.exe<br>
  termios.exe<br>
  top.exe<br>
  fileio.exe<br>
  capture.exe<br>
Benchmark:<br>
  dhrystone.exe<br>
  linpack.exe<br>
  whetstone.exe<br>
Timeouts:<br>
  ts-fatal-start-on-not-online-processor.exe<br>
  ts-validation-0.exe<br>
  ts-validation-no-clock-0.exe<br>
  ts-validation-smp-only-0.exe<br>
  ts-validation-timecounter-smp-0.exe<br>
<br>
>> On 2022-08-18 10:24, Hesham Almatary wrote:<br>
>><br>
>> All good, I'd just replace the "end == 0" with "end == NULL" as per my<br>
>> comment above. Also please test on other RISC-V QEMU platforms to make<br>
>> sure nothing got broken.<br>
>><br>
>> On Wed, 17 Aug 2022 at 14:10, Joel Sherrill <<a href="mailto:joel@rtems.org" target="_blank" rel="noreferrer">joel@rtems.org</a>> wrote:<br>
>><br>
>> I'm ok with this if Hesham acks as well.<br>
>><br>
>> --joel<br>
>><br>
>> On Wed, Aug 17, 2022 at 6:35 AM Daniel Cederman <<a href="mailto:cederman@gaisler.com" target="_blank" rel="noreferrer">cederman@gaisler.com</a>> wrote:<br>
>><br>
>> Uses the first entry in the /memory node to determine the end of the<br>
>> work area. Falls back on linker symbol if unable to parse the node.<br>
>> ---<br>
>>   bsps/riscv/shared/start/bspgetworkarea.c | 144 +++++++++++++++++++++++<br>
>>   spec/build/bsps/riscv/riscv/obj.yml      |   1 +<br>
>>   2 files changed, 145 insertions(+)<br>
>>   create mode 100644 bsps/riscv/shared/start/bspgetworkarea.c<br>
>><br>
>> diff --git a/bsps/riscv/shared/start/bspgetworkarea.c b/bsps/riscv/shared/start/bspgetworkarea.c<br>
>> new file mode 100644<br>
>> index 0000000000..1fa051d25e<br>
>> --- /dev/null<br>
>> +++ b/bsps/riscv/shared/start/bspgetworkarea.c<br>
>> @@ -0,0 +1,144 @@<br>
>> +/* SPDX-License-Identifier: BSD-2-Clause */<br>
>> +<br>
>> +/**<br>
>> + * @file<br>
>> + *<br>
>> + * @brief BSP specific initialization support routines<br>
>> + *<br>
>> + */<br>
>> +<br>
>> +/*<br>
>> + * COPYRIGHT (c) 1989-2020.<br>
>> + * On-Line Applications Research Corporation (OAR).<br>
>> + * Cobham Gaisler AB.<br>
>> + *<br>
>> + * Redistribution and use in source and binary forms, with or without<br>
>> + * modification, are permitted provided that the following conditions<br>
>> + * are met:<br>
>> + * 1. Redistributions of source code must retain the above copyright<br>
>> + *    notice, this list of conditions and the following disclaimer.<br>
>> + * 2. Redistributions in binary form must reproduce the above copyright<br>
>> + *    notice, this list of conditions and the following disclaimer in the<br>
>> + *    documentation and/or other materials provided with the distribution.<br>
>> + *<br>
>> + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"<br>
>> + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE<br>
>> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE<br>
>> + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE<br>
>> + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR<br>
>> + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF<br>
>> + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS<br>
>> + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN<br>
>> + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)<br>
>> + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE<br>
>> + * POSSIBILITY OF SUCH DAMAGE.<br>
>> + */<br>
>> +<br>
>> +#include <bsp.h><br>
>> +#include <bsp/fdt.h><br>
>> +<br>
>> +#include <rtems/sysinit.h><br>
>> +<br>
>> +#include <libfdt.h><br>
>> +<br>
>> +/*<br>
>> + *  These are provided by the linkcmds for ALL of the BSPs which use this file.<br>
>> + */<br>
>> +extern char WorkAreaBase[];<br>
>> +extern char RamEnd[];<br>
>> +<br>
>> +static Memory_Area _Memory_Areas[ 1 ];<br>
>> +<br>
>> +static const char memory_path[] = "/memory";<br>
>> +<br>
>> +static void* get_end_of_memory_from_fdt(void)<br>
>> +{<br>
>> +  const void *fdt;<br>
>> +  const void *val;<br>
>> +  int node;<br>
>> +  int parent;<br>
>> +  int ac;<br>
>> +  int sc;<br>
>> +  int len;<br>
>> +  uintptr_t start;<br>
>> +  uintptr_t size;<br>
>> +<br>
>> +  fdt = bsp_fdt_get();<br>
>> +<br>
>> +  node = fdt_path_offset_namelen(<br>
>> +    fdt,<br>
>> +    memory_path,<br>
>> +    (int) sizeof(memory_path) - 1<br>
>> +  );<br>
>> +<br>
>> +  if (node < 0) {<br>
>> +    return NULL;<br>
>> +  }<br>
>> +<br>
>> +  parent = fdt_parent_offset(fdt, node);<br>
>> +  if (parent < 0) {<br>
>> +    return NULL;<br>
>> +  }<br>
>> +<br>
>> +  ac = fdt_address_cells(fdt, parent);<br>
>> +  if (ac != 1 && ac != 2) {<br>
>> +    return NULL;<br>
>> +  }<br>
>> +<br>
>> +  sc = fdt_size_cells(fdt, parent);<br>
>> +  if (sc != 1 && sc != 2) {<br>
>> +    return NULL;<br>
>> +  }<br>
>> +<br>
>> +  if (sc > ac) {<br>
>> +    return NULL;<br>
>> +  }<br>
>> +<br>
>> +  val = fdt_getprop(fdt, node, "reg", &len);<br>
>> +  if (len < sc + ac) {<br>
>> +    return NULL;<br>
>> +  }<br>
>> +<br>
>> +  if (ac == 1) {<br>
>> +    start = fdt32_to_cpu(((fdt32_t *)val)[0]);<br>
>> +    size = fdt32_to_cpu(((fdt32_t *)val)[1]);<br>
>> +  }<br>
>> +<br>
>> +  if (ac == 2) {<br>
>> +    start = fdt64_to_cpu(((fdt64_t *)val)[0]);<br>
>> +<br>
>> +    if (sc == 1)<br>
>> +      size = fdt32_to_cpu(((fdt32_t *)(val+8))[0]);<br>
>> +    else<br>
>> +      size = fdt64_to_cpu(((fdt64_t *)val)[1]);<br>
>> +  }<br>
>> +<br>
>> +  return (void*) (start + size);<br>
>> +}<br>
>> +<br>
>> +static void bsp_memory_initialize( void )<br>
>> +{<br>
>> +  void *end;<br>
>> +<br>
>> +  /* get end of memory from the "/memory" node in the fdt */<br>
>> +  end = get_end_of_memory_from_fdt();<br>
>> +  if (end == 0) {<br>
>> +    /* fall back to linker symbol if "/memory" node not found or invalid */<br>
>> +    end = RamEnd;<br>
>> +  }<br>
>> +  _Memory_Initialize( &_Memory_Areas[ 0 ], WorkAreaBase, end );<br>
>> +}<br>
>> +<br>
>> +RTEMS_SYSINIT_ITEM(<br>
>> +  bsp_memory_initialize,<br>
>> +  RTEMS_SYSINIT_MEMORY,<br>
>> +  RTEMS_SYSINIT_ORDER_MIDDLE<br>
>> +);<br>
>> +<br>
>> +static const Memory_Information _Memory_Information =<br>
>> +  MEMORY_INFORMATION_INITIALIZER( _Memory_Areas );<br>
>> +<br>
>> +const Memory_Information *_Memory_Get( void )<br>
>> +{<br>
>> +  return &_Memory_Information;<br>
>> +}<br>
>> diff --git a/spec/build/bsps/riscv/riscv/obj.yml b/spec/build/bsps/riscv/riscv/obj.yml<br>
>> index 5e767be1bb..b2eb467824 100644<br>
>> --- a/spec/build/bsps/riscv/riscv/obj.yml<br>
>> +++ b/spec/build/bsps/riscv/riscv/obj.yml<br>
>> @@ -29,6 +29,7 @@ source:<br>
>>   - bsps/riscv/riscv/irq/irq.c<br>
>>   - bsps/riscv/riscv/start/bsp_fatal_halt.c<br>
>>   - bsps/riscv/riscv/start/bspstart.c<br>
>> +- bsps/riscv/shared/start/bspgetworkarea.c<br>
>>   - bsps/shared/cache/nocache.c<br>
>>   - bsps/shared/dev/btimer/btimer-cpucounter.c<br>
>>   - bsps/shared/dev/getentropy/getentropy-cpucounter.c<br>
>> --<br>
>> 2.34.1<br>
>><br>
>> _______________________________________________<br>
>> devel mailing list<br>
>> <a href="mailto:devel@rtems.org" target="_blank" rel="noreferrer">devel@rtems.org</a><br>
>> <a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/devel</a><br>
>><br>
>> _______________________________________________<br>
>> devel mailing list<br>
>> <a href="mailto:devel@rtems.org" target="_blank" rel="noreferrer">devel@rtems.org</a><br>
>> <a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/devel</a><br>
>><br>
>><br>
>> _______________________________________________<br>
>> devel mailing list<br>
>> <a href="mailto:devel@rtems.org" target="_blank" rel="noreferrer">devel@rtems.org</a><br>
>> <a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/devel</a><br>
<br>
_______________________________________________<br>
devel mailing list<br>
<a href="mailto:devel@rtems.org" target="_blank" rel="noreferrer">devel@rtems.org</a><br>
<a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/devel</a></blockquote></div></div>
_______________________________________________<br>
devel mailing list<br>
<a href="mailto:devel@rtems.org" target="_blank" rel="noreferrer">devel@rtems.org</a><br>
<a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/devel</a></blockquote></div></div></div>