Skip to content
Permalink
Browse files

[FREELDR][BTRFS] Fixed boot issues when using VirtualBox

  • Loading branch information...
Extravert-ir committed Jul 16, 2018
1 parent 239eec2 commit 8ae62c1bbcbd8eae15911a17193d64bca1cae950
Showing with 16 additions and 13 deletions.
  1. +16 −13 boot/freeldr/bootsect/btrfs.S
@@ -186,9 +186,9 @@ ReadSectors:
ReadSectors_loop:
pushad // Save logical sector number & sector count

cmp cx, 64 // Since the LBA calls only support 0x7F sectors at a time we will limit ourselves to 64
jbe ReadSectorsSetupDiskAddressPacket // If we are reading less than 65 sectors then just do the read
mov cx, 64 // Otherwise read only 64 sectors on this loop iteration
cmp cx, 8 // Maximum sectors per call is 0x7F, but VirtualBox correctly works with only 8

This comment has been minimized.

@volkertb

volkertb Jul 30, 2018

@Extravert-ir First of all, nice work! 😃

In your corresponding blog post, you mentioned that this was "a bug in VirtualBox BIOS implementation". In case you haven't yet done so, perhaps you can report this VirtualBox bug upstream, so that they can improve it, even though your ReactOS code now has a workaround for it? See the links below.

Thanks again!

jbe ReadSectorsSetupDiskAddressPacket // If we are reading less than 9 sectors then just do the read
mov cx, 8 // Otherwise read only 8 sectors on this loop iteration

ReadSectorsSetupDiskAddressPacket:
mov word ptr [bp-2], cx
@@ -283,7 +283,8 @@ SetTreeRoots:
mov byte ptr [esp-1], ROOT_ITEM_KEY
dec sp
push eax
data32 push FS_TREE_OBJECTID
push 0
push FS_TREE_OBJECTID
call SearchTree
add sp, 17 // setting stack back

@@ -299,7 +300,7 @@ SetTreeRoots:
// finding EXTENT_TREE root
//pop cx
//pop si

// put the key on stack
//data32 push 0
//data32 push 0
@@ -329,7 +330,8 @@ SetTreeRoots:
mov byte ptr [esp-1], DIR_ITEM_KEY
dec sp
push eax
data32 push 256 // root dir objectid
push 0
push 256 // root dir objectid
call SearchTree
add sp, 17 // setting stack back

@@ -512,7 +514,7 @@ SearchTree_readHeader:
mov es, bx

// every node begins with header
//mov ax, word ptr [DATA_BUFFER_OFFSET + HEX(60)] // number of items in this leaf
//mov ax, word ptr [DATA_BUFFER_OFFSET + HEX(60)] // number of items in this leaf
mov cx, -1 // index
xor di, di
// finding the key
@@ -548,7 +550,7 @@ SearchTree_readLeaf:
mov es, bx

// every node begins with header
//mov ax, word ptr [DATA_BUFFER_OFFSET + HEX(60)] // number of items in this leaf
//mov ax, word ptr [DATA_BUFFER_OFFSET + HEX(60)] // number of items in this leaf
mov cx, -1 // index
xor di, di
// finding the key
@@ -565,7 +567,7 @@ SearchTree_findLoop_2:
je SearchTree_foundEqual

// set pointer to previous element if greater
sub si, 25
sub si, 25

SearchTree_foundEqual:
// found equal or greater key
@@ -598,7 +600,7 @@ ConvertAddress_loop:

cmp cl, byte ptr [ChunkMapSize]
jge ConvertAddress_checkInclusion // greater chunk is not found in chunk map - checking the last one

lea di, [di+4] // set to the second dword the 8-byte number
lea si, [si+4]
inc cl
@@ -662,15 +664,16 @@ ConvertAddress_notFound:
mov byte ptr [esp-1], CHUNK_ITEM_KEY
dec sp
data32 push 0
data32 push FIRST_CHUNK_TREE_OBJECTID
push 0
push FIRST_CHUNK_TREE_OBJECTID
call SearchTree
add sp, 17 // setting stack back

mov ax, si // found key pointer
call InsertChunk
pop di
jmp ConvertAddress_secondTry // TODO: do not fall into endless loop here


// eax - key size
// ecx - key index
@@ -711,7 +714,7 @@ CompareKeys_end:
pop di
ret



btrfsSignature:
.ascii "_BHRfS_M"

0 comments on commit 8ae62c1

Please sign in to comment.
You can’t perform that action at this time.