⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 boot_loader_cfi_bits.s

📁 买的开发板上自带的例程
💻 S
字号:

# file: boot_loader_cfi_bits.S
#
# written by TPA, moved around by dvb, 2003-2004
# routines for accessing data out of a CFI-compliant
# flash device. This device appears like memory,
# so to get bytes you do memory accesses.
#
# Who would have thought?
#


#include "boot_loader.h"

   .global sub_find_payload_cfi
   .global sub_read_byte_from_flash_cfi



# |
# | reading a byte from CFI is pretty simple.
# | dvb
# |


sub_read_byte_from_flash_cfi:
   # Fix-up return-address
   addi    rfb_return_address, return_address_less_4, 4

   # result = *p++
   ldbuio  rf_byte_return_value, 0(r_flash_ptr)
   addi    r_flash_ptr, r_flash_ptr, 1
   jmp     rfb_return_address



########
# Find_Payload
#
#   returns the flash-offset of the first byte of the payload in
#   r_flash_ptr.  Takes no arguments.
#
# CFI:
#    The payload is just the next address after the end of this very
#    boot-copier program.  Use some nextpc position-independent
#    trickery to find it.

sub_find_payload_cfi:

   # Fix-up and save return-address
   addi    r_findp_return_address, return_address_less_4, 4

   nextpc  r_flash_ptr
payload_offset_base:

   # |
   # | One might suspect the code below to be
   # | off by four or something. It could happen easily.
   # | But I've confirmed that it's right.
   # | dvb 2004.
   # |

   addi    r_flash_ptr, r_flash_ptr, (end_of_boot_copier - payload_offset_base)

   # Payload found! r_flash_ptr now contains the first address of the payload.

   jmp     r_findp_return_address

# |
# | For a flash-based boot sequence, we put this very code
# | at the reset address, and the data to be copied right
# | after it. How do we know where the data is? Well, I
# | just said, it's right after it. This is right after it.
# |
# | Mind the link order, boys.
# |

end_of_boot_copier:

# | Data goes here.

   .end


# end of file

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -