Compare commits

...

11 Commits

Author SHA1 Message Date
deadwood 7851b531aa Move Bifteck to Tools/Debug
Development is not part of default installation and users don't install it,
however Bifteck is useful when trying to debug problem with user setup.
2024-03-19 17:21:53 +01:00
deadwood d750b68e5a Add workaround for bug in VirtualBox AHCI implementation
ICC register is not set to IDLE by chipset. Disabling detection of this
change on VirtualBox saves 2 seconds on boot time.
2024-03-19 17:12:14 +01:00
deadwood f5ee826e7f Provide 32-bit variable to store number of cylinders
This allow for using identical algorithm as ata.device. Number of cylinders
needs to be 32-bit as often division by 2 and 3 yields no results and
heads stay at 1 while cylinders is a number larger than 2^16.
2024-03-19 17:12:14 +01:00
deadwood 80046e3470 Shorten original delays to cut boot time by 50%
This changes original delays from DragonflyBSD code. This might prove to
be a problem under certain hardware. Introduce "slowerstart" bootstrap
argument that reverts to original timing.
2024-03-19 17:12:07 +01:00
deadwood dca6bb5e1d Shorten ahci_os_softsleep delay
This function is often used in timeout operation. Shortening allows for
faster reaction.
2024-03-15 18:59:44 +01:00
deadwood bf8923cc3e Restore 100ms delay
100ms was present in first port to AROS. In original source codes, the
wait is not active but bases on a wake up signal and 1000ms timeout. On
AROS the wait is active so that delay needs to be small to quickly
transition to next step and not delay the boot sequence.
2024-03-15 18:53:34 +01:00
deadwood e07e6f6c8e Don't allocate DMA memory in bud_dmamap_create
According to FreeBSD documentation, this function only creates a handle
that will later be used to tracking mapping. Also looking at code, the
returning map objects is never utilized.

Removing the unneeded allocation saves 66MB of RAM.

This fixes: https://github.com/deadwood2/AROS/issues/108
2024-03-14 20:04:49 +01:00
deadwood fe78dd20ea Add CHS translation that is needed for AROS to correctly report capacity
This fixes: https://github.com/deadwood2/AROS/issues/135
2024-03-14 17:16:35 +01:00
deadwood 8b16a5dd9e Integrate latest source code: revert to literals instead of constants 2024-03-13 22:11:07 +01:00
deadwood d66e110590 Adjust bttask to work on x86_64 2024-03-12 20:15:50 +01:00
deadwood 69880ae41a Fix warnings 2024-03-06 16:44:08 +01:00
13 changed files with 95 additions and 44 deletions

View File

@ -7,7 +7,7 @@ include $(SRCDIR)/config/aros.cfg
#MM debug-tools-bifteck : includes linklibs
%build_prog mmake=debug-tools-bifteck \
progname=Bifteck targetdir=$(AROS_DEBUG) \
progname=Bifteck targetdir=$(AROS_TOOLS)/Debug\
files=Bifteck
%common

View File

@ -566,22 +566,22 @@ define bttask
if ($task->tc_Node.ln_Type != 1) && ($task->tc_Node.ln_Type != 13)
printf "ERROR: Given address does not look like a task or process!\n"
else
#FIXME: The following assumes Linux x86
set $old_esp = $esp
set $old_eip = $eip
#FIXME: The following assumes Linux x86_64
set $old_esp = $rsp
set $old_eip = $rip
if $task->tc_State == 2
printf "WARNING: TS_RUN Task. Showing normal backtrace!\n"
else
set $esp = $task->tc_SPReg
set $rsp = $task->tc_SPReg
set $taskcontext = (struct AROSCPUContext *)$task->tc_UnionETask.tc_ETask.et_RegFrame
set $eip = $taskcontext.regs.eip
set $rip = $taskcontext.regs.rip
end
bt
set $esp = $old_esp
set $eip = $old_eip
set $rsp = $old_esp
set $rip = $old_eip
end
end
document bttask

View File

