-
Notifications
You must be signed in to change notification settings - Fork 155
Description
As I discussed in a dosemu2 issue: dosemu2/dosemu2#1816 (comment)
Line 1935 in 5de2eb1
if (r.AH == 0x4a) I don't understand the if (tsize < size) in my last reference. Shouldn't it check for the requested size being larger and fail the allocation then?
Also another comment by me: dosemu2/dosemu2#1816 (comment)
MS-DOS v5 returns an error (DI = -1) if you try to allocate more than there is available space. So it's valid to never query the size, just init BX with the size you want and try to allocate it. It seems both fdpp and FreeDOS get that wrong, certainly FreeDOS allocates the available size and returns a BX < the requested size.
During my tests I also found that FreeDOS seems to keep track of a byte-granular size and offset, whereas MS-DOS v7 deals in paragraphs. MS-DOS v5 also seems to round everything to paragraphs.
Currently the kernel will allocate HMA space unconditionally in 2F.4A02, shrinking the allocation to whatever space is available if the input in BX is too large. Original MS-DOS (v5 and v7 both) will error out and set DI to FFFFh instead if the requested size cannot be satisfied.
The problem of not aligning allocation offsets + sizes on paragraph boundaries is less critical but may also cause incompatibilities with programs expecting aligned addresses.
I will likely prepared a PR to fix this soon.