Skip to content

Allocate one drive per available active partition at boot time#196

Merged
Konamiman merged 3 commits intov3.0from
drive-per-partition
Feb 12, 2026
Merged

Allocate one drive per available active partition at boot time#196
Konamiman merged 3 commits intov3.0from
drive-per-partition

Conversation

@Konamiman
Copy link
Copy Markdown
Owner

@Konamiman Konamiman commented Feb 12, 2026

Previously Nextor would allocate one drive per device allocated to a Nextor kernel at boot time; and if there were partitions with the "active" bit set in the partition table (bit 7 of the first byte), the first of these would be the partition that was assigned to the drive. The active status of a partition can be changed with FDISK.

With this change, the suitable active partitions for each device are counted at boot time and each get a drive. "Suitable partitions" are FAT12 and FAT16 partitions, except when booting in DOS 1 mode via pressing the 1 key (or the 2 key in Turbo-R): in these cases only FAT12 partitions are considered:

There are a couple of edge cases when booting in DOS 1 mode:

  • DOS 1 mode is entered via any mechanism that is not the 1 key or the 2 key (64K RAM only, or DOS 1 style boot sector in A:)
  • FAT12 partition over 16MB

In these cases there will be drives assigned to the device that won't get mapped to any partition at boot time: one for each FAT12 partition over 16MB in the second case, and additionally, one for each FAT16 partition in the first case.

Additional change: if DOS detects that it's running out of available page 3 space when booting in DOS 1 mode, it will stop allocating new drives instead of displaying a "Not enough memory" message and freezing.

Closes #196.

AI usage

The development of this feature has been assisted by an AI agent (Claude). For educational purposes, a transcript of the initial session with the agent is included in this pull request:

When booting in DOS 1 mode (1 or 2 key pressed), take in account
FAT12 partitions only. Otherwise, take in account FAT16 partitions too.

For devices that don't have valid partitions, or that are offline
and removable, assign only one drive as usual.
This replaces the previous "Note enough memory" message
@github-project-automation github-project-automation bot moved this to Backlog in Nextor 3 Feb 12, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 12, 2026

📝 Walkthrough

Walkthrough

This PR enhances kernel boot initialization across two files: it adds pre-allocation memory safety checks in dos1ker.mac to prevent FAT buffer allocation when insufficient HIMEM remains, and refactors boot-time device/partition discovery in partit.mac with a new partition-counting routine that enumerates suitable FAT12/FAT16 partitions on devices during startup.

Changes

Cohort / File(s) Summary
FAT Buffer Memory Safety
source/kernel/bank3/dos1ker.mac
Added pre-allocation guard checks against C500h threshold before FAT buffer allocation. Introduced NO_FAT_MEM recovery block to handle allocation failures and gracefully degrade drive count if memory insufficient.
Boot-time Partition Discovery
source/kernel/bank4/partit.mac
Introduced F_GPART_INNER entry point for early-boot partition queries, and added COUNT_DEVICE_PARTITIONS routine with supporting helpers (CDP_* and IS_SUITABLE_PART_TYPE) to enumerate suitable FAT12/FAT16 partitions on devices during startup.

Sequence Diagram(s)

sequenceDiagram
    participant Boot as Boot Process
    participant Dev as Device
    participant PT as Partition Table
    participant PS as Partition Scanner
    participant Type as Type Checker
    
    Boot->>Dev: Enumerate Device
    Dev->>PT: F_GPART_INNER (Get Partition)
    PT-->>Dev: Partition Data
    Dev->>PS: COUNT_DEVICE_PARTITIONS
    PS->>PT: CDP_GPART_PRI (Primary Partition)
    PT-->>PS: Partition Entry
    PS->>Type: IS_SUITABLE_PART_TYPE
    Type-->>PS: FAT12/FAT16?
    alt Suitable
        PS->>PS: Increment Count
    end
    PS->>PT: CDP_SCAN_EXTENDED (Check Extended)
    PT-->>PS: Extended Chain Entries
    PS-->>Dev: Total Partition Count
    Dev->>Boot: Drive Count Updated
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐇 The kernel wakes with memory care,
Partitions counted everywhere,
FAT tables checked before they grow,
Safety guards stand firm and slow,
Boot time blooms with partition grace! 🌱✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main objective of the pull request—allocating one drive per available active partition at boot time, which is the central change across both modified files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch drive-per-partition

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Konamiman Konamiman added this to the v3.0.0 alpha 1 milestone Feb 12, 2026
@Konamiman Konamiman merged commit 729374d into v3.0 Feb 12, 2026
1 check failed
@github-project-automation github-project-automation bot moved this from Backlog to Done in Nextor 3 Feb 12, 2026
Konamiman added a commit that referenced this pull request Feb 12, 2026
@coderabbitai coderabbitai bot mentioned this pull request Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant