first and last commit

This commit is contained in:
Chris Nutter committed 2023-07-08 13:03:17 -07:00
commit 1bf4efd552
2612 files changed
+636500

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
/*
* Copyright (C) 2008 Apple Inc. All rights reserved.
*
* This document is the property of Apple Inc.
* It is considered confidential and proprietary.
*
* This document may not be reproduced or transmitted in any form,
* in whole or in part, without the express written permission of
* Apple Inc.
*/
typedef UInt32 CEATA_cmd_t;
/* XXX these may be just placeholders */
#define CEATA_IDENTIFY 0xec
#define CEATA_READ_DMA_EXT 0x25
#define CEATA_WRITE_DMA_EXT 0x35
#define CEATA_STANDBY_IMMEDIATE 0xe0
#define CEATA_FLUSH_CACHE_EXT 0xea
+193
View File
@@ -0,0 +1,193 @@
/*
* Copyright (C) 2008 Apple Inc. All rights reserved.
*
* This document is the property of Apple Inc.
* It is considered confidential and proprietary.
*
* This document may not be reproduced or transmitted in any form,
* in whole or in part, without the express written permission of
* Apple Inc.
*/
#include <debug.h>
#include <AssertMacros.h>
#include <platform/memmap.h>
#include <platform.h>
#include <sys/task.h>
#include <qwi.h>
#include <EmbeddedIOPProtocol.h>
#include "iop_ceata.h"
#include "iop_ceata_protocol.h"
#include "ceata.h"
static struct task_event ceata_message_event;
static int ceata_channel;
static bool ceata_message_process(void);
static IOPCEATA_status_t ceata_reset(void);
static IOPCEATA_status_t ceata_identify(IOPCEATA_Identify *identify);
static IOPCEATA_status_t ceata_cmd(CEATA_cmd_t cmd);
static IOPCEATA_status_t ceata_io(CEATA_cmd_t cmd,
UInt32 starting_lba,
UInt32 lba_count,
UInt32 segment_count,
IOPCEATA_dma_segment *segments);
int
iop_ceata_task(void *cfg)
{
struct iop_channel_config *channel = (struct iop_channel_config *)cfg;
dprintf(DEBUG_SPEW, "@@ CEATA task starting\n");
check(kIOPCEATA_COMMAND_SIZE == sizeof(IOPCEATA_Command));
/* establish the host communications channel */
event_init(&ceata_message_event, EVENT_FLAG_AUTO_UNSIGNAL, false);
dprintf(DEBUG_SPEW, "** opening ceata channel\n");
ceata_channel = qwi_instantiate_channel(
"ceata command",
QWI_ROLE_CONSUMER,
channel->ring_size,
mem_static_map_cached(channel->ring_base),
(qwi_channel_hook)event_signal,
(void *)&ceata_message_event);
for (;;) {
dprintf(DEBUG_SPEW, "@@ waiting for message on ceata channel\n");
while (ceata_message_process()) {
// eat all available messages
}
event_wait(&ceata_message_event);
}
return(0);
}
static bool
ceata_message_process(void)
{
uint32_t message;
IOPCEATA_Command* command;
dprintf(DEBUG_SPEW, "@@ handling host message\n");
/* look to see if there's an item waiting for us */
if (qwi_receive_item(ceata_channel, &message) == -1)
return(false);
dprintf(DEBUG_SPEW, "@@ received ceata message\n");
/* find the command structure based on the message */
command = (IOPCEATA_Command*)mem_static_map_cached(message);
/*
* Flush any cached item contents we might have lying around - we are guaranteed
* that the command size is a multiple of our cacheline size.
*/
platform_cache_operation(CACHE_INVALIDATE,
(void *)command,
sizeof(*command));
/*
* TODO: make this part of the API and push this
* architecture-specific command handling down into the s5l8920x
* platform directory.
*/
switch (command->iopceata.opcode) {
case kIOPCEATA_OPCODE_RESET:
dprintf(DEBUG_SPEW, "@@ RESET\n");
command->iopceata.status = ceata_reset();
break;
case kIOPCEATA_OPCODE_IDENTIFY:
dprintf(DEBUG_SPEW, "@@ IDENTIFY\n");
command->iopceata.status = ceata_identify((IOPCEATA_Identify *)command);
break;
case kIOPCEATA_OPCODE_READ:
dprintf(DEBUG_SPEW, "@@ READ\n");
command->iopceata.status = ceata_io(
CEATA_READ_DMA_EXT,
command->read_write.starting_lba,
command->read_write.lba_count,
command->read_write.segment_count,
&command->read_write.data_segments[0]);
break;
case kIOPCEATA_OPCODE_WRITE:
dprintf(DEBUG_SPEW, "@@ WRITE\n");
command->iopceata.status = ceata_io(
CEATA_WRITE_DMA_EXT,
command->read_write.starting_lba,
command->read_write.lba_count,
command->read_write.segment_count,
&command->read_write.data_segments[0]);
break;
case kIOPCEATA_OPCODE_STANDBY:
dprintf(DEBUG_SPEW, "@@ STANDBY\n");
command->iopceata.status = ceata_cmd(CEATA_STANDBY_IMMEDIATE);
break;
case kIOPCEATA_OPCODE_FLUSH:
dprintf(DEBUG_SPEW, "@@ FLUSH\n");
command->iopceata.status = ceata_cmd(CEATA_FLUSH_CACHE_EXT);
break;
default:
dprintf(DEBUG_CRITICAL, "@@ ERROR: unrecognised ceata opcode 0x%x",
command->iopceata.opcode);
command->iopceata.status = kIOPCEATA_STATUS_PARAM_INVALID;
break;
}
dprintf(DEBUG_SPEW, "@@ done processing ceata message with status 0x%08x\n", command->iopceata.status);
platform_cache_operation(CACHE_CLEAN,
(void *)command,
sizeof(IOPCEATA_Command));
qwi_send_item(ceata_channel, message);
dprintf(DEBUG_SPEW, "@@ signaled completion of ceata message to host\n");
return(true);
}
static IOPCEATA_status_t
ceata_reset(void)
{
return(kIOPCEATA_STATUS_UNIMPLEMENTED);
}
static IOPCEATA_status_t
ceata_identify(IOPCEATA_Identify *identify)
{
return(kIOPCEATA_STATUS_UNIMPLEMENTED);
}
static IOPCEATA_status_t
ceata_cmd(CEATA_cmd_t cmd)
{
return(kIOPCEATA_STATUS_UNIMPLEMENTED);
}
static IOPCEATA_status_t
ceata_io(CEATA_cmd_t cmd,
UInt32 starting_lba,
UInt32 lba_count,
UInt32 segment_count,
IOPCEATA_dma_segment *segments)
{
return(kIOPCEATA_STATUS_UNIMPLEMENTED);
}
@@ -0,0 +1,12 @@
/*
* Copyright (C) 2008 Apple Inc. All rights reserved.
*
* This document is the property of Apple Inc.
* It is considered confidential and proprietary.
*
* This document may not be reproduced or transmitted in any form,
* in whole or in part, without the express written permission of
* Apple Inc.
*/
extern int iop_ceata_task(void *arg);
@@ -0,0 +1,115 @@
/*
* Copyright (C) 2008 Apple Inc. All rights reserved.
*
* This document is the property of Apple Inc.
* It is considered confidential and proprietary.
*
* This document may not be reproduced or transmitted in any form,
* in whole or in part, without the express written permission of
* Apple Inc.
*/
#ifndef _IOP_CEATA_PROTOCOL_H_
#define _IOP_CEATA_PROTOCOL_H_
#include <sys/types.h>
/*
* Command size is (somewhat) tunable.
*
* The principal consideration here is the maximum scatter/gather list size
* this permits.
*/
#define kIOPCEATA_COMMAND_SIZE (512)
typedef UInt32 IOPCEATA_opcode_t;
#define kIOPCEATA_OPCODE_UNKNOWN ((IOPCEATA_opcode_t) 0)
#define kIOPCEATA_OPCODE_RESET ((IOPCEATA_opcode_t) 1)
#define kIOPCEATA_OPCODE_IDENTIFY ((IOPCEATA_opcode_t) 2)
#define kIOPCEATA_OPCODE_READ ((IOPCEATA_opcode_t) 3)
#define kIOPCEATA_OPCODE_WRITE ((IOPCEATA_opcode_t) 4)
#define kIOPCEATA_OPCODE_STANDBY ((IOPCEATA_opcode_t) 5)
#define kIOPCEATA_OPCODE_FLUSH ((IOPCEATA_opcode_t) 6)
typedef UInt32 IOPCEATA_status_t;
#define kIOPCEATA_STATUS_UNKNOWN ((IOPCEATA_status_t) 0)
#define kIOPCEATA_STATUS_SUCCESS ((IOPCEATA_status_t) 1)
#define kIOPCEATA_STATUS_FAILURE ((IOPCEATA_status_t) 0x80000000)
#define kIOPCEATA_STATUS_DEVICE_ERROR ((IOPCEATA_status_t) 0x80000001)
#define kIOPCEATA_STATUS_DEVICE_TIMEOUT ((IOPCEATA_status_t) 0x80000002)
#define kIOPCEATA_STATUS_DMA_TIMEOUT ((IOPCEATA_status_t) 0x80000003)
#define kIOPCEATA_STATUS_PARAM_INVALID ((IOPCEATA_status_t) 0x80000004)
#define kIOPCEATA_STATUS_UNIMPLEMENTED ((IOPCEATA_status_t) 0x80000005)
/* this must match <drivers/dma.h>::struct dma_segment */
struct _IOPCEATA_dma_segment {
u_int32_t paddr;
u_int32_t length;
};
typedef struct _IOPCEATA_dma_segment IOPCEATA_dma_segment;
struct _IOPCEATA
{
IOPCEATA_opcode_t opcode;
IOPCEATA_status_t status;
};
typedef struct _IOPCEATA IOPCEATA;
struct _IOPCEATA_Identify
{
IOPCEATA iopceata;
// relevant properties from the CE-ATA Identify operation
UInt8 serial_number[20]; // ASCII bytes, not NUL-terminated
UInt8 firmware_revision[8];
UInt8 model_number[40];
UInt32 device_size; // note this is size, not max LBA
UInt32 lba_size; // LBA size in bytes
};
typedef struct _IOPCEATA_Identify IOPCEATA_Identify;
struct _IOPCEATA_ReadWrite
{
IOPCEATA iopceata;
UInt32 starting_lba;
UInt32 lba_count;
UInt32 segment_count;
IOPCEATA_dma_segment data_segments[];
};
typedef struct _IOPCEATA_ReadWrite IOPCEATA_ReadWrite;
union _IOPCEATA_Command
{
IOPCEATA iopceata;
IOPCEATA_Identify identify;
IOPCEATA_ReadWrite read_write;
UInt8 _pad[kIOPCEATA_COMMAND_SIZE];
};
typedef union _IOPCEATA_Command IOPCEATA_Command;
union _IOPCEATA_sgl_sizing_tool
{
IOPCEATA_ReadWrite io_single_dma;
};
#define kIOPCEATA_MAX_SEGMENTS ((kIOPCEATA_COMMAND_SIZE - sizeof(union _IOPCEATA_sgl_sizing_tool)) / sizeof(IOPCEATA_dma_segment))
#endif // _IOP_CEATA_PROTOCOL_H_
+26
View File
@@ -0,0 +1,26 @@
# Copyright (C) 2008 Apple Computer, Inc. All rights reserved.
#
# This document is the property of Apple Computer, Inc.
# It is considered confidential and proprietary.
#
# This document may not be reproduced or transmitted in any form,
# in whole or in part, without the express written permission of
# Apple Computer, Inc.
#
#
# CE-ATA driver
#
LOCAL_DIR := $(GET_LOCAL_DIR)
OPTIONS += WITH_FUNCTION_CEATA=1
IOP_FUNCTIONS += CEATA
ALL_OBJS += $(LOCAL_DIR)/iop_ceata.o
export FMI_PROTOCOL_HEADER:= $(LOCAL_DIR)/iop_ceata_protocol.h
export WITH_FUNCTION_CEATA= 1
export IOP_HEAP_REQUIRED := $(call ADD,$(IOP_HEAP_REQUIRED),8192)