   1              		.file	"miv_rv32_syscall.c"
   2              		.option nopic
   3              		.attribute arch, "rv32i2p0_m2p0"
   4              		.attribute unaligned_access, 0
   5              		.attribute stack_align, 16
   6              		.text
   7              		.section	.text.write_hex,"ax",@progbits
   8              		.align	2
   9              		.globl	write_hex
  11              	write_hex:
  12 0000 130101FD 		addi	sp,sp,-48
  13 0004 232A5101 		sw	s5,20(sp)
  14 0008 938A0500 		mv	s5,a1
  15 000c B7050000 		lui	a1,%hi(.LC0)
  16 0010 13062000 		li	a2,2
  17 0014 93850500 		addi	a1,a1,%lo(.LC0)
  18 0018 23248102 		sw	s0,40(sp)
  19 001c 23229102 		sw	s1,36(sp)
  20 0020 23202103 		sw	s2,32(sp)
  21 0024 232E3101 		sw	s3,28(sp)
  22 0028 232C4101 		sw	s4,24(sp)
  23 002c 23261102 		sw	ra,44(sp)
  24 0030 130A0500 		mv	s4,a0
  25 0034 1304C001 		li	s0,28
  26 0038 97000000 		call	write
  26      E7800000 
  27 0040 9309F000 		li	s3,15
  28 0044 13099000 		li	s2,9
  29 0048 9304C0FF 		li	s1,-4
  30 004c 6F00C002 		j	.L4
  31              	.L9:
  32 0050 93978601 		slli	a5,a3,24
  33 0054 93D78741 		srai	a5,a5,24
  34 0058 1304C4FF 		addi	s0,s0,-4
  35 005c 13061000 		li	a2,1
  36 0060 9305F100 		addi	a1,sp,15
  37 0064 13050A00 		mv	a0,s4
  38 0068 A307F100 		sb	a5,15(sp)
  39 006c 97000000 		call	write
  39      E7800000 
  40 0074 63049404 		beq	s0,s1,.L8
  41              	.L4:
  42 0078 B3978900 		sll	a5,s3,s0
  43 007c B3F75701 		and	a5,a5,s5
  44 0080 B3D78700 		srl	a5,a5,s0
  45 0084 93F7F70F 		andi	a5,a5,0xff
  46 0088 93868704 		addi	a3,a5,72
  47 008c 1387B705 		addi	a4,a5,91
  48 0090 E370F9FC 		bleu	a5,s2,.L9
  49 0094 93178701 		slli	a5,a4,24
  50 0098 93D78741 		srai	a5,a5,24
  51 009c 1304C4FF 		addi	s0,s0,-4
  52 00a0 13061000 		li	a2,1
  53 00a4 9305F100 		addi	a1,sp,15
  54 00a8 13050A00 		mv	a0,s4
  55 00ac A307F100 		sb	a5,15(sp)
  56 00b0 97000000 		call	write
  56      E7800000 
  57 00b8 E31094FC 		bne	s0,s1,.L4
  58              	.L8:
  59 00bc 8320C102 		lw	ra,44(sp)
  60 00c0 03248102 		lw	s0,40(sp)
  61 00c4 83244102 		lw	s1,36(sp)
  62 00c8 03290102 		lw	s2,32(sp)
  63 00cc 8329C101 		lw	s3,28(sp)
  64 00d0 032A8101 		lw	s4,24(sp)
  65 00d4 832A4101 		lw	s5,20(sp)
  66 00d8 13010103 		addi	sp,sp,48
  67 00dc 67800000 		jr	ra
  69              		.section	.text._exit,"ax",@progbits
  70              		.align	2
  71              		.globl	_exit
  73              	_exit:
  74              	.L11:
  75 0000 6F000000 		j	.L11
  77              		.section	.text._sbrk,"ax",@progbits
  78              		.align	2
  79              		.globl	_sbrk
  81              	_sbrk:
  82 0000 B7070000 		lui	a5,%hi(__heap_end)
  83 0004 37070000 		lui	a4,%hi(__heap_start)
  84 0008 93870700 		addi	a5,a5,%lo(__heap_end)
  85 000c 13070700 		addi	a4,a4,%lo(__heap_start)
  86 0010 6364F700 		bgtu	a5,a4,.L13
  87              	 #APP
  88              	# 167 "../miv_rv32_hal/miv_rv32_syscall.c" 1
   1              	/*******************************************************************************
   2              	 * Copyright 2019 Microchip FPGA Embedded Systems Solutions.
   3              	 *
   4              	 * SPDX-License-Identifier: MIT
   5              	 *
   6              	 * @file miv_rv32_syscall.c
   7              	 * @author Microchip FPGA Embedded Systems Solutions
   8              	 * @brief Stubs for system calls.
   9              	 *
  10              	 */
  11              	#include <unistd.h>
  12              	#include <errno.h>
  13              	#include <sys/stat.h>
  14              	#include <sys/times.h>
  15              	#include "miv_rv32_hal.h"
  16              	
  17              	#ifdef MSCC_STDIO_THRU_CORE_UART_APB
  18              	#include <string.h>
  19              	
  20              	#ifndef LEGACY_DIR_STRUCTURE
  21              	#include "drivers/fpga_ip/CoreUARTapb/core_uart_apb.h"
  22              	#else
  23              	#include "core_uart_apb.h"
  24              	#endif
  25              	
  26              	#endif  /*MSCC_STDIO_THRU_CORE_UART_APB*/
  27              	
  28              	#ifdef __cplusplus
  29              	extern "C" {
  30              	#endif
  31              	
  32              	#ifdef MSCC_STDIO_THRU_CORE_UART_APB
  33              	
  34              	/*------------------------------------------------------------------------------
  35              	 * CoreUARTapb instance data for the CoreUARTapb instance used for standard
  36              	 * output.
  37              	 */
  38              	static UART_instance_t g_stdio_uart;
  39              	
  40              	/*==============================================================================
  41              	 * Flag used to indicate if the UART driver needs to be initialized.
  42              	 */
  43              	static int g_stdio_uart_init_done = 0;
  44              	
  45              	/*
  46              	 * Disable semihosting apis
  47              	 */
  48              	#pragma import(__use_no_semihosting_swi)
  49              	
  50              	/*==============================================================================
  51              	 * sendchar()
  52              	 */
  53              	int sendchar(int ch)
  54              	{
  55              	    /*--------------------------------------------------------------------------
  56              	    * Initialize the UART driver if it is the first time this function is
  57              	    * called.
  58              	    */
  59              	    if ( !g_stdio_uart_init_done )
  60              	    {
  61              	        /******************************************************************************
  62              	         * Baud value:
  63              	         * This value is calculated using the following equation:
  64              	         *      BAUD_VALUE = (CLOCK / (16 * BAUD_RATE)) - 1
  65              	         *****************************************************************************/
  66              	        UART_init( &g_stdio_uart,
  67              	                   MSCC_STDIO_UART_BASE_ADDR,
  68              	                   ((SYS_CLK_FREQ/(16 * MSCC_STDIO_BAUD_VALUE))-1),
  69              	                   (DATA_8_BITS | NO_PARITY));
  70              	
  71              	        g_stdio_uart_init_done = 1;
  72              	    }
  73              	
  74              	    /*--------------------------------------------------------------------------
  75              	    * Output text to the UART.
  76              	    */
  77              	    UART_send( &g_stdio_uart, (uint8_t *)&ch, 1 );
  78              	
  79              	    return (ch);
  80              	}
  81              	
  82              	/*==============================================================================
  83              	 * getachar()
  84              	 */
  85              	int getachar(void)
  86              	{
  87              	    uint8_t rx_size;
  88              	    uint8_t rx_byte;
  89              	
  90              	    if ( !g_stdio_uart_init_done )
  91              	    {
  92              	        /******************************************************************************
  93              	         * Baud value:
  94              	         * This value is calculated using the following equation:
  95              	         *      BAUD_VALUE = (CLOCK / (16 * BAUD_RATE)) - 1
  96              	         *****************************************************************************/
  97              	        UART_init( &g_stdio_uart,
  98              	                   MSCC_STDIO_UART_BASE_ADDR,
  99              	                   ((SYS_CLK_FREQ/(16 * MSCC_STDIO_BAUD_VALUE))-1),
 100              	                   (DATA_8_BITS | NO_PARITY));
 101              	
 102              	        g_stdio_uart_init_done = 1;
 103              	    }
 104              	
 105              	    do
 106              	    {
 107              	        rx_size = UART_get_rx(&g_stdio_uart, &rx_byte, 1);
 108              	    } while(0u == rx_size);
 109              	
 110              	    return rx_byte;
 111              	}
 112              	
 113              	#endif /*MSCC_STDIO_THRU_CORE_UART_APB*/
 114              	
 115              	#undef errno
 116              	static int errno;
 117              	
 118              	static char *__env[1] = { 0 };
 119              	char **environ = __env;
 120              	
 121              	void write_hex(int fd, uint32_t hex)
 122              	{
 123              	    char towrite;
 124              	
 125              	    write( fd , "0x", 2U );
 126              	
 127              	    for (uint32_t ii = 8U ; ii > 0U; ii--)
 128              	    {
 129              	        uint32_t jj = ii-1U;
 130              			uint8_t digit = ((hex & (0xFU << (jj*4U))) >> (jj*4U));
 131              	        towrite = digit < 0xAU ? (0x48U + digit) : (0x65U +  (digit - 0xAU));
 132              	        write( fd, &towrite, 1U);
 133              	    }
 134              	}
 135              	
 136              	               
 137              	#ifdef GDB_TESTING
 138              	void __attribute__((optimize("O0"))) _exit(int code)
 139              	#else
 140              	void _exit(int code)
 141              	#endif
 142              	{
 143              	#ifdef MSCC_STDIO_THRU_CORE_UART_APB
 144              	    const char * message = "\nProgam has exited with code:";
 145              	
 146              	    write(STDERR_FILENO, message, strlen(message));
 147              	    write_hex(STDERR_FILENO, code);
 148              	#endif
 149              	
 150              	    while (1){};
 151              	}
 152              	
 153              	void *_sbrk(ptrdiff_t incr)
 154              	{
 155              	    extern char _end;
 156              	    extern char _heap_end;
 157              	    extern char __heap_start;
 158              	    extern char __heap_end;
 159              	    static char *curbrk = &_end;
 160              	    void * ret = NULL;
 161              	
 162              	    /*
 163              	     * Did we allocated memory for the heap in the linker script?
 164              	     * You need to set HEAP_SIZE to a non-zero value in your linker script if
 165              	     * the following assertion fires.
 166              	     */
 167 0014 73001000 	    ASSERT(&__heap_end > &__heap_start);
 168              	
  89              		ebreak
  90              	# 0 "" 2
  91              	 #NO_APP
  92              	.L13:
  93 0018 B7060000 		lui	a3,%hi(.LANCHOR0)
  94 001c 93860600 		addi	a3,a3,%lo(.LANCHOR0)
  95 0020 83A50600 		lw	a1,0(a3)
  96 0024 37060000 		lui	a2,%hi(_end)
  97 0028 13060600 		addi	a2,a2,%lo(_end)
  98 002c 3387A500 		add	a4,a1,a0
  99 0030 1305F0FF 		li	a0,-1
 100 0034 6368C700 		bltu	a4,a2,.L14
 101 0038 37060000 		lui	a2,%hi(_heap_end)
 102 003c 13060600 		addi	a2,a2,%lo(_heap_end)
 103 0040 6378E600 		bleu	a4,a2,.L18
 104              	.L14:
 105 0044 63F4B700 		bleu	a1,a5,.L12
 106              	 #APP
 107              	# 185 "../miv_rv32_hal/miv_rv32_syscall.c" 1
 169              	    if (((curbrk + incr) < &_end) || ((curbrk + incr) > &_heap_end))
 170              	    {
 171              	        errno = ENOMEM;
 172              	        ret = ((char *) - 1);
 173              	    }
 174              	    else
 175              	    {
 176              	        curbrk += incr;
 177              	        ret = curbrk - incr;
 178              	    }
 179              	
 180              	    /*
 181              	     * Did we run out of heap?
 182              	     * You need to increase the heap size in the linker script if the following
 183              	     * assertion fires.
 184              	     * */
 185 0048 73001000 	    ASSERT(curbrk <= &__heap_end);
 186              	
 108              		ebreak
 109              	# 0 "" 2
 110              	 #NO_APP
 111              	.L12:
 112 004c 67800000 		ret
 113              	.L18:
 114 0050 13850500 		mv	a0,a1
 115 0054 23A0E600 		sw	a4,0(a3)
 116 0058 93050700 		mv	a1,a4
 117 005c 6FF09FFE 		j	.L14
 119              		.section	.text._isatty,"ax",@progbits
 120              		.align	2
 121              		.globl	_isatty
 123              	_isatty:
 124 0000 13253500 		slti	a0,a0,3
 125 0004 67800000 		ret
 127              		.section	.text._open,"ax",@progbits
 128              		.align	2
 129              		.globl	_open
 131              	_open:
 132 0000 1305F0FF 		li	a0,-1
 133 0004 67800000 		ret
 135              		.section	.text._openat,"ax",@progbits
 136              		.align	2
 137              		.globl	_openat
 139              	_openat:
 140 0000 1305F0FF 		li	a0,-1
 141 0004 67800000 		ret
 143              		.section	.text._close,"ax",@progbits
 144              		.align	2
 145              		.globl	_close
 147              	_close:
 148 0000 1305F0FF 		li	a0,-1
 149 0004 67800000 		ret
 151              		.section	.text._execve,"ax",@progbits
 152              		.align	2
 153              		.globl	_execve
 155              	_execve:
 156 0000 1305F0FF 		li	a0,-1
 157 0004 67800000 		ret
 159              		.section	.text._fork,"ax",@progbits
 160              		.align	2
 161              		.globl	_fork
 163              	_fork:
 164 0000 1305F0FF 		li	a0,-1
 165 0004 67800000 		ret
 167              		.section	.text._fstat,"ax",@progbits
 168              		.align	2
 169              		.globl	_fstat
 171              	_fstat:
 172 0000 130101FF 		addi	sp,sp,-16
 173 0004 23248100 		sw	s0,8(sp)
 174 0008 23261100 		sw	ra,12(sp)
 175 000c 13840500 		mv	s0,a1
 176 0010 97000000 		call	isatty
 176      E7800000 
 177 0018 63000502 		beq	a0,zero,.L27
 178 001c B7270000 		li	a5,8192
 179 0020 2322F400 		sw	a5,4(s0)
 180 0024 13050000 		li	a0,0
 181              	.L25:
 182 0028 8320C100 		lw	ra,12(sp)
 183 002c 03248100 		lw	s0,8(sp)
 184 0030 13010101 		addi	sp,sp,16
 185 0034 67800000 		jr	ra
 186              	.L27:
 187 0038 1305F0FF 		li	a0,-1
 188 003c 6FF0DFFE 		j	.L25
 190              		.section	.text._getpid,"ax",@progbits
 191              		.align	2
 192              		.globl	_getpid
 194              	_getpid:
 195 0000 13051000 		li	a0,1
 196 0004 67800000 		ret
 198              		.section	.text._kill,"ax",@progbits
 199              		.align	2
 200              		.globl	_kill
 202              	_kill:
 203 0000 1305F0FF 		li	a0,-1
 204 0004 67800000 		ret
 206              		.section	.text._link,"ax",@progbits
 207              		.align	2
 208              		.globl	_link
 210              	_link:
 211 0000 1305F0FF 		li	a0,-1
 212 0004 67800000 		ret
 214              		.section	.text._lseek,"ax",@progbits
 215              		.align	2
 216              		.globl	_lseek
 218              	_lseek:
 219 0000 13253500 		slti	a0,a0,3
 220 0004 1305F5FF 		addi	a0,a0,-1
 221 0008 67800000 		ret
 223              		.section	.text._read,"ax",@progbits
 224              		.align	2
 225              		.globl	_read
 227              	_read:
 228 0000 1305F0FF 		li	a0,-1
 229 0004 67800000 		ret
 231              		.section	.text._stat,"ax",@progbits
 232              		.align	2
 233              		.globl	_stat
 235              	_stat:
 236 0000 1305F0FF 		li	a0,-1
 237 0004 67800000 		ret
 239              		.section	.text._times,"ax",@progbits
 240              		.align	2
 241              		.globl	_times
 243              	_times:
 244 0000 1305F0FF 		li	a0,-1
 245 0004 67800000 		ret
 247              		.section	.text._unlink,"ax",@progbits
 248              		.align	2
 249              		.globl	_unlink
 251              	_unlink:
 252 0000 1305F0FF 		li	a0,-1
 253 0004 67800000 		ret
 255              		.section	.text._wait,"ax",@progbits
 256              		.align	2
 257              		.globl	_wait
 259              	_wait:
 260 0000 1305F0FF 		li	a0,-1
 261 0004 67800000 		ret
 263              		.section	.text._write,"ax",@progbits
 264              		.align	2
 265              		.globl	_write
 267              	_write:
 268 0000 1305F0FF 		li	a0,-1
 269 0004 67800000 		ret
 271              		.globl	environ
 272              		.comm	MRV_LOCAL_IRQn_Type,4,4
 273              		.section	.rodata.write_hex.str1.4,"aMS",@progbits,1
 274              		.align	2
 275              	.LC0:
 276 0000 307800   		.string	"0x"
 277              		.section	.sbss.__env,"aw",@nobits
 278              		.align	2
 281              	__env:
 282 0000 00000000 		.zero	4
 283              		.section	.sdata.curbrk.2491,"aw"
 284              		.align	2
 285              		.set	.LANCHOR0,. + 0
 288              	curbrk.2491:
 289 0000 00000000 		.word	_end
 290              		.section	.sdata.environ,"aw"
 291              		.align	2
 294              	environ:
 295 0000 00000000 		.word	__env
 296              		.ident	"GCC: (xPack GNU RISC-V Embedded GCC (Microsemi SoftConsole build), 64-bit) 8.3.0"
DEFINED SYMBOLS
                            *ABS*:0000000000000000 miv_rv32_syscall.c
C:\Users\i68629\AppData\Local\Temp\ccT6ZjrU.s:11     .text.write_hex:0000000000000000 write_hex
C:\Users\i68629\AppData\Local\Temp\ccT6ZjrU.s:73     .text._exit:0000000000000000 _exit
C:\Users\i68629\AppData\Local\Temp\ccT6ZjrU.s:81     .text._sbrk:0000000000000000 _sbrk
C:\Users\i68629\AppData\Local\Temp\ccT6ZjrU.s:123    .text._isatty:0000000000000000 _isatty
C:\Users\i68629\AppData\Local\Temp\ccT6ZjrU.s:131    .text._open:0000000000000000 _open
C:\Users\i68629\AppData\Local\Temp\ccT6ZjrU.s:139    .text._openat:0000000000000000 _openat
C:\Users\i68629\AppData\Local\Temp\ccT6ZjrU.s:147    .text._close:0000000000000000 _close
C:\Users\i68629\AppData\Local\Temp\ccT6ZjrU.s:155    .text._execve:0000000000000000 _execve
C:\Users\i68629\AppData\Local\Temp\ccT6ZjrU.s:163    .text._fork:0000000000000000 _fork
C:\Users\i68629\AppData\Local\Temp\ccT6ZjrU.s:171    .text._fstat:0000000000000000 _fstat
C:\Users\i68629\AppData\Local\Temp\ccT6ZjrU.s:194    .text._getpid:0000000000000000 _getpid
C:\Users\i68629\AppData\Local\Temp\ccT6ZjrU.s:202    .text._kill:0000000000000000 _kill
C:\Users\i68629\AppData\Local\Temp\ccT6ZjrU.s:210    .text._link:0000000000000000 _link
C:\Users\i68629\AppData\Local\Temp\ccT6ZjrU.s:218    .text._lseek:0000000000000000 _lseek
C:\Users\i68629\AppData\Local\Temp\ccT6ZjrU.s:227    .text._read:0000000000000000 _read
C:\Users\i68629\AppData\Local\Temp\ccT6ZjrU.s:235    .text._stat:0000000000000000 _stat
C:\Users\i68629\AppData\Local\Temp\ccT6ZjrU.s:243    .text._times:0000000000000000 _times
C:\Users\i68629\AppData\Local\Temp\ccT6ZjrU.s:251    .text._unlink:0000000000000000 _unlink
C:\Users\i68629\AppData\Local\Temp\ccT6ZjrU.s:259    .text._wait:0000000000000000 _wait
C:\Users\i68629\AppData\Local\Temp\ccT6ZjrU.s:267    .text._write:0000000000000000 _write
C:\Users\i68629\AppData\Local\Temp\ccT6ZjrU.s:294    .sdata.environ:0000000000000000 environ
                            *COM*:0000000000000004 MRV_LOCAL_IRQn_Type
C:\Users\i68629\AppData\Local\Temp\ccT6ZjrU.s:281    .sbss.__env:0000000000000000 __env
C:\Users\i68629\AppData\Local\Temp\ccT6ZjrU.s:285    .sdata.curbrk.2491:0000000000000000 .LANCHOR0
C:\Users\i68629\AppData\Local\Temp\ccT6ZjrU.s:288    .sdata.curbrk.2491:0000000000000000 curbrk.2491
C:\Users\i68629\AppData\Local\Temp\ccT6ZjrU.s:275    .rodata.write_hex.str1.4:0000000000000000 .LC0
C:\Users\i68629\AppData\Local\Temp\ccT6ZjrU.s:41     .text.write_hex:0000000000000078 .L4
C:\Users\i68629\AppData\Local\Temp\ccT6ZjrU.s:58     .text.write_hex:00000000000000bc .L8
C:\Users\i68629\AppData\Local\Temp\ccT6ZjrU.s:31     .text.write_hex:0000000000000050 .L9
C:\Users\i68629\AppData\Local\Temp\ccT6ZjrU.s:74     .text._exit:0000000000000000 .L11
C:\Users\i68629\AppData\Local\Temp\ccT6ZjrU.s:92     .text._sbrk:0000000000000018 .L13
C:\Users\i68629\AppData\Local\Temp\ccT6ZjrU.s:104    .text._sbrk:0000000000000044 .L14
C:\Users\i68629\AppData\Local\Temp\ccT6ZjrU.s:113    .text._sbrk:0000000000000050 .L18
C:\Users\i68629\AppData\Local\Temp\ccT6ZjrU.s:111    .text._sbrk:000000000000004c .L12
C:\Users\i68629\AppData\Local\Temp\ccT6ZjrU.s:186    .text._fstat:0000000000000038 .L27
C:\Users\i68629\AppData\Local\Temp\ccT6ZjrU.s:181    .text._fstat:0000000000000028 .L25

UNDEFINED SYMBOLS
write
__heap_end
__heap_start
_end
_heap_end
isatty
