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) 2006 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.
#
LOCAL_DIR := $(GET_LOCAL_DIR)
OPTIONS += \
WITH_SW_H2FMI=1
MODULES += \
lib/blockdev
ALL_OBJS += \
$(LOCAL_DIR)/sw_h2fmi.o
+115
View File
@@ -0,0 +1,115 @@
/*
* Copyright (C) 2007-2011 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 "sw_h2fmi_private.h"
#include <debug.h>
#include <drivers/sw_h2fmi.h>
#include <lib/blockdev.h>
#include <sys.h>
static int sw_h2fmi_blockdev_read_block(struct blockdev *bdev, void *ptr, block_addr block, uint32_t count)
{
uint32_t addr_size;
int ret = 0;
uint32_t page_start, page_end;
register uint32_t* dest = (uint32_t*)ptr;
/* sanity-check the starting block and count */
if ((block >= bdev->block_count) || (count > bdev->block_count) || (NULL == ptr))
return ret;
/* adjust the operation length if it overruns */
if (block > (bdev->block_count - count))
count = bdev->block_count - block;
addr_size = 4; // Any number > 0 will do
page_start = (block / 3);
page_end = ((block + count + 2) / 3);
/* Reset the device */
rFASTSIM_H2FMI_CMD = FASTSIM_H2FMI_RESET;
for (uint32_t page = page_start; page < page_end; page++) {
uint32_t block_addr2, block_addr1, block_addr0;
const uint32_t words_per_loop = 8;
block_addr2 = ((page) >> 16) & 0xFF;
block_addr1 = ((page) >> 8) & 0xFF;
block_addr0 = ((page) >> 0) & 0xFF;
/* Send the offset to device */
rFASTSIM_H2FMI_ADDR0 = ((block_addr1 << 24) | (block_addr0 << 16));
rFASTSIM_H2FMI_ADDR1 = block_addr2;
rFASTSIM_H2FMI_ADDRNUM = (addr_size & 0x7);
/* Roll in the data */
for (uint32_t sector = 0; sector < FASTSIM_H2FMI_BLOCK_PER_PAGE; sector++) {
register uint32_t index = ((FASTSIM_H2FMI_BLOCK_SIZE / sizeof(uint32_t)) / words_per_loop);
do {
register uint32_t tmp0;
register uint32_t tmp1;
register uint32_t tmp2;
register uint32_t tmp3;
register uint32_t tmp4;
register uint32_t tmp5;
register uint32_t tmp6;
register uint32_t tmp7;
tmp0 = rFASTSIM_H2FMI_DATA_BUF;
tmp1 = rFASTSIM_H2FMI_DATA_BUF;
tmp2 = rFASTSIM_H2FMI_DATA_BUF;
tmp3 = rFASTSIM_H2FMI_DATA_BUF;
tmp4 = rFASTSIM_H2FMI_DATA_BUF;
tmp5 = rFASTSIM_H2FMI_DATA_BUF;
tmp6 = rFASTSIM_H2FMI_DATA_BUF;
tmp7 = rFASTSIM_H2FMI_DATA_BUF;
if ((((page * 3) + sector) >= block) && (((page * 3) + sector) < (block + count))) {
*dest++ = tmp0;
*dest++ = tmp1;
*dest++ = tmp2;
*dest++ = tmp3;
*dest++ = tmp4;
*dest++ = tmp5;
*dest++ = tmp6;
*dest++ = tmp7;
}
} while (--index);
}
}
return count;
}
/* to-do: write and erase */
int sw_h2fmi_init(void)
{
struct blockdev *sw_h2fmi_dev;
sw_h2fmi_dev = malloc(sizeof(struct blockdev));
if (sw_h2fmi_dev == NULL) {
dprintf(DEBUG_CRITICAL, "sw_h2fmi_init: failed to create blockdev\n");
return -3;
}
memset(sw_h2fmi_dev, 0, sizeof(struct blockdev));
/* create the block device */
construct_blockdev(sw_h2fmi_dev, "sw-h2fmi", FASTSIM_H2FMI_BLOCK_SIZE * FASTSIM_H2FMI_BLOCK_NUMBER, FASTSIM_H2FMI_BLOCK_SIZE);
sw_h2fmi_dev->read_block_hook = &sw_h2fmi_blockdev_read_block;
/* register it in the block device namespace */
register_blockdev(sw_h2fmi_dev);
return 0;
}
+29
View File
@@ -0,0 +1,29 @@
/*
* Copyright (C) 2007-2011 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.
*/
#define FASTSIM_H2FMI_BLOCK_PER_PAGE (3)
#define FASTSIM_H2FMI_BLOCK_SIZE (512)
#define FASTSIM_H2FMI_BLOCK_NUMBER (16384)
/* Register base and offsets address used for FastSim */
#define FASTSIM_H2FMI_BASE_ADDR (0x31200000)
#define rFASTSIM_H2FMI_DATA_BUF (*(volatile u_int32_t *)(FASTSIM_H2FMI_BASE_ADDR + 0x00014))
#define rFASTSIM_H2FMI_DEBUG0 (*(volatile u_int32_t *)(FASTSIM_H2FMI_BASE_ADDR + 0x0001C))
#define rFASTSIM_H2FMI_CMD (*(volatile u_int32_t *)(FASTSIM_H2FMI_BASE_ADDR + 0x40014))
#define rFASTSIM_H2FMI_ADDR0 (*(volatile u_int32_t *)(FASTSIM_H2FMI_BASE_ADDR + 0x40018))
#define rFASTSIM_H2FMI_ADDR1 (*(volatile u_int32_t *)(FASTSIM_H2FMI_BASE_ADDR + 0x4001C))
#define rFASTSIM_H2FMI_ADDRNUM (*(volatile u_int32_t *)(FASTSIM_H2FMI_BASE_ADDR + 0x40020))
#define rFASTSIM_H2FMI_STATUS (*(volatile u_int32_t *)(FASTSIM_H2FMI_BASE_ADDR + 0x40044))
/* CMD */
#define FASTSIM_H2FMI_RESET (0xFF)
+77
View File
@@ -0,0 +1,77 @@
/*
* Copyright (C) 2007-2011 Apple Inc. All rights reserved.
* Copyright (C) 2006 Apple Computer, 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 <sys.h>
#include <debug.h>
#include <lib/heap.h>
#include <lib/blockdev.h>
#include <lib/partition.h>
//#include <platform/clocks.h>
//#include <sys/menu.h>
#include "hdc_private.h"
static int hdc_read_block_hook(struct blockdev *bdev, void *ptr, block_addr block, uint32_t count)
{
register uint32_t* dest = (uint32_t*)ptr;
/* sanity-check the starting block and count */
if ((block >= bdev->block_count) || (count > bdev->block_count) || (NULL == ptr))
return 0;
/* adjust the operation length if it overruns */
if (block > (bdev->block_count - count))
count = bdev->block_count - block;
/* Reset HDC? */
for (uint32_t block_start = block; block_start < (block + count); block_start++) {
uint32_t hdc_cmd = 0;
hdc_cmd = HDC_SET_CMD_CMD(hdc_cmd, HDC_CMD_READ);
hdc_cmd = HDC_SET_CMD_CMD(hdc_cmd, HDC_CMD_INT);
hdc_cmd = HDC_SET_CMD_DISK(hdc_cmd, 0);
hdc_cmd = HDC_SET_CMD_LEN(hdc_cmd, 0);
rHDC_DMA = (uint32_t)dest;
rHDC_FIRST = block_start;
rHDC_CMD = hdc_cmd;
while (HDC_ST_DONE != HDC_GET_STATUS_ST(rHDC_STATUS))
;
dest += (HDC_BLKSIZE / 4);
}
return count;
}
int hdc_init(void)
{
struct blockdev *hdc;
off_t len;
size_t block_size = (HDC_BLKSIZE);
hdc = malloc(sizeof(struct blockdev));
if (!hdc)
panic("error allocation hdc block device\n");
len = (rHDC_DRV_SIZE) * HDC_BLKSIZE;
construct_blockdev(hdc, "hdc0", len, block_size);
hdc->read_block_hook = &hdc_read_block_hook;
register_blockdev(hdc);
/* scan ourselfs for partitions and publish subdevices */
partition_scan_and_publish_subdevices("hdc0");
return 0;
}
+44
View File
@@ -0,0 +1,44 @@
/*
* Copyright (C) 2007-2011 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.
*/
/* Base address for the fake device */
#define HDC_BASE_ADDR (0x70000000)
/* Registers */
#define rHDC_CMD (*(volatile u_int32_t *)(HDC_BASE_ADDR + 0x000))
#define rHDC_FIRST (*(volatile u_int32_t *)(HDC_BASE_ADDR + 0x010))
#define rHDC_STATUS (*(volatile u_int32_t *)(HDC_BASE_ADDR + 0x030))
#define rHDC_DRV_SIZE (*(volatile u_int32_t *)(HDC_BASE_ADDR + 0x080))
#define rHDC_DMA (*(volatile u_int32_t *)(HDC_BASE_ADDR + 0x100))
/* Register operations */
#define HDC_SET_CMD_CMD(r,c) ((r) | (((c) & 0xff) << 24))
#define HDC_SET_CMD_DISK(r,c) ((r) | (((c) & 0xff) << 16))
#define HDC_SET_CMD_LEN(r,c) ((r) | (((c) & 0xff) << 0))
#define HDC_GET_STATUS_ST(r) (((r) >> 24) & 0xff)
#define HDC_GET_STATUS_DISK(r) (((r) >> 16) & 0xff)
#define HDC_GET_STATUS_CNT(r) (((r) >> 0) & 0xffff)
/* Constant values */
#define HDC_BLKSIZE (512)
#define HDC_MAX_SIZE (0x1000000000)
#define HDC_CMD_READ (0x01)
#define HDC_CMD_WRITE (0x02)
#define HDC_CMD_INT (0x80)
#define HDC_CMD_MASK (0X7F)
#define HDC_ST_READY (0)
#define HDC_ST_BUSY (1)
#define HDC_ST_DONE (2)
#define HDC_ST_ERROR (3)
+19
View File
@@ -0,0 +1,19 @@
# Copyright (C) 2006 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.
#
LOCAL_DIR := $(GET_LOCAL_DIR)
OPTIONS += \
WITH_SW_HDC=1
MODULES += \
lib/blockdev
ALL_OBJS += \
$(LOCAL_DIR)/hdc.o