OpenCores
URL https://opencores.org/ocsvn/neorv32/neorv32/trunk

Subversion Repositories neorv32

[/] [neorv32/] [trunk/] [sw/] [lib/] [source/] [neorv32_rte.c] - Diff between revs 41 and 42

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 41 Rev 42
Line 1... Line 1...
// #################################################################################################
// #################################################################################################
// # << NEORV32: neorv32_rte.c - NEORV32 Runtime Environment >>                                    #
// # << NEORV32: neorv32_rte.c - NEORV32 Runtime Environment >>                                    #
// # ********************************************************************************************* #
// # ********************************************************************************************* #
// # BSD 3-Clause License                                                                          #
// # BSD 3-Clause License                                                                          #
// #                                                                                               #
// #                                                                                               #
// # Copyright (c) 2020, Stephan Nolting. All rights reserved.                                     #
// # Copyright (c) 2021, Stephan Nolting. All rights reserved.                                     #
// #                                                                                               #
// #                                                                                               #
// # Redistribution and use in source and binary forms, with or without modification, are          #
// # Redistribution and use in source and binary forms, with or without modification, are          #
// # permitted provided that the following conditions are met:                                     #
// # permitted provided that the following conditions are met:                                     #
// #                                                                                               #
// #                                                                                               #
// # 1. Redistributions of source code must retain the above copyright notice, this list of        #
// # 1. Redistributions of source code must retain the above copyright notice, this list of        #
Line 286... Line 286...
    neorv32_uart_printf("rv128");
    neorv32_uart_printf("rv128");
  }
  }
 
 
  // CPU extensions
  // CPU extensions
  neorv32_uart_printf("\nEndianness:        ");
  neorv32_uart_printf("\nEndianness:        ");
  if (neorv32_cpu_csr_read(CSR_MSTATUSH) & (1<<CPU_MSTATUSH_MBE)) {
  if (neorv32_cpu_csr_read(CSR_MSTATUSH) & (1<<CSR_MSTATUSH_MBE)) {
    neorv32_uart_printf("big\n");
    neorv32_uart_printf("big\n");
  }
  }
  else {
  else {
    neorv32_uart_printf("little\n");
    neorv32_uart_printf("little\n");
  }
  }
 
 
  // CPU extensions
  // CPU extensions
  neorv32_uart_printf("\nExtensions:        ");
  neorv32_uart_printf("Extensions:        ");
  tmp = neorv32_cpu_csr_read(CSR_MISA);
  tmp = neorv32_cpu_csr_read(CSR_MISA);
  for (i=0; i<26; i++) {
  for (i=0; i<26; i++) {
    if (tmp & (1 << i)) {
    if (tmp & (1 << i)) {
      c = (char)('A' + i);
      c = (char)('A' + i);
      neorv32_uart_putc(c);
      neorv32_uart_putc(c);
Line 306... Line 306...
    }
    }
  }
  }
 
 
  // Z* CPU extensions (from custom "mzext" CSR)
  // Z* CPU extensions (from custom "mzext" CSR)
  tmp = neorv32_cpu_csr_read(CSR_MZEXT);
  tmp = neorv32_cpu_csr_read(CSR_MZEXT);
  if (tmp & (1<<CPU_MZEXT_ZICSR)) {
  if (tmp & (1<<CSR_MZEXT_ZICSR)) {
    neorv32_uart_printf("Zicsr ");
    neorv32_uart_printf("Zicsr ");
  }
  }
  if (tmp & (1<<CPU_MZEXT_ZIFENCEI)) {
  if (tmp & (1<<CSR_MZEXT_ZIFENCEI)) {
    neorv32_uart_printf("Zifencei ");
    neorv32_uart_printf("Zifencei ");
  }
  }
  if (tmp & (1<<CPU_MZEXT_PMP)) {
 
    neorv32_uart_printf("PMP ");
 
  }
 
 
 
 
 
  // check physical memory protection
  // check physical memory protection
  neorv32_uart_printf("\n\nPhysical memory protection: ");
  neorv32_uart_printf("\nPMP:               ");
  if (neorv32_cpu_csr_read(CSR_MZEXT) & (1<<CPU_MZEXT_PMP))  {
  uint32_t pmp_num_regions = neorv32_cpu_pmp_get_num_regions();
 
  if (pmp_num_regions != 0)  {
    // get minimal region siz (granulartiy)
    // get number of available regions
    neorv32_uart_printf("\n- Minimal granularity: %u bytes per region\n", neorv32_cpu_pmp_get_granularity());
    neorv32_uart_printf("\n- Available regions:   %u\n", pmp_num_regions);
 
 
    // test available modes
 
    neorv32_uart_printf("- Mode TOR:   ");
 
    neorv32_cpu_csr_write(CSR_PMPCFG0, 0x08);
 
    if ((neorv32_cpu_csr_read(CSR_PMPCFG0) & 0xFF) == 0x08) {
 
      neorv32_uart_printf("available\n");
 
    }
 
    else {
 
      neorv32_uart_printf("not implemented\n");
 
    }
 
 
 
    neorv32_uart_printf("- Mode NA4:   ");
    // get minimal region size (granulartiy)
    neorv32_cpu_csr_write(CSR_PMPCFG0, 0x10);
    neorv32_uart_printf("- Minimal granularity: %u bytes per region\n", neorv32_cpu_pmp_get_granularity());
    if ((neorv32_cpu_csr_read(CSR_PMPCFG0) & 0xFF) == 0x10) {
 
      neorv32_uart_printf("available\n");
 
    }
    }
    else {
    else {
      neorv32_uart_printf("not implemented\n");
      neorv32_uart_printf("not implemented\n");
    }
    }
 
 
    neorv32_uart_printf("- Mode NAPOT: ");
  // check physical memory protection
    neorv32_cpu_csr_write(CSR_PMPCFG0, 0x18);
  neorv32_uart_printf("HPM Counters:      %u\n", neorv32_cpu_hpm_get_counters());
    if ((neorv32_cpu_csr_read(CSR_PMPCFG0) & 0xFF) == 0x18) {
 
      neorv32_uart_printf("available\n");
 
    }
 
    else {
 
      neorv32_uart_printf("not implemented\n");
 
    }
 
 
 
    // deactivate entry
 
    neorv32_cpu_csr_write(CSR_PMPCFG0, 0);
 
  }
 
  else {
 
    neorv32_uart_printf("not implemented\n");
 
  }
 
 
 
 
 
  // Misc - system
  // Misc - system
  neorv32_uart_printf("\n\n---- Processor - General ----\n");
  neorv32_uart_printf("\n\n---- Processor - General ----\n");
  neorv32_uart_printf("Clock:   %u Hz\n", SYSINFO_CLK);
  neorv32_uart_printf("Clock:   %u Hz\n", SYSINFO_CLK);
