Skip to content

Commit

Permalink
Merge pull request #26 from reinauer/MBRnGPT
Browse files Browse the repository at this point in the history
MBR and GPT support
  • Loading branch information
reinauer authored Dec 4, 2023
2 parents d46a9af + 9ee67ec commit 4aedb46
Show file tree
Hide file tree
Showing 10 changed files with 575 additions and 145 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ CFLAGS += -D_KERNEL -DPORT_AMIGA
#DEBUG += -DNO_SERIAL_OUTPUT # Turn off serial debugging for the whole driver
CFLAGS += $(DEBUG)
CFLAGS += -DENABLE_SEEK # Not needed for modern drives (~500 bytes)
#CFLAGS += -DDISKLABELS # Enable support for MBR / GPT disklabels
CFLAGS += -Os -fomit-frame-pointer -noixemul
#CFLAGS += -fbaserel -resident -DUSING_BASEREL
CFLAGS += -msmall-code
Expand Down Expand Up @@ -223,7 +224,7 @@ $(ROM): $(ROM_ND) $(PROG).rnc $(OBJDIR)/romtool

$(ROM_CD): $(ROM) $(CDFS).rnc $(OBJDIR)/romtool
@echo Building $@
$(QUIET)$(OBJDIR)/romtool $(ROM) -o $(ROM_CD) -F $(CDFS).rnc
$(QUIET)$(OBJDIR)/romtool $(ROM) -o $(ROM_CD) -F $(CDFS).rnc -T 0x43443031

$(ROM_COM): $(ROM_ND) a3090.ld_strip $(OBJDIR)/romtool
@echo Building $@
Expand Down
2 changes: 0 additions & 2 deletions attach.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ typedef struct {
struct timerequest *as_timerio;
struct callout **as_callout_head;
struct ConfigDev *as_cd;
uint32_t romfile[2];
uint32_t romfile_len[2];
/* battmem */
uint8_t cdrom_boot;
uint8_t ignore_last;
Expand Down
6 changes: 3 additions & 3 deletions bootmenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -433,13 +433,13 @@ int scan_disks(void)
Text(rp, (char *)unit_str, 3);
x+=48;
Move(rp,x,y);
Text(rp, inq_res.vendor, 8);
Text(rp, inq_res.vendor, strlen(inq_res.vendor));
x+=96;
Move(rp,x,y);
Text(rp, inq_res.product, 16);
Text(rp, inq_res.product, strlen(inq_res.product));
x+=176;
Move(rp,x,y);
Text(rp, inq_res.revision, 4);
Text(rp, inq_res.revision, strlen(inq_res.revision));
x+=48;
Move(rp,x,y);
const char *dtype=devtype_str(inq_res.device & SID_TYPE);
Expand Down
3 changes: 1 addition & 2 deletions device.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,7 @@ init(BPTR seg_list asm("a0"), struct Library *dev asm("d0"))
AddDevice((struct Device *)mydev);

if (romboot) {
parse_romfiles();
add_cdromfilesystem();
init_romfiles();
mount_drives(asave->as_cd, dev);
boot_menu();
}
Expand Down
76 changes: 76 additions & 0 deletions legacy.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
//
// Copyright 2022-2023 Stefan Reinauer & Chris Hooper
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//

typedef uint64_t ULLONG;

typedef struct { /* RFC4122 */
union {
struct {
ULONG time_low;
UWORD time_mid;
UWORD time_high_and_version;
UBYTE clock_seq_high_and_reserved;
UBYTE clock_seq_low;
UBYTE node[6];
} UUID;
UBYTE raw[16];
} u;
} __attribute__((packed)) GUID;

struct mbr_partition {
UBYTE status;
UBYTE f_head;
UBYTE f_sect;
UBYTE f_cyl;
UBYTE type;
UBYTE l_head;
UBYTE l_sect;
UBYTE l_cyl;
ULONG f_lba;
ULONG num_sect;
} __attribute__((packed));

struct mbr {
UBYTE bootcode[424];
GUID boot_guid;
ULONG disk_id;
UBYTE magic[2];
struct mbr_partition part[4];
UBYTE sig[2];
} __attribute__((packed));

struct gpt {
UBYTE signature[8];
ULONG revision;
ULONG size;
ULONG header_crc32;
ULONG reserved_zero;
ULLONG my_lba;
ULLONG alternate_lba;
ULLONG first_usable_lba;
ULLONG last_usable_lba;
GUID disk_uuid;
ULLONG entries_lba;
ULONG number_of_entries;
ULONG size_of_entry;
ULONG entries_crc32;
} __attribute__((packed));

struct gpt_partition {
GUID partition_type;
GUID unique_partition;
ULLONG first_lba;
ULLONG last_lba;
ULLONG attribute_flags;
USHORT partition_name[36];
} __attribute__((packed));
Loading

0 comments on commit 4aedb46

Please sign in to comment.