add ls2k sata ssd driver

This commit is contained in:
bigmagic authored and bigmagic committed 2020-12-29 18:54:12 +08:00
1 parent eaf3e4795d
commit 68689c7c43
18 files changed
+3280

No files matched your search

+35
View File
@@ -385,6 +385,8 @@ CONFIG_RT_LWIP_USING_PING=y
# CONFIG_PKG_USING_AGILE_JSMN is not set
# CONFIG_PKG_USING_PDULIB is not set
# CONFIG_PKG_USING_BTSTACK is not set
# CONFIG_PKG_USING_LORAWAN_ED_STACK is not set
# CONFIG_PKG_USING_WAYZ_IOTKIT is not set
#
# security packages
@@ -410,6 +412,9 @@ CONFIG_RT_LWIP_USING_PING=y
# CONFIG_PKG_USING_STEMWIN is not set
# CONFIG_PKG_USING_WAVPLAYER is not set
# CONFIG_PKG_USING_TJPGD is not set
# CONFIG_PKG_USING_HELIX is not set
# CONFIG_PKG_USING_AZUREGUIX is not set
# CONFIG_PKG_USING_TOUCHGFX2RTT is not set
#
# tools packages
@@ -424,6 +429,7 @@ CONFIG_RT_LWIP_USING_PING=y
# CONFIG_PKG_USING_ADBD is not set
# CONFIG_PKG_USING_COREMARK is not set
# CONFIG_PKG_USING_DHRYSTONE is not set
# CONFIG_PKG_USING_MEMORYPERF is not set
# CONFIG_PKG_USING_NR_MICRO_SHELL is not set
# CONFIG_PKG_USING_CHINESE_FONT_LIBRARY is not set
# CONFIG_PKG_USING_LUNAR_CALENDAR is not set
@@ -431,6 +437,10 @@ CONFIG_RT_LWIP_USING_PING=y
# CONFIG_PKG_USING_GPS_RMC is not set
# CONFIG_PKG_USING_URLENCODE is not set
# CONFIG_PKG_USING_UMCN is not set
# CONFIG_PKG_USING_LWRB2RTT is not set
# CONFIG_PKG_USING_CPU_USAGE is not set
# CONFIG_PKG_USING_GBK2UTF8 is not set
# CONFIG_PKG_USING_VCONSOLE is not set
#
# system packages
@@ -462,8 +472,18 @@ CONFIG_PKG_LWEXT4_VER="latest"
# CONFIG_PKG_USING_RAMDISK is not set
# CONFIG_PKG_USING_MININI is not set
# CONFIG_PKG_USING_QBOOT is not set
#
# Micrium: Micrium software products porting for RT-Thread
#
# CONFIG_PKG_USING_UCOSIII_WRAPPER is not set
# CONFIG_PKG_USING_UCOSII_WRAPPER is not set
# CONFIG_PKG_USING_UC_CRC is not set
# CONFIG_PKG_USING_UC_CLK is not set
# CONFIG_PKG_USING_UC_COMMON is not set
# CONFIG_PKG_USING_UC_MODBUS is not set
# CONFIG_PKG_USING_PPOOL is not set
# CONFIG_PKG_USING_OPENAMP is not set
#
# peripheral libraries and drivers
@@ -517,6 +537,13 @@ CONFIG_PKG_LWEXT4_VER="latest"
# CONFIG_PKG_USING_LD3320 is not set
# CONFIG_PKG_USING_WK2124 is not set
# CONFIG_PKG_USING_LY68L6400 is not set
# CONFIG_PKG_USING_DM9051 is not set
# CONFIG_PKG_USING_SSD1306 is not set
# CONFIG_PKG_USING_QKEY is not set
# CONFIG_PKG_USING_RS485 is not set
# CONFIG_PKG_USING_NES is not set
# CONFIG_PKG_USING_VIRTUAL_SENSOR is not set
# CONFIG_PKG_USING_VDEVICE is not set
#
# miscellaneous packages
@@ -526,6 +553,7 @@ CONFIG_PKG_LWEXT4_VER="latest"
# CONFIG_PKG_USING_FASTLZ is not set
# CONFIG_PKG_USING_MINILZO is not set
# CONFIG_PKG_USING_QUICKLZ is not set
# CONFIG_PKG_USING_LZMA is not set
# CONFIG_PKG_USING_MULTIBUTTON is not set
# CONFIG_PKG_USING_FLEXIBLE_BUTTON is not set
# CONFIG_PKG_USING_CANFESTIVAL is not set
@@ -546,6 +574,7 @@ CONFIG_PKG_LWEXT4_VER="latest"
# CONFIG_PKG_USING_PERIPHERAL_SAMPLES is not set
# CONFIG_PKG_USING_HELLO is not set
# CONFIG_PKG_USING_VI is not set
# CONFIG_PKG_USING_KI is not set
# CONFIG_PKG_USING_NNOM is not set
# CONFIG_PKG_USING_LIBANN is not set
# CONFIG_PKG_USING_ELAPACK is not set
@@ -554,8 +583,14 @@ CONFIG_PKG_LWEXT4_VER="latest"
# CONFIG_PKG_USING_ULAPACK is not set
# CONFIG_PKG_USING_UKAL is not set
# CONFIG_PKG_USING_CRCLIB is not set
#
# games: games run on RT-Thread console
#
# CONFIG_PKG_USING_THREES is not set
# CONFIG_PKG_USING_2048 is not set
# CONFIG_PKG_USING_SNAKE is not set
# CONFIG_PKG_USING_TETRIS is not set
# CONFIG_PKG_USING_LWGPS is not set
# CONFIG_PKG_USING_TENSORFLOWLITEMICRO is not set
CONFIG_SOC_LS2K1000=y
+39
View File
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2006-2020, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2020-12-29 bigmagic first version
*/
#include <rthw.h>
#include <rtthread.h>
#include <dfs.h>
#include <dfs_fs.h>
#include <dfs_file.h>
#include <ext4.h>
#include <ext4_debug.h>
#include <blk_device.h>
#include <stdint.h>
#include <pci.h>
int mount_ssd(void)
{
struct blk_device *blkdev = (struct blk_device *)rt_device_find("dwc_ahsata_blk");
if(blkdev == RT_NULL)
{
rt_kprintf("dwc_ahsata_blk not found!\n");
return;
}
//ext4_dmask_set(0xFFFFFFFF);
blk_device_init(blkdev);
dfs_mount("dwc_ahsata_blk","/","ext",0,(void *)1);
dfs_mount("dwc_ahsata_blk","/boot","ext",0,(void *)0);
return 0;
}
INIT_ENV_EXPORT(mount_ssd);
+14
View File
@@ -0,0 +1,14 @@
from building import *
cwd = GetCurrentDir()
src = Glob('*.c')
CPPPATH = [cwd]
if GetDepend('RT_USING_DFS_ELMFAT') == False:
SrcRemove(src, 'dwc_ahsata.c')
SrcRemove(src, 'libata.c')
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH)
Return('group')
File diff suppressed because it is too large. Load diff
+20
View File
@@ -0,0 +1,20 @@
/*
* Copyright (c) 2006-2020, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2020-08-19 lizhirui first version
*/
#ifndef __ATA_DEBUG_H__
#define __ATA_DEBUG_H__
//#define ATA_DEBUG
#include <rtthread.h>
#ifdef ATA_DEBUG
#define debug rt_kprintf
#else
#define debug(...)
#endif
#endif
+101
View File
@@ -0,0 +1,101 @@
/*
* Copyright (c) 2006-2020, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2020-08-19 lizhirui first version
*/
#ifndef __ATA_INTERFACE_H__
#define __ATA_INTERFACE_H__
typedef rt_uint8_t u8;
typedef rt_uint16_t u16;
typedef rt_uint32_t u32;
typedef rt_uint64_t u64;
typedef rt_uint64_t ulong;
typedef rt_int8_t s8;
typedef rt_int16_t s16;
typedef rt_int32_t s32;
typedef rt_int64_t s64;
typedef rt_size_t lbaint_t;
#define __iomem
#define mdelay rt_thread_mdelay
#define udelay(...) rt_thread_mdelay(1)
#define cpu_to_le32
#define cpu_to_le16
#define le32_to_cpu
#define le16_to_cpu
#define flush_cache(...)
#define invalidate_dcache_range(...)
#define ARCH_DMA_MINALIGN 1024
#define CONFIG_IS_ENABLED
#define AHCI 1
#define VADDR_TO_PHY(vaddr) (((u64)vaddr) - KSEG0BASE)
#define LOW_PHY(vaddr) ((u32)VADDR_TO_PHY(vaddr))
#define HIGH_PHY(vaddr) ((u32)((VADDR_TO_PHY(vaddr)) >> 32))
#define ALIGN_1(x, a) __ALIGN_MASK((x), (typeof(x))(a)-1)
#define ALIGN_DOWN(x, a) ALIGN_1((x) - ((a)-1), (a))
#define __ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask))
#define PTR_ALIGN(p, a) ((typeof(p))ALIGN((unsigned long)(p), (a)))
#define IS_ALIGNED(x, a) (((x) & ((typeof(x))(a)-1)) == 0)
#define ROUND(a, b) (((a) + (b)-1) & ~((b)-1))
#define PAD_COUNT(s, pad) (((s)-1) / (pad) + 1)
#define PAD_SIZE(s, pad) (PAD_COUNT(s, pad) * pad)
#define ALLOC_ALIGN_BUFFER_PAD(type, name, size, align, pad) \
char __##name[ROUND(PAD_SIZE((size) * sizeof(type), pad), align) + (align - 1)]; \
\
type *name = (type *)ALIGN_1((rt_ubase_t)__##name, align)
#define ALLOC_ALIGN_BUFFER(type, name, size, align) \
ALLOC_ALIGN_BUFFER_PAD(type, name, size, align, 1)
#define ALLOC_CACHE_ALIGN_BUFFER_PAD(type, name, size, pad) \
ALLOC_ALIGN_BUFFER_PAD(type, name, size, ARCH_DMA_MINALIGN, pad)
#define ALLOC_CACHE_ALIGN_BUFFER(type, name, size) \
ALLOC_ALIGN_BUFFER(type, name, size, ARCH_DMA_MINALIGN)
static inline u32 readl(void *addr)
{
return *((u32 *)addr);
}
static inline void writel(u32 data, void *addr)
{
*((u32 *)addr) = data;
}
static inline int ffs(int word)
{
int r;
if (word == 0)
{
return 0;
}
word &= (-word);
__asm__("clz %0, %1"
: "=r"(r)
: "r"(word));
return 32 - r;
}
static inline void setbits_le32(u32 *addr, u32 value)
{
*addr = value;
}
#endif
+127
View File
@@ -0,0 +1,127 @@
/*
* Copyright (c) 2006-2020, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2020-08-19 lizhirui first version
*/
#include <rtthread.h>
#include <rtdef.h>
#include <dfs.h>
#include <dfs_fs.h>
#include <dfs_file.h>
#include <ext4.h>
#include <ext4_debug.h>
#include <blk_device.h>
#include <stdint.h>
static struct blk_device *blkdev;
static rt_uint32_t disk_sector_size;
static int blockdev_open(struct ext4_blockdev *bdev)
{
int r;
uint32_t size;
rt_device_t device = (rt_device_t)blkdev;
struct rt_device_blk_geometry geometry;
RT_ASSERT(device);
r = rt_device_open((rt_device_t)blkdev, RT_DEVICE_OFLAG_RDWR);
if (r != RT_EOK)
{
return r;
}
r = rt_device_control(device, RT_DEVICE_CTRL_BLK_GETGEOME, &geometry);
if (RT_EOK == r)
{
bdev->part_offset = 0;
bdev->part_size = geometry.sector_count * geometry.bytes_per_sector;
disk_sector_size = geometry.bytes_per_sector;
bdev->bdif->ph_bcnt = bdev->part_size / bdev->bdif->ph_bsize;
}
return r;
}
static int blockdev_bread(struct ext4_blockdev *bdev, void *buf, uint64_t blk_id,
uint32_t blk_cnt)
{
int result;
rt_device_t device = (rt_device_t)blkdev;
struct blk_device *blk = (struct blk_device *)device;
RT_ASSERT(device);
result = rt_device_read(device, blk_id * (bdev->bdif->ph_bsize / disk_sector_size),
buf, blk_cnt * (bdev->bdif->ph_bsize / disk_sector_size));
if ((blk_cnt * (bdev->bdif->ph_bsize / disk_sector_size)) == result)
{
result = 0;
}
else
{
result = -EIO;
}
return result;
}
static int blockdev_bwrite(struct ext4_blockdev *bdev, const void *buf,
uint64_t blk_id, uint32_t blk_cnt)
{
int result;
rt_device_t device = (rt_device_t)blkdev;
RT_ASSERT(device);
result = rt_device_write(device, blk_id * (bdev->bdif->ph_bsize / disk_sector_size),
buf, blk_cnt * (bdev->bdif->ph_bsize / disk_sector_size));
if ((blk_cnt * (bdev->bdif->ph_bsize / disk_sector_size)) == result)
{
result = 0;
}
else
{
result = -EIO;
}
return result;
}
static int blockdev_close(struct ext4_blockdev *bdev)
{
return rt_device_close((rt_device_t)blkdev);
}
static int blockdev_lock(struct ext4_blockdev *bdev)
{
return 0;
}
static int blockdev_unlock(struct ext4_blockdev *bdev)
{
return 0;
}
EXT4_BLOCKDEV_STATIC_INSTANCE(bdev, 4096, 0, blockdev_open,
blockdev_bread, blockdev_bwrite, blockdev_close,
blockdev_lock, blockdev_unlock);
void blk_device_init(struct blk_device *blk_devices)
{
blkdev = blk_devices;
if (ext4_mbr_scan(&bdev, &(blkdev->ext4_partition)) != EOK)
{
rt_kprintf("MBR scan failed!\n");
return;
}
}
+48
View File
@@ -0,0 +1,48 @@
/*
* Copyright (c) 2006-2020, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2020-08-19 lizhirui first version
*/
#ifndef __BLK_DEVICE_H__
#define __BLK_DEVICE_H__
#include <rtconfig.h>
#include <ext4_mbr.h>
#define DEV_TYPE_UNKNOWN 0xff /* not connected */
#define DEV_TYPE_HARDDISK 0x00 /* harddisk */
#define DEV_TYPE_TAPE 0x01 /* Tape */
#define DEV_TYPE_CDROM 0x05 /* CD-ROM */
#define DEV_TYPE_OPDISK 0x07 /* optical disk */
struct blk_device
{
struct rt_device parent;
struct ahci_uc_priv *ahci_device;
rt_uint8_t target;
rt_uint8_t lun;
rt_uint8_t type;
#ifdef RT_USING_DFS_LWEXT4
struct ext4_mbr_bdevs ext4_partition;
#endif
rt_bool_t lba48;
rt_uint64_t lba;
rt_uint64_t blksz;
rt_int32_t log2blksz;
char product[21];
char revision[9];
char vendor[41];
};
void blk_device_init(struct blk_device *blk_devices);
#endif
File diff suppressed because it is too large. Load diff
+25
View File
@@ -0,0 +1,25 @@
/*
* Copyright (c) 2006-2020, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2020-08-19 lizhirui porting to ls2k
*/
#ifndef __DWC_AHSATA_H__
#define __DWC_AHSATA_H__
#define DWCAHSATA_BASE (0x9000000000000000 | 0x400e0000)
int dwc_ahsata_bus_reset(struct rt_device *dev);
int dwc_ahsata_probe(struct rt_device *dev);
int dwc_ahsata_scan(struct rt_device *dev);
int dwc_ahsata_port_status(struct rt_device *dev, int port);
rt_size_t dwc_ahsata_read(rt_device_t dev, rt_off_t pos, void *buffer, rt_size_t size);
rt_size_t dwc_ahsata_write(rt_device_t dev, rt_off_t pos, const void *buffer, rt_size_t size);
rt_err_t dwc_ahsata_control(rt_device_t dev, int cmd, void *args);
#endif
File diff suppressed because it is too large. Load diff
+152
View File
@@ -0,0 +1,152 @@
/*
* Copyright (c) 2006-2020, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2020-08-19 lizhirui porting to ls2k
*/
#ifndef __FIS_H__
#define __FIS_H__
/*
* Register - Host to Device FIS
*/
typedef struct sata_fis_h2d
{
u8 fis_type;
u8 pm_port_c;
u8 command;
u8 features;
u8 lba_low;
u8 lba_mid;
u8 lba_high;
u8 device;
u8 lba_low_exp;
u8 lba_mid_exp;
u8 lba_high_exp;
u8 features_exp;
u8 sector_count;
u8 sector_count_exp;
u8 res1;
u8 control;
u8 res2[4];
} __attribute__((packed)) sata_fis_h2d_t;
/*
* Register - Host to Device FIS for read/write FPDMA queued
*/
typedef struct sata_fis_h2d_ncq
{
u8 fis_type;
u8 pm_port_c;
u8 command;
u8 sector_count_low;
u8 lba_low;
u8 lba_mid;
u8 lba_high;
u8 device;
u8 lba_low_exp;
u8 lba_mid_exp;
u8 lba_high_exp;
u8 sector_count_high;
u8 tag;
u8 res1;
u8 res2;
u8 control;
u8 res3[4];
} __attribute__((packed)) sata_fis_h2d_ncq_t;
/*
* Register - Device to Host FIS
*/
typedef struct sata_fis_d2h
{
u8 fis_type;
u8 pm_port_i;
u8 status;
u8 error;
u8 lba_low;
u8 lba_mid;
u8 lba_high;
u8 device;
u8 lba_low_exp;
u8 lba_mid_exp;
u8 lba_high_exp;
u8 res1;
u8 sector_count;
u8 sector_count_exp;
u8 res2[2];
u8 res3[4];
} __attribute__((packed)) sata_fis_d2h_t;
/*
* DMA Setup - Device to Host or Host to Device FIS
*/
typedef struct sata_fis_dma_setup
{
u8 fis_type;
u8 pm_port_dir_int_act;
u8 res1;
u8 res2;
u32 dma_buffer_id_low;
u32 dma_buffer_id_high;
u32 res3;
u32 dma_buffer_offset;
u32 dma_transfer_count;
u32 res4;
} __attribute__((packed)) sata_fis_dma_setup_t;
/*
* PIO Setup - Device to Host FIS
*/
typedef struct sata_fis_pio_setup
{
u8 fis_type;
u8 pm_port_dir_int;
u8 status;
u8 error;
u8 lba_low;
u8 lba_mid;
u8 lba_high;
u8 res1;
u8 lba_low_exp;
u8 lba_mid_exp;
u8 lba_high_exp;
u8 res2;
u8 sector_count;
u8 sector_count_exp;
u8 res3;
u8 e_status;
u16 transfer_count;
u16 res4;
} __attribute__((packed)) sata_fis_pio_setup_t;
/*
* Data - Host to Device or Device to Host FIS
*/
typedef struct sata_fis_data
{
u8 fis_type;
u8 pm_port;
u8 res1;
u8 res2;
u32 data[2048];
} __attribute__((packed)) sata_fis_data_t;
/* fis_type - SATA FIS type
*/
enum sata_fis_type
{
SATA_FIS_TYPE_REGISTER_H2D = 0x27,
SATA_FIS_TYPE_REGISTER_D2H = 0x34,
SATA_FIS_TYPE_DMA_ACT_D2H = 0x39,
SATA_FIS_TYPE_DMA_SETUP_BI = 0x41,
SATA_FIS_TYPE_DATA_BI = 0x46,
SATA_FIS_TYPE_BIST_ACT_BI = 0x58,
SATA_FIS_TYPE_PIO_SETUP_D2H = 0x5F,
SATA_FIS_TYPE_SET_DEVICE_BITS_D2H = 0xA1,
};
#endif /* __FIS_H__ */
+150
View File
@@ -0,0 +1,150 @@
/*
* Copyright (c) 2006-2020, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2020-08-19 lizhirui porting to ls2k
*/
#include <rtthread.h>
#include <ata_interface.h>
#include <libata.h>
u64 ata_id_n_sectors(u16 *id)
{
if (ata_id_has_lba(id)) {
if (ata_id_has_lba48(id))
return ata_id_u64(id, ATA_ID_LBA48_SECTORS);
else
return ata_id_u32(id, ATA_ID_LBA_SECTORS);
} else {
return 0;
}
}
u32 ata_dev_classify(u32 sig)
{
u8 lbam, lbah;
lbam = (sig >> 16) & 0xff;
lbah = (sig >> 24) & 0xff;
if (((lbam == 0) && (lbah == 0)) ||
((lbam == 0x3c) && (lbah == 0xc3)))
return ATA_DEV_ATA;
if ((lbam == 0x14) && (lbah == 0xeb))
return ATA_DEV_ATAPI;
if ((lbam == 0x69) && (lbah == 0x96))
return ATA_DEV_PMP;
return ATA_DEV_UNKNOWN;
}
static void ata_id_string(const u16 *id, unsigned char *s,
unsigned int ofs, unsigned int len)
{
unsigned int c;
while (len > 0) {
c = id[ofs] >> 8;
*s = c;
s++;
c = id[ofs] & 0xff;
*s = c;
s++;
ofs++;
len -= 2;
}
}
void ata_id_c_string(const u16 *id, unsigned char *s,
unsigned int ofs, unsigned int len)
{
unsigned char *p;
ata_id_string(id, s, ofs, len - 1);
p = s + strnlen((char *)s, len - 1);
while (p > s && p[-1] == ' ')
p--;
*p = '\0';
}
void ata_dump_id(u16 *id)
{
unsigned char serial[ATA_ID_SERNO_LEN + 1];
unsigned char firmware[ATA_ID_FW_REV_LEN + 1];
unsigned char product[ATA_ID_PROD_LEN + 1];
u64 n_sectors;
/* Serial number */
ata_id_c_string(id, serial, ATA_ID_SERNO, sizeof(serial));
printf("S/N: %s\n\r", serial);
/* Firmware version */
ata_id_c_string(id, firmware, ATA_ID_FW_REV, sizeof(firmware));
printf("Firmware version: %s\n\r", firmware);
/* Product model */
ata_id_c_string(id, product, ATA_ID_PROD, sizeof(product));
printf("Product model number: %s\n\r", product);
/* Total sectors of device */
n_sectors = ata_id_n_sectors(id);
printf("Capablity: %lld sectors\n\r", n_sectors);
printf ("id[49]: capabilities = 0x%04x\n"
"id[53]: field valid = 0x%04x\n"
"id[63]: mwdma = 0x%04x\n"
"id[64]: pio = 0x%04x\n"
"id[75]: queue depth = 0x%04x\n",
id[49],
id[53],
id[63],
id[64],
id[75]);
printf ("id[76]: sata capablity = 0x%04x\n"
"id[78]: sata features supported = 0x%04x\n"
"id[79]: sata features enable = 0x%04x\n",
id[76],
id[78],
id[79]);
printf ("id[80]: major version = 0x%04x\n"
"id[81]: minor version = 0x%04x\n"
"id[82]: command set supported 1 = 0x%04x\n"
"id[83]: command set supported 2 = 0x%04x\n"
"id[84]: command set extension = 0x%04x\n",
id[80],
id[81],
id[82],
id[83],
id[84]);
printf ("id[85]: command set enable 1 = 0x%04x\n"
"id[86]: command set enable 2 = 0x%04x\n"
"id[87]: command set default = 0x%04x\n"
"id[88]: udma = 0x%04x\n"
"id[93]: hardware reset result = 0x%04x\n",
id[85],
id[86],
id[87],
id[88],
id[93]);
}
void ata_swap_buf_le16(u16 *buf, unsigned int buf_words)
{
unsigned int i;
for (i = 0; i < buf_words; i++)
{
buf[i] = le16_to_cpu(buf[i]);
}
}
File diff suppressed because it is too large. Load diff
+10
View File
@@ -0,0 +1,10 @@
from building import *
cwd = GetCurrentDir()
src = Glob('*.c')
CPPPATH = [cwd]
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH)
Return('group')
+20
View File
@@ -0,0 +1,20 @@
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2020-12-28 lizhirui first version
*/
#include <rtthread.h>
#include <pci.h>
rt_uint64_t pci_get_device_map_addr(rt_uint64_t bus,rt_uint64_t device,rt_uint64_t function,rt_uint32_t index)
{
rt_uint64_t device_addr = 0xFE00000000 | (bus << 16) | ((device & 0x1f) << 11) | ((function & 0x07) << 8);
struct pci_header *p = (struct pci_header *)(0x9000000000000000UL | device_addr);
return 0x9000000000000000UL | ((rt_uint64_t)(p -> BaseAddressRegister[index] & 0xFFFFFFF0));
}
+42
View File
@@ -0,0 +1,42 @@
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2020-12-28 lizhirui first version
*/
#ifndef __PCI_H__
#define __PCI_H__
struct pci_header
{
rt_uint16_t VendorID;
rt_uint16_t DeviceID;
rt_uint16_t Command;
rt_uint16_t Status;
rt_uint32_t RevisionID : 8;
rt_uint32_t ClassCode : 24;
rt_uint8_t CachelineSize;
rt_uint8_t LatencyTimer;
rt_uint8_t HeaderType;
rt_uint8_t BIST;
rt_uint32_t BaseAddressRegister[6];
rt_uint32_t CardbusCISPointer;
rt_uint16_t SubsystemVendorID;
rt_uint16_t SubsystemID;
rt_uint32_t ExpansionROMBaseAddress;
rt_uint32_t CapabilitiesPointer : 8;
rt_uint32_t resv1 : 24;
rt_uint32_t resv2;
rt_uint8_t InterruptLine;
rt_uint8_t InterruptPin;
rt_uint8_t Min_Gnt;
rt_uint8_t Max_Lat;
};
rt_uint64_t pci_get_device_map_addr(rt_uint64_t bus,rt_uint64_t device,rt_uint64_t function,rt_uint32_t index);
#endif
+6
View File
@@ -223,6 +223,9 @@
#define RT_USING_DFS_LWEXT4
#define PKG_USING_LWEXT4_LATEST_VERSION
/* Micrium: Micrium software products porting for RT-Thread */
/* peripheral libraries and drivers */
@@ -231,6 +234,9 @@
/* samples: kernel and components samples */
/* games: games run on RT-Thread console */
#define SOC_LS2K1000
#endif