Skip to content

Commit

Permalink
[kernel] Use MAJOR_NR in blk.h to select block device
Browse files Browse the repository at this point in the history
  • Loading branch information
ghaerr committed Oct 3, 2023
1 parent 14cae1c commit 267d100
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 27 deletions.
1 change: 0 additions & 1 deletion elks/arch/i86/drivers/block/bioshd.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
#define MAX_ERRS 5 /* maximum sector read/write error retries */

#define MAJOR_NR BIOSHD_MAJOR
#define BIOSDISK
#include "blk.h"

struct elks_disk_parms {
Expand Down
22 changes: 6 additions & 16 deletions elks/arch/i86/drivers/block/blk.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,27 +51,23 @@ extern void resetup_one_dev(struct gendisk *dev, int drive);
* hard-disks, floppies, SSD and ramdisk.
*/

#ifdef RAMDISK
#if (MAJOR_NR == RAM_MAJOR)

/* ram disk */
#define DEVICE_NAME "rd"
#define DEVICE_REQUEST do_rd_request
#define DEVICE_NR(device) ((device) & 1)
#define DEVICE_OFF(device)

#endif

#ifdef SSDDISK
#elif (MAJOR_NR == SSD_MAJOR)

/* solid-state disk */
#define DEVICE_NAME "ssd"
#define DEVICE_REQUEST do_ssd_request
#define DEVICE_NR(device) ((device) & 0)
#define DEVICE_OFF(device)

#endif

#ifdef FLOPPYDISK
#elif (MAJOR_NR == FLOPPY_MAJOR)

static void floppy_off(int nr);

Expand All @@ -80,27 +76,21 @@ static void floppy_off(int nr);
#define DEVICE_NR(device) ((device) & 3)
#define DEVICE_OFF(device) floppy_off(DEVICE_NR(device))

#endif

#ifdef ATDISK
#elif (MAJOR_NR == ATHD_MAJOR)

#define DEVICE_NAME "hd"
#define DEVICE_REQUEST do_directhd_request
#define DEVICE_NR(device) (MINOR(device)>>6)
#define DEVICE_OFF(device)

#endif

#ifdef BIOSDISK
#elif (MAJOR_NR == BIOSHD_MAJOR)

#define DEVICE_NAME "bioshd"
#define DEVICE_REQUEST do_bioshd_request
#define DEVICE_NR(device) (MINOR(device)>>MINOR_SHIFT)
#define DEVICE_OFF(device)

#endif

#ifdef METADISK
#elif (MAJOR_NR == UDD_MAJOR)

#define DEVICE_NAME "udd"
#define DEVICE_REQUEST do_meta_request
Expand Down
9 changes: 4 additions & 5 deletions elks/arch/i86/drivers/block/directfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,11 @@
#include <arch/ports.h>
#include <arch/hdreg.h> /* for ioctl GETGEO */

#define FLOPPYDISK
#define MAJOR_NR FLOPPY_MAJOR
#define MINOR_SHIFT 0 /* shift to get drive num */
#define FLOPPY_DMA 2 /* hardwired on old PCs */
#define MAJOR_NR FLOPPY_MAJOR
#include "blk.h"

#include "blk.h" /* ugly - blk.h contains code */
#define MINOR_SHIFT 0 /* shift to get drive num */
#define FLOPPY_DMA 2 /* hardwired on old PCs */

/*
* The original 8272A doesn't have FD_DOR, FD_DIR or FD_CCR registers,
Expand Down
3 changes: 1 addition & 2 deletions elks/arch/i86/drivers/block/rd.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
#include <linuxmt/fs.h>
#include <linuxmt/debug.h>

#define MAJOR_NR RAM_MAJOR
#define RAMDISK
#define MAJOR_NR RAM_MAJOR
#include "blk.h"

#define MAX_DRIVES 2 /* # ram drives*/
Expand Down
3 changes: 1 addition & 2 deletions elks/arch/i86/drivers/block/ssd.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
#include <linuxmt/errno.h>
#include <linuxmt/debug.h>

#define MAJOR_NR SSD_MAJOR
#define SSDDISK
#define MAJOR_NR SSD_MAJOR
#include "blk.h"
#include "ssd.h"

Expand Down
2 changes: 1 addition & 1 deletion elks/include/linuxmt/major.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
#define RAM_MAJOR 1
#define SSD_MAJOR 2
#define BIOSHD_MAJOR 3
#define FLOPPY_MAJOR 4 /* experimental*/
#define FLOPPY_MAJOR 4
#define ATHD_MAJOR 5 /* experimental*/
#define ROMFLASH_MAJOR 6

Expand Down

0 comments on commit 267d100

Please sign in to comment.