adds bsp write and read for rtl
This commit is contained in:
		
							
								
								
									
										19
									
								
								env/testbench/rtl/bsp_read.c
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								env/testbench/rtl/bsp_read.c
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,19 @@
 | 
				
			|||||||
 | 
					#include <stdint.h>
 | 
				
			||||||
 | 
					#include <stdio.h>
 | 
				
			||||||
 | 
					#include <sys/types.h>
 | 
				
			||||||
 | 
					#include <unistd.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ssize_t _bsp_read(int fd, void *ptr, size_t len) {
 | 
				
			||||||
 | 
					  uint8_t *current = (uint8_t *)ptr;
 | 
				
			||||||
 | 
					  volatile uint32_t *uart_rx = (uint32_t *)0xFFFF0000;
 | 
				
			||||||
 | 
					  ssize_t result = 0;
 | 
				
			||||||
 | 
					  if (isatty(fd)) {
 | 
				
			||||||
 | 
					    for (current = (uint8_t *)ptr; (current < ((uint8_t *)ptr) + len);
 | 
				
			||||||
 | 
					         current++) {
 | 
				
			||||||
 | 
					      *current = *uart_rx;
 | 
				
			||||||
 | 
					      result++;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    return result;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  return EOF;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										18
									
								
								env/testbench/rtl/bsp_write.c
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								env/testbench/rtl/bsp_write.c
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,18 @@
 | 
				
			|||||||
 | 
					/* See LICENSE of license details. */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <errno.h>
 | 
				
			||||||
 | 
					#include <stdint.h>
 | 
				
			||||||
 | 
					#include <sys/types.h>
 | 
				
			||||||
 | 
					#include <unistd.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ssize_t _bsp_write(int fd, const void *ptr, size_t len) {
 | 
				
			||||||
 | 
					  const uint8_t *current = (const uint8_t *)ptr;
 | 
				
			||||||
 | 
					  if (isatty(fd)) {
 | 
				
			||||||
 | 
					    for (size_t jj = 0; jj < len; jj++) {
 | 
				
			||||||
 | 
					      *((uint32_t *)0xFFFF0000) = current[jj];
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    return len;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  return 1;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user