Line 376... Line 347...
  __neorv32_rte_print_true_false(SYSINFO_FEATURES & (1 << SYSINFO_FEATURES_MEM_INT_IMEM));
  __neorv32_rte_print_true_false(SYSINFO_FEATURES & (1 << SYSINFO_FEATURES_MEM_INT_IMEM));
  neorv32_uart_printf("IMEM size:            %u bytes\n", SYSINFO_IMEM_SIZE);
  neorv32_uart_printf("IMEM size:            %u bytes\n", SYSINFO_IMEM_SIZE);
  neorv32_uart_printf("Internal IMEM as ROM: ");
  neorv32_uart_printf("Internal IMEM as ROM: ");
  __neorv32_rte_print_true_false(SYSINFO_FEATURES & (1 << SYSINFO_FEATURES_MEM_INT_IMEM_ROM));
  __neorv32_rte_print_true_false(SYSINFO_FEATURES & (1 << SYSINFO_FEATURES_MEM_INT_IMEM_ROM));
 
 
  neorv32_uart_printf("\nData base address:    0x%x\n", SYSINFO_DSPACE_BASE);
  neorv32_uart_printf("Data base address:    0x%x\n", SYSINFO_DSPACE_BASE);
  neorv32_uart_printf("Internal DMEM:        ");
  neorv32_uart_printf("Internal DMEM:        ");
  __neorv32_rte_print_true_false(SYSINFO_FEATURES & (1 << SYSINFO_FEATURES_MEM_INT_DMEM));
  __neorv32_rte_print_true_false(SYSINFO_FEATURES & (1 << SYSINFO_FEATURES_MEM_INT_DMEM));
  neorv32_uart_printf("DMEM size:            %u bytes\n", SYSINFO_DMEM_SIZE);
  neorv32_uart_printf("DMEM size:            %u bytes\n", SYSINFO_DMEM_SIZE);
 
 
  neorv32_uart_printf("\nInternal i-cache:     ");
  neorv32_uart_printf("Internal i-cache:     ");
  __neorv32_rte_print_true_false(SYSINFO_FEATURES & (1 << SYSINFO_FEATURES_ICACHE));
  __neorv32_rte_print_true_false(SYSINFO_FEATURES & (1 << SYSINFO_FEATURES_ICACHE));
  if (SYSINFO_FEATURES & (1 << SYSINFO_FEATURES_ICACHE)) {
  if (SYSINFO_FEATURES & (1 << SYSINFO_FEATURES_ICACHE)) {
    neorv32_uart_printf("- ");
    neorv32_uart_printf("- ");
 
 
    uint32_t ic_block_size = (SYSINFO_CACHE >> SYSINFO_CACHE_IC_BLOCK_SIZE_0) & 0x0F;
    uint32_t ic_block_size = (SYSINFO_CACHE >> SYSINFO_CACHE_IC_BLOCK_SIZE_0) & 0x0F;
Line 417... Line 388...
    else {
    else {
      neorv32_uart_printf("fully-associative\n");
      neorv32_uart_printf("fully-associative\n");
    }
    }
  }
  }
 
 
  neorv32_uart_printf("\nBootloader:           ");
  neorv32_uart_printf("Bootloader:           ");
  __neorv32_rte_print_true_false(SYSINFO_FEATURES & (1 << SYSINFO_FEATURES_BOOTLOADER));
  __neorv32_rte_print_true_false(SYSINFO_FEATURES & (1 << SYSINFO_FEATURES_BOOTLOADER));
 
 
  neorv32_uart_printf("\nExternal memory bus interface:  ");
  neorv32_uart_printf("Ext. bus interface:   ");
  __neorv32_rte_print_true_false(SYSINFO_FEATURES & (1 << SYSINFO_FEATURES_MEM_EXT));
  __neorv32_rte_print_true_false(SYSINFO_FEATURES & (1 << SYSINFO_FEATURES_MEM_EXT));
  neorv32_uart_printf("External memory bus Endianness: ");
  neorv32_uart_printf("Ext. bus Endianness:  ");
  if (SYSINFO_FEATURES & (1 << SYSINFO_FEATURES_MEM_EXT_ENDIAN)) {
  if (SYSINFO_FEATURES & (1 << SYSINFO_FEATURES_MEM_EXT_ENDIAN)) {
    neorv32_uart_printf("big\n");
    neorv32_uart_printf("big\n");
  }
  }
  else {
  else {
    neorv32_uart_printf("little\n");
    neorv32_uart_printf("little\n");
Line 540... Line 511...
/**********************************************************************//**
/**********************************************************************//**
 * NEORV32 runtime environment: Print project credits
 * NEORV32 runtime environment: Print project credits
 **************************************************************************/
 **************************************************************************/
void neorv32_rte_print_credits(void) {
void neorv32_rte_print_credits(void) {
 
 
  neorv32_uart_print("The NEORV32 Processor Project by Stephan Nolting\n"
  neorv32_uart_print("The NEORV32 Processor Project\n"
 
                     "Copyright 2021, Stephan Nolting\n"
 
                     "BSD 3-Clause License\n"
                     "https://github.com/stnolting/neorv32\n\n");
                     "https://github.com/stnolting/neorv32\n\n");
}
}
 
 
 
 
/**********************************************************************//**
/**********************************************************************//**
Line 595... Line 568...
 
 
  neorv32_uart_print(
  neorv32_uart_print(
  "\n"
  "\n"
  "BSD 3-Clause License\n"
  "BSD 3-Clause License\n"
  "\n"
  "\n"
  "Copyright (c) 2020, Stephan Nolting. All rights reserved.\n"
  "Copyright (c) 2021, Stephan Nolting. All rights reserved.\n"
  "\n"
  "\n"
  "Redistribution and use in source and binary forms, with or without modification, are\n"
  "Redistribution and use in source and binary forms, with or without modification, are\n"
  "permitted provided that the following conditions are met:\n"
  "permitted provided that the following conditions are met:\n"
  "\n"
  "\n"
  "1. Redistributions of source code must retain the above copyright notice, this list of\n"
  "1. Redistributions of source code must retain the above copyright notice, this list of\n"

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.