dk(4): Add support for discovering Atari TOS partitions as wedges
Any partitioning scheme which conforms to the Atari AHDI 3.00 spec should be recognized by the new DKWEDGE_METHOD_TOS.
This commit is contained in:
parent
d0ccdab6f4
commit
53b28be123
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: ALL,v 1.186 2024/03/21 02:36:01 riastradh Exp $
|
||||
# $NetBSD: ALL,v 1.187 2024/04/02 22:30:03 charlotte Exp $
|
||||
# From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp
|
||||
#
|
||||
# ALL machine description file
|
||||
|
@ -17,7 +17,7 @@ include "arch/amd64/conf/std.amd64"
|
|||
|
||||
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
|
||||
|
||||
#ident "ALL-$Revision: 1.186 $"
|
||||
#ident "ALL-$Revision: 1.187 $"
|
||||
|
||||
maxusers 64 # estimated number of users
|
||||
|
||||
|
@ -164,6 +164,7 @@ options DKWEDGE_METHOD_BSDLABEL # Support disklabel entries as wedges
|
|||
options DKWEDGE_METHOD_MBR # Support MBR partitions as wedges
|
||||
options DKWEDGE_METHOD_APPLE # Support Apple partitions as wedges
|
||||
options DKWEDGE_METHOD_RDB # Support RDB partitions as wedges
|
||||
options DKWEDGE_METHOD_TOS # Support Atari "TOS" partitions as wedges
|
||||
|
||||
# File systems
|
||||
file-system FFS # UFS
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: ALL,v 1.517 2024/03/21 02:36:01 riastradh Exp $
|
||||
# $NetBSD: ALL,v 1.518 2024/04/02 22:30:03 charlotte Exp $
|
||||
# From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp
|
||||
#
|
||||
# ALL machine description file
|
||||
|
@ -17,7 +17,7 @@ include "arch/i386/conf/std.i386"
|
|||
|
||||
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
|
||||
|
||||
#ident "ALL-$Revision: 1.517 $"
|
||||
#ident "ALL-$Revision: 1.518 $"
|
||||
|
||||
maxusers 64 # estimated number of users
|
||||
|
||||
|
@ -151,6 +151,7 @@ options DKWEDGE_METHOD_GPT # Supports GPT partitions as wedges
|
|||
#options DKWEDGE_METHOD_MBR # Support MBR partitions as wedges
|
||||
options DKWEDGE_METHOD_APPLE # Support Apple partitions as wedges
|
||||
options DKWEDGE_METHOD_RDB # Support RDB partitions as wedges
|
||||
options DKWEDGE_METHOD_TOS # Support Atari "TOS" partitions as wedges
|
||||
|
||||
# File systems
|
||||
file-system FFS # UFS
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: files,v 1.1311 2024/02/09 22:08:34 andvar Exp $
|
||||
# $NetBSD: files,v 1.1312 2024/04/02 22:30:03 charlotte Exp $
|
||||
# @(#)files.newconf 7.5 (Berkeley) 5/10/93
|
||||
|
||||
version 20171118
|
||||
|
@ -105,6 +105,7 @@ defflag opt_dkwedge.h DKWEDGE_AUTODISCOVER
|
|||
DKWEDGE_METHOD_MBR
|
||||
DKWEDGE_METHOD_APPLE
|
||||
DKWEDGE_METHOD_RDB
|
||||
DKWEDGE_METHOD_TOS
|
||||
|
||||
defflag opt_veriexec.h VERIFIED_EXEC_FP_SHA256
|
||||
VERIFIED_EXEC_FP_SHA384
|
||||
|
|
|
@ -0,0 +1,175 @@
|
|||
/* $NetBSD: dkwedge_tos.c,v 1.1 2024/04/02 22:30:03 charlotte Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2024 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Charlotte Koch.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* dk(4) support for Atari "TOS" partition schemes.
|
||||
*
|
||||
* Technical details taken from:
|
||||
*
|
||||
* - "Atari Hard Disk File Systems Reference Guide" v1.2b by Jean
|
||||
* Louis-Guerin (DrCoolZic) (September 2014)
|
||||
*
|
||||
* https://info-coach.fr/atari/documents/_mydoc/Atari_HD_File_Sytem_Reference_Guide.pdf
|
||||
*/
|
||||
|
||||
#include <sys/buf.h>
|
||||
#include <sys/disk.h>
|
||||
#include <sys/endian.h>
|
||||
#include <sys/vnode.h>
|
||||
|
||||
#define TOS_PART_TYPE_LEN 3
|
||||
#define TOS_GEM_PARTITION "GEM"
|
||||
#define TOS_BGM_PARTITION "BGM"
|
||||
#define TOS_XGM_PARTITION "XGM"
|
||||
|
||||
#define TOS_CXNMETHOD_SASI 0x00
|
||||
#define TOS_CXNMETHOD_SCSI 0xFF
|
||||
|
||||
#define TOS_MAX_PART_COUNT 4
|
||||
#define TOS_SECTOR_SIZE 512
|
||||
|
||||
struct tos_partition {
|
||||
uint8_t status;
|
||||
char type[TOS_PART_TYPE_LEN];
|
||||
uint32_t offset;
|
||||
uint32_t size;
|
||||
} __packed;
|
||||
__CTASSERT(sizeof(struct tos_partition) == 12);
|
||||
|
||||
struct tos_root_sector {
|
||||
uint8_t unused1[441];
|
||||
uint8_t connection_method;
|
||||
uint8_t unused2[8];
|
||||
uint32_t size;
|
||||
struct tos_partition parts[TOS_MAX_PART_COUNT];
|
||||
uint8_t unused3[10];
|
||||
} __packed;
|
||||
__CTASSERT(sizeof(struct tos_root_sector) == TOS_SECTOR_SIZE);
|
||||
|
||||
static int dkwedge_discover_tos(struct disk *pdk, struct vnode *vp);
|
||||
|
||||
static int
|
||||
dkwedge_discover_tos(struct disk *pdk, struct vnode *vp)
|
||||
{
|
||||
struct dkwedge_info dkw;
|
||||
int error = 0;
|
||||
size_t i;
|
||||
char safe_type[4];
|
||||
|
||||
/* Get ourselves a fistful of memory. */
|
||||
buf_t *bp = geteblk(TOS_SECTOR_SIZE);
|
||||
|
||||
error = dkwedge_read(pdk, vp, 0L, bp->b_data, TOS_SECTOR_SIZE);
|
||||
if (error) {
|
||||
aprint_error("unable to read TOS Root Sector: error = %d",
|
||||
error);
|
||||
goto out;
|
||||
}
|
||||
|
||||
struct tos_root_sector *trs = bp->b_data;
|
||||
|
||||
/*
|
||||
* If the "connection method" isn't recognized, then this is
|
||||
* probably NOT an Atari-style partition, so get outta here. Note
|
||||
* that there really isn't a magic number we can rely on; this check
|
||||
* is somewhat made up. But at least it's better than nothing.
|
||||
*/
|
||||
switch (trs->connection_method) {
|
||||
case TOS_CXNMETHOD_SASI: /* FALLTHROUGH */
|
||||
case TOS_CXNMETHOD_SCSI:
|
||||
; /* OK */
|
||||
break;
|
||||
default:
|
||||
error = ESRCH;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/*
|
||||
* Make a wedge for each partition that exists (i.e., has the "exist"
|
||||
* bit set).
|
||||
*/
|
||||
for (i = 0; i < TOS_MAX_PART_COUNT; i++) {
|
||||
struct tos_partition part = trs->parts[i];
|
||||
|
||||
if (!(part.status & 0x01))
|
||||
continue;
|
||||
|
||||
/* Ignore if we see it's an extended "XGM" partition. */
|
||||
if (!strncmp(part.type, TOS_XGM_PARTITION, TOS_PART_TYPE_LEN)) {
|
||||
aprint_normal(
|
||||
"WARNING: XGM partitions are not yet supported\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Otherwise, get outta here if it's not the partition-types
|
||||
* we *do* support.
|
||||
*/
|
||||
if (strncmp(part.type, TOS_GEM_PARTITION, TOS_PART_TYPE_LEN) &&
|
||||
strncmp(part.type, TOS_BGM_PARTITION, TOS_PART_TYPE_LEN)) {
|
||||
error = ESRCH;
|
||||
goto out;
|
||||
}
|
||||
|
||||
memset(&dkw, 0, sizeof(dkw));
|
||||
memset(safe_type, 0, sizeof(safe_type));
|
||||
|
||||
/*
|
||||
* The partition type string is NOT NUL-terminated, so let's
|
||||
* play it safe.
|
||||
*/
|
||||
memcpy(safe_type, part.type, TOS_PART_TYPE_LEN);
|
||||
safe_type[TOS_PART_TYPE_LEN] = '\0';
|
||||
|
||||
/* Finally, make the wedge. */
|
||||
snprintf(dkw.dkw_wname, sizeof(dkw.dkw_wname), "ATARI_%s_%02lu",
|
||||
safe_type, i);
|
||||
dkw.dkw_offset = be32toh(trs->parts[i].offset);
|
||||
dkw.dkw_size = be32toh(trs->parts[i].size);
|
||||
strlcpy(dkw.dkw_ptype, DKW_PTYPE_FAT, sizeof(dkw.dkw_ptype));
|
||||
strlcpy(dkw.dkw_parent, pdk->dk_name, sizeof(dkw.dkw_parent));
|
||||
error = dkwedge_add(&dkw);
|
||||
|
||||
if (error == EEXIST) {
|
||||
aprint_error("partition named \"%s\" already exists",
|
||||
dkw.dkw_wname);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
error = 0;
|
||||
|
||||
out:
|
||||
brelse(bp, 0);
|
||||
return error;
|
||||
}
|
||||
|
||||
DKWEDGE_DISCOVERY_METHOD_DECL(TOS, 10, dkwedge_discover_tos);
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: files.dev,v 1.9 2022/06/04 03:31:10 pgoyette Exp $
|
||||
# $NetBSD: files.dev,v 1.10 2024/04/02 22:30:03 charlotte Exp $
|
||||
|
||||
file dev/bio.c bio needs-flag
|
||||
file dev/ccd.c ccd
|
||||
|
@ -13,6 +13,7 @@ file dev/dkwedge/dkwedge_bsdlabel.c dkwedge_method_bsdlabel
|
|||
file dev/dkwedge/dkwedge_gpt.c dkwedge_method_gpt
|
||||
file dev/dkwedge/dkwedge_mbr.c dkwedge_method_mbr
|
||||
file dev/dkwedge/dkwedge_rdb.c dkwedge_method_rdb
|
||||
file dev/dkwedge/dkwedge_tos.c dkwedge_method_tos
|
||||
file dev/firmload.c firmload
|
||||
file dev/fss.c fss
|
||||
file dev/keylock.c keylock
|
||||
|
|
Loading…
Reference in New Issue