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

parser: add missed diskette geometry parsing #1312

Open
wants to merge 2 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/base/init/lexer.l
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ threeinch_2880 RETURN(THREEINCH_2880);
threeinch_720 RETURN(THREEINCH_720);
fiveinch RETURN(FIVEINCH);
fiveinch_360 RETURN(FIVEINCH_360);
customdiskette RETURN(CUSTOMDISKETTE);
boot RETURN(BOOT);
sectors RETURN(SECTORS);
cylinders RETURN(CYLINDERS);
Expand Down
8 changes: 7 additions & 1 deletion src/base/init/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ enum {
%token L_PARTITION WHOLEDISK
%token SECTORS CYLINDERS TRACKS HEADS OFFSET HDIMAGE HDTYPE1 HDTYPE2 HDTYPE9 DISKCYL4096
/* floppy */
%token THREEINCH THREEINCH_720 THREEINCH_2880 FIVEINCH FIVEINCH_360 READONLY BOOT
%token THREEINCH THREEINCH_720 THREEINCH_2880 FIVEINCH FIVEINCH_360 READONLY BOOT CUSTOMDISKETTE
%token DEFAULT_DRIVES SKIP_DRIVES
/* ports/io */
%token RDONLY WRONLY RDWR ORMASK ANDMASK RANGE FAST SLOW
Expand Down Expand Up @@ -1500,6 +1500,12 @@ floppy_flag : READONLY { dptr->wantrdonly = 1; }
| THREEINCH_720 { dptr->default_cmos = THREE_INCH_720KFLOP; }
| FIVEINCH { dptr->default_cmos = FIVE_INCH_FLOPPY; }
| FIVEINCH_360 { dptr->default_cmos = FIVE_INCH_360KFLOP; }
| CUSTOMDISKETTE { dptr->default_cmos = CUSTOM_DISKETTE; }
| SECTORS expression { dptr->sectors = $2; }
| CYLINDERS expression { dptr->tracks = $2; }
| TRACKS expression { dptr->tracks = $2; }
| HEADS expression { dptr->heads = $2; }
| OFFSET expression { dptr->header = $2; }
| BOOT { dptr->boot = 1; }
| L_FLOPPY string_expr
{
Expand Down
6 changes: 4 additions & 2 deletions src/base/misc/disks.c
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,8 @@ static void image_auto(struct disk *dp)
leavedos(19);
return;
}
if (!(set_floppy_chs_by_size(st.st_size, dp) ||
if (!(dp->default_cmos == CUSTOM_DISKETTE ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just check above (at line 499)
that chs already set (all values != 0)
and then return immediately?
Looks much simpler than adding another
keyword.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we do want the dp->num_secs = line that comes later, to calculate the total (CHS-addressable) size though?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds reasonable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So would you like to do that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will get around to it eventually. Still considering how to fix the HD image geometry specifiers too. They're also broken. For example, if we set cylinders X heads Y sectors Z (all specified) then in disk_reset2 the conditional is not taken, and thus num_secs is never initialised (stays zero) which makes read_sectors fail.

set_floppy_chs_by_size(st.st_size, dp) ||
set_floppy_chs_by_type(dp->default_cmos, dp)) ){
d_printf("IMAGE auto set floppy geometry %s\n", dp->dev_name);
leavedos(19);
Expand Down Expand Up @@ -685,7 +686,8 @@ static void floppy_setup(struct disk *dp)
static void dir_auto(struct disk *dp)
{
if (dp->floppy) {
if (!set_floppy_chs_by_type(dp->default_cmos, dp))
if (!(dp->default_cmos == CUSTOM_DISKETTE ||
set_floppy_chs_by_type(dp->default_cmos, dp)))
d_printf("DIR: Invalid floppy disk type (%d)\n", dp->default_cmos);
else
d_printf("DIR: Selected floppy disk type (%s)\n",
Expand Down
1 change: 1 addition & 0 deletions src/include/disks.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ typedef enum {
THREE_INCH_720KFLOP, /* 3.5 in, 720 kB floppy */
THREE_INCH_FLOPPY, /* 3.5 in, 1.44 MB floppy */
THREE_INCH_2880KFLOP, /* 3.5 in, 2.88 MB floppy */
CUSTOM_DISKETTE,
} floppy_t;

const char *floppy_t_str(floppy_t t);
Expand Down