Skip to content

Issues on copying files on PC-98 with LOADALL? #2398

Open

Description

@tyama501

This is sub issue from
#2389 (comment)

I have booted from 1232k floppy and confirmed
mount /dev/hda1 /mnt
cp /bin/* /mnt/tmp

gets the same stuck problem if
hma=kernel
xms=on
#xms=int15

It succeeded if
#hma=kernel
#xms=on
#xms=int15
or
hma=kernel
#xms=on
#xms=int15
or
#hma=kernel
xms=on
xms=int15

So, it looks LOADALL problem.

Thank you.

Activity

  1. tyama501 commented on Oct 11, 2025

    @tyama501
    ContributorAuthor

    I have tried one more variation, using LOADALL

    #hma=kernel
    xms=on
    #xms=int15

    Unexpectedly this succeeded.

    It might only occurrs when hma=kernel and LOADALL both are enabled.

  2. tyama501 commented on Oct 11, 2025

    @tyama501
    ContributorAuthor

    Hmm, something still might be wrong with above case too. I couldn't remove some files properly.
    (EDIT: some wrong files have been created)

    Image

  3. ghaerr commented on Oct 11, 2025

    @ghaerr
    Owner

    Perhaps try copying floppy to floppy (instead of hard disk) or to same floppy to make sure problem isn't the hard disk driver or differing sector sizes.

  4. tyama501 commented on Oct 11, 2025

    @tyama501
    ContributorAuthor

    Hello @ghaerr ,

    I need to prepare another floppy disk so I will try that later but
    is there difference using int1F or LOADALL on the driver?
    (It looks int1F is working.)

    Thank you.

  5. ghaerr commented on Oct 11, 2025

    @ghaerr
    Owner

    Hello @tyama501,

    There shouldn't be any explicit difference in the driver between INT 1F and LOADALL, they are both handled underneath the xms_fmemcpy function call. We can take a deeper look at that when a more definitive error case is found.

    From your screenshot above, it looks like the /mnt/tmp directory entries have been written with garbage. You might try ls /mnt/tmp to get a better look.

    Whether this is related to INT 1F, LOADALL or possibly sector size differences between FD1232k and HD is hard to tell at this point. LOADALL is a non-BIOS rewrite of the BIOS INT 1F call. I had thought we tested LOADALL pretty heavily, but it's always possible a register was not saved or perhaps another area of memory being overwritten (IIRC the LOADALL CPU buffer is directly next to DMA buffer?) Also could be related to HMA as you have seen. At this point, reducing variables and keeping error reproduction as simple as possible will help.

    Does this occur only on real hardware, or can you duplicate on Neko or DosBox-X?

    Thank you!

  6. tyama501 commented on Oct 12, 2025

    @tyama501
    ContributorAuthor

    Neko looks ok. It is using UNREAL mode.

    EDIT:
    fsck-dos.os2 after copying files from fd1232 to hda1 on Neko.
    Image

    Thank you.

  7. drachen6jp commented on Oct 12, 2025

    @drachen6jp
    Contributor

    Hello.@ghaerr. Hello.@tyama501
    I wrote Loadall code before.
    I did find bug on loadall.S.
    line 174
    mov %bx,%es:(0x30) #BX is block operation code
    830h does'nt mean BX register
    and line 176
    //mov %dx,%es:(0x2e) #the following not required to be preserved
    82eh also doesn7t mean DX register.

    these are reverse.
    thank you!

  8. ghaerr commented on Oct 12, 2025

    @ghaerr
    Owner

    Hello @drachen6jp,

    Wow! Very nice catch on incorrect registers being setup in loadall routine!!! What is most surprising to me is that this ever worked in the first place, since the value of DX (instead of BX) was being used to determine the BX operations code (0=copy, 1=clear).

    Hello @tyama501, I have made the following patch for your testing and will commit it shortly:

    diff --git a/elks/arch/i86/lib/loadall.S b/elks/arch/i86/lib/loadall.S
    index cce9a833..a8c32335 100644
    --- a/elks/arch/i86/lib/loadall.S
    +++ b/elks/arch/i86/lib/loadall.S
    @@ -171,9 +171,9 @@ loadall_block_op:
            mov     %sp,%es:(0x2c)
            //mov   %di,%es:(0x26)  #comment out sets SI, DI zero for REP MOVS
            //mov   %si,%es:(0x28)
    -       mov     %bx,%es:(0x30)  #BX is block operation code
    +       mov     %bx,%es:(0x2e)  #BX is block operation code
            mov     %cx,%es:(0x32)  #CX is byte count for block operation
    -       //mov   %dx,%es:(0x2e)  #the following not required to be preserved
    +       //mov   %dx,%es:(0x30)  #the following not required to be preserved
            //mov   %ax,%es:(0x34)
            .byte   0x0F,0x05       #loadall opcode - execution continues at new IP
            # not reached
    

    Hopefully this fix the problem you are seeing with the copy.

    Thank you!

  9. ghaerr commented on Oct 12, 2025

    @ghaerr
    Owner

    Hello @drachen6jp,

    What is most surprising to me is that this ever worked in the first place

    After studying a bit more, I think the reason it worked with wrong programming is that the DX value was never saved (for speed reasons, since it is allowed be clobbered), thus the value of BX was always being set to 0 since 0830 was always 0. This caused operation to always be COPY. When filesystem sometimes issued command for CLEAR, this would either corrupt buffer by not zeroing or copy to invalid locations in passed GDT, crashing system.

    Thank you!

  10. ghaerr commented on Oct 12, 2025

    @ghaerr
    Owner

    fsck-dos.os2 after copying files from fd1232 to hda1 on Neko.

    It would be interesting to see the results of fsck-dos.os2 on hda1 damaged by LOADALL problem on real hardware or Neko running LOADALL mode. This would tell us more about how good a disk checker fsck-dos really is.

  11. tyama501 commented on Oct 13, 2025

    @tyama501
    ContributorAuthor

    Hello @ghaerr and @drachen6jp ,

    I got a good news and a bad news.

    First of all, here is the fsck-dos.os2 result requested by @ghaerr of the broken files.
    Does the fsck modify the boot block signature? It says so after running it once although it can still boot.
    Image

    [good news]
    I could install and copy files using LOADALL when
    #hma=kernel
    xms=on
    #xms=int15
    Thank you!

    Image

    [bad news]
    It still get stuck if I enable hma=kernel when copying.

    Image

    I tried cp -v /bin/* /mnt/tmp/ a couple of times
    and once I have gotten A20 LINE ERROR (hardware message from PC-98).
    Image
    Other time it just stuck here.
    Image

  12. ghaerr commented on Oct 13, 2025

    @ghaerr
    Owner

    [good news]
    I could install and copy files using LOADALL when
    #hma=kernel
    xms=on

    That is good news, so @drachen6jp's LOADALL fix is working.

    [bad news]
    It still get stuck if I enable hma=kernel when copying.
    once I have gotten A20 LINE ERROR (hardware message from PC-98).

    I am guessing this is a separate issue from LOADALL. This could easily be caused by the PC98 BIOS if it switches A20 line for any reason while ELKS is running.

    Did PC-98 work well before using xms=on (not xms=int15?).

    Next step would be testing without XMS but with HMA:

    hma=kernel
    #xms=on
    #xms=int15
    

    I would also guess that hma=kernel will work fine with xms=int15, but that should also be tested. If BIOS uses A20 switch ever, then running kernel in HMA won't work, as the timer interrupt could cause interrupt into HMA area when A20 is OFF.

  13. ghaerr commented on Oct 13, 2025

    @ghaerr
    Owner

    First of all, here is the fsck-dos.os2 result requested by @ghaerr of the broken files.
    Does the fsck modify the boot block signature? It says so after running it once although it can still boot.

    That is interesting, we are just starting to learn about fsck-dos, since it hasn't been used much before on corrupted filesystems, it seems. I was unaware it tries to rewrite boot block, but it seems to do so.

    I can see how fsck might complain on 1232k floppies with 1024 byte sectors, since AA55 would be in wrong place (although I think PC98 boot still has additional boot marker both at 510 and 1022, right?). But this seems to be on hard disk with 512 byte sectors, correct?

    A quick test would be to use hd /dev/hda1 | more to inspect the first 512 bytes of image when corrupted. Then look to see what bytes 510-511 look like before and after corruption/fsck.

  14. ghaerr commented on Oct 14, 2025

    @ghaerr
    Owner

    once I have gotten A20 LINE ERROR (hardware message from PC-98).

    It is curious that PC98 BIOS has error message for A20 line error: this would seem to me that the BIOS cares about the state of A20 line, which likely also means it requires A20 to be in different states? If so, this would answer why hma=kernel is not and won't work on PC98. Is there any BIOS documentation about A20 use that you have seen?

  15. 48 remaining items

  16. ghaerr commented on Nov 23, 2025

    @ghaerr
    Owner

    Hello @tyama501,

    NMI occurs at the parity error of the extended RAM and it can be disabled by I/O 0050h.

    I see. Yes, I would recommend that any NMI interrupt be disabled at kernel startup (this could be done in the ifdef PC98 bios init code for now), if there is no NMI handler installed to catch the interrupt.

    It seems that interrupt vector for x86 NMI is INT 02 but we don't have this handler, right?

    Not presently, but it could easily be added. See the following code, used for handling the INT 00 divide-by-zero handler in irq.c:

        /* install direct panic-only DIV fault handler until known that
         * the _irqit version doesn't overwrite the stack
         */
        int_handler_add(IDX_DIVZERO, 0x00, div0_handler_panic);
    

    This could be further expanded for PC98 using an IDX_NMI and nmi_handler entry point, similar to divzero.c to display or panic when an NMI occurs. Or it might be better to write an ASM nmi-pc98.S handler that just executes IRET, after determining how it works. It might be a bit tricky to test!

    Thank you.

  17. tyama501 commented on Nov 23, 2025

    @tyama501
    ContributorAuthor

    Thank you.

    Maybe adding handler and show some message is preferable.
    I will try that when I get another time.

  18. tyama501 commented on Nov 24, 2025

    @tyama501
    ContributorAuthor

    Hello @ghaerr

    Looking at the codes,
    IDX_DIVZERO is defined as 17 in irq.h and NR_IRQ is 18.
    How are these numbers determined?
    To add IDX_NMI, do we need to set it as 18 and redefine NR_IRQ to 19?

  19. ghaerr commented on Nov 24, 2025

    @ghaerr
    Owner

    To add IDX_NMI, do we need to set it as 18 and redefine NR_IRQ to 19?

    I think so, try that. I will look more when I have time. Thank you.

  20. tyama501 commented on Dec 6, 2025

    @tyama501
    ContributorAuthor

    Hello @ghaerr ,

    I have added NMI handler as below but unfortunately I couldn't detect any evidence that NMI is occurring.
    (No message appeared.)
    tyama501@bed5e4d

    I may leave this problem until some other user gets same situation,
    since it works great if hma or xms is disabled.

    Thank you.

  21. ghaerr commented on Dec 6, 2025

    @ghaerr
    Owner

    Hello @tyama501,

    I have added NMI handler as below but unfortunately I couldn't detect any evidence that NMI is occurring.

    Looks good. You're welcome to submit the enhancement with a PR if you like, even though so far nothing has occurred.

    I may leave this problem until some other user gets same situation,
    since it works great if hma or xms is disabled.

    Ok. I'm thinking that the PC98 BIOS is somehow changing the A20 line state, since the screen did show an A20 line error from the BIOS. Given that, it seems perhaps best idea would be to disable HMA for PC98, and leave XMS enabled. By default, /bootopts enables both, I'm not sure the best way to handle that yet for distribution images?

    Thank you!

  22. tyama501 commented on Dec 7, 2025

    @tyama501
    ContributorAuthor

    Hello @ghaerr
    I will make a PR for NMI later.

    Actually, I found today just enabling XMS is not perfect.
    It crashes filesystem if I do ramdisk /dev/ssd make ***. (Unable to access /bin if I do this)

    It woks on 386 Neko project.

    Also the available conventional memory is greater for hma enable and xms disabled.

    Currently all phenomena is happening only on my system. (Although maybe I am the only one testing...)
    So, I am not sure what the best setting for now. (maybe leave as is ...)

    EDIT:
    It is hard to change bootopts with IBM vs PC98, right?

    Thank you.

  23. tyama501 commented on Dec 7, 2025

    @tyama501
    ContributorAuthor

    It crashes filesystem if I do ramdisk /dev/ssd make ***. (Unable to access /bin if I do this)

    Above is the hma disabled and xms enabled case.

    When both hma and xms are enabled, I got panic.
    It says bad blkdev.

    Image

    One thing that my PC-98 system is different from the emulators and/or IBM systems
    is my PC-98 has 3 floppy drives for block device.

  24. tyama501 commented on Dec 7, 2025

    @tyama501
    ContributorAuthor

    (Well, there might be real bad memory on some part. If so, that make sense hma and xms both enabled then address moves or using ramdisk for more xms causing problem. Also that make sense @drachen6jp didn't see this problem before.)

  25. ghaerr commented on Dec 7, 2025

    @ghaerr
    Owner

    Are both the above xms tests done with xms=on or xms=int15 in /bootopts?

    Yes, it appears that PC98 is not working with XMS. It could be RAM problem not sure. Can you post what xms: ... boot line displays? It is possible PC98 may be reporting XMS memory at wrong address?

    With #xms= in /bootopts (xms OFF), and hma=kernel, does your PC98 always operate without errors?

  26. tyama501 commented on Dec 7, 2025

    @tyama501
    ContributorAuthor

    Hello @ghaerr

    I already shutdown my PCs today but I also have tried int15.
    It is a little bit different from previous case and it succeeded the ramdisk command and mkfat but when I copied files something is wrong.

  27. tyama501 commented on Dec 7, 2025

    @tyama501
    ContributorAuthor

    I would like to change my memory board if possible... but maybe not so soon...

  28. tyama501 commented on Jan 11, 2026

    @tyama501
    ContributorAuthor

    (Well, there might be real bad memory on some part. If so, that make sense hma and xms both enabled then address moves or using ramdisk for more xms causing problem. Also that make sense @drachen6jp didn't see this problem before.)

    Hello @ghaerr ,

    It seems that my system works better if I reduce
    CONFIG_FS_NR_XMS_BUFFERS from 500 to 256.
    (copy works well, ramdisk works well if small minixfs is used for the ssd. FAT ssd is still strange but it might be different problem)

    It might be just my memory board or chip issue around 500KB,
    but I may reduce the value of pc98_*.config later just in case.

    Thank you.

  29. ghaerr commented on Jan 11, 2026

    @ghaerr
    Owner

    Hello @tyama501,

    Thanks for the information and test results. I would agree this sounds like a possible hardware memory problem. You're welcome to change PC98 default configuration values to work better for you, also just in case this is not hardware memory problem.

    Is there a way you can swap chips on the memory card to further test?

    Thank you!

  30. tyama501 commented on Jan 12, 2026

    @tyama501
    ContributorAuthor

    Thank you @ghaerr ,

    I don't think I can swap chips, but I may swap cards or get new cards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugDefect in the product

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions