<commit_before>/**
 * @file
 * @brief SD-Card driver for STM32F4-Discovery using SDIO.
 *
 * @author  <NAME>
 * @date    26 Jan 2015
 */

#include <embox/block_dev.h>
#include "stm32f4_discovery_sdio_sd.h"

static int stm32f4_sd_init(void *arg);
static int stm32f4_sd_ioctl(struct block_dev *bdev, int cmd, void *buf, size_t size);
static int stm32f4_sd_read(struct block_dev *bdev, char *buf, size_t count, blkno_t blkno);
static int stm32f4_sd_write(struct block_dev *bdev, char *buf, size_t count, blkno_t blkno);

#define STM32F4_SD_DEVNAME "stm32f4_sd_card"

block_dev_driver_t stm32f4_sd_driver = {
	.name = STM32F4_SD_DEVNAME,
	.ioctl = stm32f4_sd_ioctl,
	.read = stm32f4_sd_read,
	.write = stm32f4_sd_write,
};

EMBOX_BLOCK_DEV(STM32F4_SD_DEVNAME, &stm32f4_sd_driver, stm32f4_sd_init);

static int stm32f4_sd_init(void *arg) {
	return -SD_Init();
}

static int stm32f4_sd_ioctl(struct block_dev *bdev, int cmd, void *buf, size_t size) {
	return 0;
}

static int stm32f4_sd_read(struct block_dev *bdev, char *buf, size_t count, blkno_t blkno) {
	return -SD_ReadBlock((uint8_t*) buf, blkno, SECTOR_SIZE);
}

static int stm32f4_sd_write(struct block_dev *bdev, char *buf, size_t count, blkno_t blkno) {
	return -SD_WriteBlock((uint8_t*) buf, blkno, SECTOR_SIZE);
}

<commit_msg>stm32-sd: blockdev initialization + ioctl<commit_after>/**
 * @file
 * @brief SD-Card driver for STM32F4-Discovery using SDIO.
 *
 * @author  <NAME>
 * @date    26 Jan 2015
 */

#include <embox/block_dev.h>
#include "stm32f4_discovery_sdio_sd.h"

static int stm32f4_sd_init(void *arg);
static int stm32f4_sd_ioctl(struct block_dev *bdev, int cmd, void *buf, size_t size);
static int stm32f4_sd_read(struct block_dev *bdev, char *buf, size_t count, blkno_t blkno);
static int stm32f4_sd_write(struct block_dev *bdev, char *buf, size_t count, blkno_t blkno);

#define STM32F4_SD_DEVNAME "stm32f4_sd_card"

block_dev_driver_t stm32f4_sd_driver = {
	.name = STM32F4_SD_DEVNAME,
	.ioctl = stm32f4_sd_ioctl,
	.read = stm32f4_sd_read,
	.write = stm32f4_sd_write,
};

EMBOX_BLOCK_DEV(STM32F4_SD_DEVNAME, &stm32f4_sd_driver, stm32f4_sd_init);

static int stm32f4_sd_init(void *arg) {
	block_dev_t *bdev;
	if (block_dev_lookup(STM32F4_SD_DEVNAME)) {
		bdev = block_dev_create("/dev/" STM32F4_SD_DEVNAME, &stm32f4_sd_driver, NULL);
		bdev->size = 2048 * 1024; /* XXX Hardcode */
		return -SD_Init();
	}
	return -1;
}

static int stm32f4_sd_ioctl(struct block_dev *bdev, int cmd, void *buf, size_t size) {
	switch (cmd) {
	case IOCTL_GETDEVSIZE:
		return 2048 * 1024; /* XXX Hardcode */
	case IOCTL_GETBLKSIZE:
		return 512;	/* XXX Hardcode */
	default:
		return -1;
	}
}

static int stm32f4_sd_read(struct block_dev *bdev, char *buf, size_t count, blkno_t blkno) {
	return -SD_ReadBlock((uint8_t*) buf, blkno, SECTOR_SIZE);
}

static int stm32f4_sd_write(struct block_dev *bdev, char *buf, size_t count, blkno_t blkno) {
	return -SD_WriteBlock((uint8_t*) buf, blkno, SECTOR_SIZE);
}


{'fraction_non_alphanumeric': 0.11163734776725305, 'fraction_numerical': 0.05717185385656292, 'mean_word_length': 5.484649122807017, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3303048', 'n_tokens_mistral': 1393, 'n_tokens_neox': 1312, 'n_words': 281}