[coreboot-gerrit] Change in coreboot[master]: riscv: add trampoline in MBR block to support boot mode 1
Philipp Hug (Code Review)
gerrit at coreboot.org
Sat Jul 7 13:17:20 CEST 2018
Philipp Hug has uploaded this change for review. ( https://review.coreboot.org/27397
Change subject: riscv: add trampoline in MBR block to support boot mode 1
......................................................................
riscv: add trampoline in MBR block to support boot mode 1
Add "J pc + 0x1000" at the beginning of the MBR to jump to bootlock.
Changed first usable lba to 4 (0x1000) as prevent stack alignment
issues.
Change-Id: I16e762d9f027346b124412f1f7ee6ff37f431d86
---
M util/riscv/sifive-gpt.py
1 file changed, 9 insertions(+), 7 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/97/27397/1
diff --git a/util/riscv/sifive-gpt.py b/util/riscv/sifive-gpt.py
index cb77302..2619a21 100755
--- a/util/riscv/sifive-gpt.py
+++ b/util/riscv/sifive-gpt.py
@@ -25,6 +25,12 @@
# Size of the bootcode part of the MBR
MBR_BOOTCODE_SIZE = 0x1be
+# MBR trampoline to bootblock
+MBR_BOOTCODE = bytes([
+ # j pc + 0x1000
+ 0x6f, 0x10, 0x00, 0x00,
+])
+
# A protecive MBR, without the bootcode part
PROTECTIVE_MBR_FOOTER = bytes([
0x00, 0x00, 0x02, 0x00, 0xee, 0xff, 0xff, 0xff,
@@ -43,7 +49,7 @@
# [1]: https://en.wikipedia.org/wiki/GUID_Partition_Table#PROTECTIVE-MBR
class ProtectiveMBR:
def __init__(self):
- self.bootcode = bytes(MBR_BOOTCODE_SIZE)
+ self.bootcode = MBR_BOOTCODE + bytes(MBR_BOOTCODE_SIZE - len(MBR_BOOTCODE))
def generate(self, stream):
assert len(self.bootcode) == MBR_BOOTCODE_SIZE
@@ -71,7 +77,7 @@
def __init__(self):
self.current_lba = 1
self.backup_lba = 1
- self.first_usable_lba = 2
+ self.first_usable_lba = 8 # hard-coded to match jump
self.last_usable_lba = 0xff # dummy value
self.uniq = DUMMY_GUID_DISK_UNIQUE
self.part_entries_lba = 2
@@ -126,7 +132,7 @@
def __init__(self):
self.mbr = ProtectiveMBR()
self.header = GPTHeader()
- self.partitions = [ GPTPartition() for i in range(8) ]
+ self.partitions = [ GPTPartition() for i in range(24) ]
self.bootblock = b''
@@ -137,10 +143,6 @@
bootblock_size = (len(self.bootblock) + BLOCK_SIZE - 1) & ~BLOCK_MASK
self.bootblock = self.bootblock.ljust(bootblock_size)
- # Propagate the number of partition entries
- self.header.part_entries_number = len(self.partitions)
- self.header.first_usable_lba = 2 + self.header.part_entries_number // 4
-
# Create a partition entry for the bootblock
self.partitions[0].type = GUID_TYPE_FSBL
self.partitions[0].uniq = DUMMY_GUID_PART_UNIQUE
--
To view, visit https://review.coreboot.org/27397
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I16e762d9f027346b124412f1f7ee6ff37f431d86
Gerrit-Change-Number: 27397
Gerrit-PatchSet: 1
Gerrit-Owner: Philipp Hug <philipp at hug.cx>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20180707/c7757f1b/attachment.html>
More information about the coreboot-gerrit
mailing list