| 1 | /*
|
|---|
| 2 | * \file : reset_utils.h
|
|---|
| 3 | * \date : August 2012
|
|---|
| 4 | * \author : Cesar Fuguet
|
|---|
| 5 | */
|
|---|
| 6 |
|
|---|
| 7 | #ifndef RESET_UTILS_H
|
|---|
| 8 | #define RESET_UTILS_H
|
|---|
| 9 |
|
|---|
| 10 | #include <elf-types.h>
|
|---|
| 11 | #include <inttypes.h>
|
|---|
| 12 | #include <defs.h>
|
|---|
| 13 |
|
|---|
| 14 | /********************************************************************
|
|---|
| 15 | * Other types definition
|
|---|
| 16 | ********************************************************************/
|
|---|
| 17 |
|
|---|
| 18 | #define __cache_aligned__ __attribute__((aligned(CACHE_LINE_SIZE)))
|
|---|
| 19 |
|
|---|
| 20 | /*
|
|---|
| 21 | * cache line aligned disk block (sector) buffer
|
|---|
| 22 | */
|
|---|
| 23 | struct aligned_blk
|
|---|
| 24 | {
|
|---|
| 25 | char b[BLOCK_SIZE];
|
|---|
| 26 | } __cache_aligned__;
|
|---|
| 27 |
|
|---|
| 28 | /********************************************************************
|
|---|
| 29 | * Utility functions definition
|
|---|
| 30 | ********************************************************************/
|
|---|
| 31 |
|
|---|
| 32 | /**
|
|---|
| 33 | * \brief processor waits for n cycles
|
|---|
| 34 | */
|
|---|
| 35 | static inline void reset_sleep(int cycles)
|
|---|
| 36 | {
|
|---|
| 37 | volatile int i;
|
|---|
| 38 | for (i = 0; i < cycles; i++);
|
|---|
| 39 | }
|
|---|
| 40 |
|
|---|
| 41 | /**
|
|---|
| 42 | * \brief returns processor count
|
|---|
| 43 | */
|
|---|
| 44 | static inline unsigned int proctime()
|
|---|
| 45 | {
|
|---|
| 46 | register unsigned int ret asm ("v0");
|
|---|
| 47 | asm volatile ("mfc0 %0, $9":"=r" (ret));
|
|---|
| 48 | return ret;
|
|---|
| 49 | }
|
|---|
| 50 |
|
|---|
| 51 | int pread(size_t file_offset, void *buf, size_t nbyte, size_t offset);
|
|---|
| 52 |
|
|---|
| 53 | void* memcpy(void *_dst, const void *_src, size_t n);
|
|---|
| 54 | void* memset(void *_dst, int c, size_t len);
|
|---|
| 55 |
|
|---|
| 56 | void check_elf_header(Elf32_Ehdr *ehdr);
|
|---|
| 57 | void reset_print_elf_phdr(Elf32_Phdr * elf_phdr_ptr);
|
|---|
| 58 | void reset_display_block( char* buffer );
|
|---|
| 59 |
|
|---|
| 60 | #endif /* RESET_UTILS_H */
|
|---|
| 61 |
|
|---|
| 62 | // vim: tabstop=4 : softtabstop=4 : shiftwidth=4 : expandtab
|
|---|
| 63 |
|
|---|