Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Impossible to implement phantom drive properly #54

Closed
Eugeny1 opened this issue May 6, 2020 · 6 comments
Closed

Impossible to implement phantom drive properly #54

Eugeny1 opened this issue May 6, 2020 · 6 comments
Assignees
Labels
enhancement New feature or request fixplemented This bug has already been fixed/this feature has already been implemented in a released version

Comments

@Eugeny1
Copy link

Eugeny1 commented May 6, 2020

The problem starts just at the system start: after DRV_CONFIG is finished, kernel tries to identify the contents of the media in the drives reading boot sectors, however as there's only one diskette drive and another one is phantom, this action causes messages

DSCN2265-1

as kernel has no idea that these drive letters are the same physical drive. It is not possible to overcome at the driver level, and requires changes in the kernel.

Second issue, where to obtain current the letter of the current device to display the prompt: YF33F seems to contain invalid information when device enumeration is being performed (see prompt strings above - for all the devices enumerated YF33F has value of 0). However it seems to contain correct drive letter reference when booting is started.

Third issue, at some point in time (when booting is attempted) the PROMPT hook XF24F is set with jump to somewhere, and machine crashes. When device enumeration is performed before this event, the hook properly contains the RET.

DSCN2271-1

On the pictures -Dx means calling the prompt checking routine for the device x. If prompt is going to be displayed, routine also displays contents of 3 bytes starting XF24F. The first pictures show C9C9C9, while second at the top shows jump to some address EAC6. The jump to this EAC6 ends at some Nextor kernel location displaying arbitrary strings from built-in FDISK application.

Also you can see as soon as booting process started and DOS2 is loaded, YF33F contains correct reference to device current number (as it starts displaying A: and B: in the prompt).

@Eugeny1
Copy link
Author

Eugeny1 commented May 8, 2020

The solution to this problem is setting up two flags in the LUN_INFO:

  • phantom device flag;
  • not bootable device flag.

It is generally possible to merge these two flags into the one flag (phantom/non-bootable) if Nextor is not going to implement phantom drives and will leave this task to the driver. If driver sets this flag, device is not attempted to be booted from.

@Konamiman Konamiman added due in next version This will be fixed/implemented in the next version enhancement New feature or request labels Jul 11, 2020
@Konamiman Konamiman self-assigned this Jul 11, 2020
@Konamiman
Copy link
Owner

Konamiman commented Jul 11, 2020

Final version of Nextor 2.1.0 will provide:

  • A callable PROMPT routine.
  • A new flag returned by LUN_INFO that means "skip device when searching for candidate drives for automapping"

Those two should allow to implement the functionality that you mention.

@Eugeny1
Copy link
Author

Eugeny1 commented Jul 12, 2020

Unfortunately this did not solve the problem of the "insert diskette" at the startup. Driver, in its DEV_STAT routine, still asks to insert phantom disk into logical drive to get its status because kernel asks for the status of the phantom drive/LUN.
Is it possible to exclude phantom drive from the status querying at the startup?

@Konamiman
Copy link
Owner

Please look at how the Rookie Drive FDD does it: https://github.com/Konamiman/RookieDrive-FDD-ROM/blob/master/msx/bank1/misc.asm#L128 - that CHECK_SAME_DRIVE routine is executed both when performing sector read/writes and when checking for disk change status.

Basically:

  • You need to keep a variable (in page 3 work area for the driver, unless your hardware has its own RAM) holding the last drive number accessed (in your case I guess it would be the last device number accessed, and only when that device either has a phantom sibling or is a phantom itself).
  • Then in DEV_STATUS and DEV_RW you check the requested device and if it's not the same as the one stored, you invoke PROMPT.
  • At the end of these routines you update the variable, regarldess of whether you called PROMPT or not.

@Eugeny1
Copy link
Author

Eugeny1 commented Jul 13, 2020

The driver does exactly this you describe.
Let me explain the problem again.

Look at the very top picture of my original post. You can see machine says "-D1", then "-D2", then 3 hex codes and "insert diskette". "-Dx" is kernel invoking DEV_STATUS routine. Thus when kernel starts, it tries to obtain the status of the all devices, and calls DEV_STATUS several times. Of course, as soon as it calls DEV_STATUS for phantom device (-D2), driver sees that kernel selects another logical floppy drive (phantom one) and displays "insert diskette".

Now look further into the picture. Kernel obtains status of other devices (-D3, -D4 ... -D7), driver displays nothing because these devices do not exist or they have no phantoms.

Then kernel again tries to obtain status of primary drive (-D1), causing another "insert diskette" prompt because last drive accesses was drive 2 (phantom drive when querying its status).

Then again, kernel queries phantom drive for status "-D2" and driver displays another "insert diskette" message.

Now look at the second picture. Before booting. kernel again checks the status of the device 1 (primary floppy, "-D1"), but as it was querying status of phantom before, this causes another "insert diskette" message.

Thus there're in total 5 "insert diskette" messages appearing when Nextor kernel starts.
If kernel does not check status of phantom drives at its start (as obviously it will not be going to do anything with them at this stage), these messages would not appear.

I hope it is clearer now.

Konamiman added a commit that referenced this issue Jul 26, 2020
- Fix: broken RAM disk (introduced in RC1).
- Fix: disk errors for old MSX-DOS 1 file functions in BASIC crash the computer (#59).
- Add: new flag returned by LUN_INFO allows to instruct Nextor to ignore devices when searching devices for automatic device to drive mapping (#54).
- Fix: files can't have 3 or 4 in their names in DOS 1 mode (#55).
- Fix: after booting directly yo BASIC by pressing 3, CALL SYSTEM doesn't work.
- Fix: slot disable keys don't work on real MSX computers (#49).
- Add: new boot key, pressing N at boot time disables all the Nextor kernels present.
- Add: default DPB gets a fixed address of 7BAAh in banks 0 and 3, so it can be customized reliably.
- Add: PROMPT routine made available to drivers at address 41E8h (#42).
- Fix: the DOS 1 variables "data buffer changed" and "redirect console output to printer" were not zeroed when switching to DOS 1 mode at boot time.
- Fix: can't change volume name when there are long filename entries in the root directory (#57).
- Fix: absolute sector read/write functions not working properly when a file is mounted to a drive (#43).
- Fix: bad sector buffer management when writing to a mounted file causing data corruption on the mounted file (#58).
- Fix: drive parameters not updated on first access to a drive after a media change if the driver provides drive mapping via DRV_CONFIG, causing bad data read (#45).
@Konamiman
Copy link
Owner

Implemented in v2.1.0 ("ignore when auto-assigning" flag in LUN_INFO)

@Konamiman Konamiman added fixplemented This bug has already been fixed/this feature has already been implemented in a released version and removed due in next version This will be fixed/implemented in the next version labels Aug 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request fixplemented This bug has already been fixed/this feature has already been implemented in a released version
Projects
None yet
Development

No branches or pull requests

2 participants