@ -85,6 +85,8 @@ static void ahci_empty_done(struct ahci_ccb *ccb);
static void ahci_ata_cmd_done(struct ahci_ccb *ccb);
static u_int32_t ahci_pactive(struct ahci_port *ap);
extern int ahci_icc_bug;
/*
* Initialize the global AHCI hardware. This code does not set up any of
* its ports.
@ -1431,6 +1433,7 @@ ahci_comreset(struct ahci_port *ap, int *pmdetectp)
cmd |= AHCI_PREG_CMD_SUD | AHCI_PREG_CMD_POD;
cmd |= AHCI_PREG_CMD_ICC_ACTIVE;
ahci_pwrite(ap, AHCI_PREG_CMD, cmd);
if (!ahci_icc_bug)
ahci_pwait_clr(ap, AHCI_PREG_CMD, AHCI_PREG_CMD_ICC);
/*
@ -1460,7 +1463,7 @@ retry:
* Give the new power management state time to settle, then clear
* pending status.
*/
ahci_os_sleep(1000);
ahci_os_sleep(AhciStartDelay << 2);
ahci_flush_tfd(ap);
ahci_pwrite(ap, AHCI_PREG_SERR, -1);
@ -1493,7 +1496,7 @@ retry:
break;
}
ahci_pwrite(ap, AHCI_PREG_SCTL, r);
ahci_os_sleep(1000);
ahci_os_sleep(AhciStartDelay << 2);
ap->ap_flags &= ~AP_F_HARSH_REINIT;
@ -1516,7 +1519,7 @@ retry:
r &= ~AHCI_PREG_SCTL_DET_INIT;
r |= AHCI_PREG_SCTL_DET_NONE;
ahci_pwrite(ap, AHCI_PREG_SCTL, r);
ahci_os_sleep(1000);
ahci_os_sleep(AhciStartDelay << 2);
/*
* Try to determine if there is a device on the port. This operation
@ -1535,7 +1538,7 @@ retry:
* If we fail clear PRCS (phy detect) since we may cycled
* the phy and probably caused another PRCS interrupt.
*/
loop = 2000;
loop = AhciStartDelay * 10;
while (loop > 0) {
r = ahci_pread(ap, AHCI_PREG_SSTS);
if (r & AHCI_PREG_SSTS_DET)
@ -1656,7 +1659,7 @@ ahci_port_hardreset(struct ahci_port *ap, int hard)
/*
* Finish up.
*/
ahci_os_sleep(500);
ahci_os_sleep(AhciStartDelay << 1);
switch(error) {
case 0:
@ -1811,6 +1814,7 @@ ahci_port_hardstop(struct ahci_port *ap)
AHCI_PREG_CMD_SUD |
AHCI_PREG_CMD_ICC_ACTIVE;
ahci_pwrite(ap, AHCI_PREG_CMD, cmd);
if (!ahci_icc_bug)
ahci_pwait_clr(ap, AHCI_PREG_CMD, AHCI_PREG_CMD_ICC);
/*

View File

@ -665,6 +665,7 @@ void ahci_os_unlock_port(struct ahci_port *ap);
extern u_int32_t AhciForceGen;
extern u_int32_t AhciNoFeatures;
extern int ahci_synchronous_boot;
extern u_int32_t AhciStartDelay;
enum {AHCI_LINK_PWR_MGMT_NONE, AHCI_LINK_PWR_MGMT_MEDIUM,
AHCI_LINK_PWR_MGMT_AGGR};

View File

@ -148,10 +148,10 @@ int ahci_os_softsleep(void)
{
struct IORequest *io = ahci_OpenTimer();
if (io != NULL) {
ahci_WaitTO(io, 0, 100 * 1000, 0);
ahci_WaitTO(io, 0, 50 * 1000, 0);
ahci_CloseTimer(io);
}
return 100;
return 50;
}
/*

View File

@ -175,14 +175,13 @@ void bus_dmamem_free(bus_dma_tag_t tag, void *vaddr, bus_dmamap_t map)
int bus_dmamap_create(bus_dma_tag_t tag, unsigned flags, bus_dmamap_t *map)
{
DDMA(bug("[AHCI] %s()\n", __func__));
bus_dmamem_alloc(tag, NULL, 0, map);
*map = NULL;
return 0;
}
void bus_dmamap_destroy(bus_dma_tag_t tag, bus_dmamap_t map)
{
DDMA(bug("[AHCI] %s()\n", __func__));
bus_dmamem_free(tag, NULL, map);
}
int bus_dmamap_load(bus_dma_tag_t tag, bus_dmamap_t map, void *data, size_t len, bus_dmamap_callback_t *callback, void *info, unsigned flags)
@ -198,6 +197,10 @@ void bus_dmamap_sync(bus_dma_tag_t tag, bus_dmamap_t map, unsigned flags)
DDMA(bug("[AHCI] %s()\n", __func__));
/* Note: this works for rfis, cmd_list and cmd_table, because the go through bus_dmamem_alloc which is implemented
to set map to vaddr. In case of prdt, the memory DMAed with device comes from outside and should actually be
"assigned" to map in bus_dmamap_load so that it can be used here */
if (!(flags & (1 << 31)))
CachePreDMA(map, &len, flags);
else

View File

@ -119,6 +119,7 @@ static const struct ahci_pciid ahci_msi_blacklist[] = {
static int ahci_msi_enable = 1;
int ahci_synchronous_boot = 1;
int ahci_icc_bug = 0;
/*
* Match during probe and attach. The device does not yet have a softc.
@ -296,6 +297,10 @@ ahci_pci_attach(device_t dev)
}
}
/* VirtualBox AHCI controller */
if (vid == PCI_VENDOR_INTEL && did == 0x2829 && rev == 0x2)
ahci_icc_bug = 1;
sc->sc_irq_type = pci_alloc_1intr(dev, msi_enable,
&sc->sc_rid_irq, &irq_flags);
@ -614,7 +619,7 @@ noccc:
for (i = 0; i < AHCI_MAX_PORTS; i++) {
if ((ap = sc->sc_ports[i]) != NULL) {
while (ap->ap_signal & AP_SIGF_THREAD_SYNC)
ahci_os_sleep(1000);
ahci_os_sleep(100);
}
}
@ -638,13 +643,13 @@ noccc:
for (i = 0; i < AHCI_MAX_PORTS && ahci_synchronous_boot; i++) {
if ((ap = sc->sc_ports[i]) != NULL) {
while (ap->ap_signal & AP_SIGF_INIT)
ahci_os_sleep(1000);
ahci_os_sleep(100);
ahci_os_lock_port(ap);
if (ahci_cam_attach(ap) == 0) {
ahci_cam_changed(ap, NULL, -1);
ahci_os_unlock_port(ap);
while ((ap->ap_flags & AP_F_SCAN_COMPLETED) == 0) {
ahci_os_sleep(1000);
ahci_os_sleep(100);
}
} else {
ahci_os_unlock_port(ap);

View File

@ -31,27 +31,6 @@
#include LC_LIBDEFS_FILE
static const char *str_typedisk = "DISK";
static const char *str_typeatapi = "ATAPI";
static const char *str_typeunk = "UNKNOWN(ATAPI?)";
static const char *str_enabled = "enabled";
static const char *str_disabled = "disabled";
static const char *str_enabling = "enabling";
static const char *str_frozen = "frozen";
static const char *str_unfrozen = "unfrozen";
static const char *str_disabled2 = "<disabled>";
static const char *str_freezing = "freezing";
static const char *str_unsupported = "notsupp";
static const char *str_yes = "YES";
static const char *str_no = "NO";
static const char *str_found = "%s: Found %s \"%*.*s %*.*s\" serial=\"%*.*s\"\n"
"%s: tags=%d/%d satacap=%04x satafea=%04x NCQ=%s "
"capacity=%lld.%02dMB\n";
static const char *str_found2 = "%s: f85=%04x f86=%04x f87=%04x WC=%s RA=%s SEC=%s\n";
static const char *str_unabletoident = "%s: Detected %s device but unable to IDENTIFY\n";
/*
* Execute a SCSI TEST UNIT READY every 250ms, to see
* if the medium has changed.
@ -295,7 +274,7 @@ static BOOL ahci_RegisterVolume(struct ahci_port *ap, struct ata_port *at, struc
pp[DE_BLKSPERTRACK + 4] = at->at_identify.nsectors;
pp[DE_RESERVEDBLKS + 4] = 2;
pp[DE_LOWCYL + 4] = 0;
pp[DE_HIGHCYL + 4] = (ap->ap_type == ATA_PORT_T_DISK) ? (at->at_identify.ncyls - 1) : 0;
pp[DE_HIGHCYL + 4] = (ap->ap_type == ATA_PORT_T_DISK) ? (at->at_ncyls - 1) : 0;
pp[DE_NUMBUFFERS + 4] = 10;
pp[DE_BUFMEMTYPE + 4] = MEMF_PUBLIC;
pp[DE_MAXTRANSFER + 4] = 0x00200000;
@ -441,6 +420,53 @@ ata_fix_identify(struct ata_identify *id)
swap[i] = bswap16(swap[i]);
}
static void
ata_fix_chs(struct ata_identify *id, u_int32_t *ncyls, u_int64_t capacity48)
{
*ncyls = id->ncyls;
if (le16toh(id->cmdset83) & 0x0400) {
/* LBA48 feature set supported */
/* Code copied from ata.device */
ULONG div = 1;
/*
* TODO: this shouldn't be casted down here.
*/
ULONG sec = capacity48;
if (sec < capacity48)
sec = ~((ULONG)0);
id->nsectors = 63;
sec /= 63;
/*
* keep dividing by 2
*/
do
{
if (((sec >> 1) << 1) != sec)
break;
if ((div << 1) > 255)
break;
div <<= 1;
sec >>= 1;
} while (1);
do
{
if (((sec / 3) * 3) != sec)
break;
if ((div * 3) > 255)
break;
div *= 3;
sec /= 3;
} while (1);
*ncyls = sec;
id->nheads = div;
}
}
/*
* Dummy done callback for xa.
*/
@ -786,6 +812,8 @@ ahci_cam_probe(struct ahci_port *ap, struct ata_port *atx)
capacity_bytes = capacity * 512;
ata_fix_chs(&at->at_identify, &at->at_ncyls, at->at_capacity);
/*
* Negotiate NCQ, throw away any ata_xfer's beyond the negotiated
* number of slots and limit the number of CAM ccb's to one less

View File

@ -46,6 +46,7 @@
u_int32_t AhciForceGen = 0;
u_int32_t AhciNoFeatures = 0;
u_int32_t AhciStartDelay = 25;
#include LC_LIBDEFS_FILE
@ -134,6 +135,11 @@ static int AHCI_Init(struct AHCIBase *AHCIBase)
D(bug("[AHCI--] %s: Disabling AHCI features\n", __func__));
AhciNoFeatures = -1;
}
if (strstr(CmdLine, "slowerstart"))
{
D(bug("[AHCI--] %s: Using original start delays\n", __func__));
AhciStartDelay = 250;
}
}
}
}

View File

@ -330,7 +330,7 @@ AROS_LH1(void, BeginIO,
SetMem(geom, 0, len);
if (ap->ap_type == ATA_PORT_T_DISK) {
geom->dg_SectorSize = at->at_identify.sector_size;
geom->dg_Cylinders = at->at_identify.ncyls;
geom->dg_Cylinders = at->at_ncyls;
geom->dg_CylSectors = at->at_identify.nsectors * at->at_identify.nheads;
if (((UQUAD)geom->dg_Cylinders * geom->dg_CylSectors) >> 32 != 0)
geom->dg_TotalSectors = 0xffffffff;

View File

@ -303,7 +303,7 @@ retry:
* target 0, because when a PM is attached target 0 represents
* slot #0 behind the PM.
*/
if (ahci_poll(ccb, 5000, ahci_quick_timeout) != ATA_S_COMPLETE) {
if (ahci_poll(ccb, 500 + (AhciStartDelay * 20), ahci_quick_timeout) != ATA_S_COMPLETE) {
kprintf("%s: PMPROBE(2) No Port Multiplier was found.\n",
PORTNAME(ap));
if (--count) {

View File

@ -325,6 +325,7 @@ struct ata_port {
u_int64_t at_capacity; /* only if ATA_PORT_T_DISK */
int at_target; /* port multiplier port */
char at_name[16];
u_int32_t at_ncyls; /* only if ATA_PORT_T_DISK */
};
struct ata_xfer {

View File

@ -21,6 +21,9 @@
# include <exec/semaphores.h>
#endif
#include <hidd/hidd.h>
#include <hidd/gfx.h>
#define ATTRBASES_NUM 6
struct HeadlessGfx_staticdata