require '_h2ph_pre.ph';

no warnings qw(redefine misc);

unless(defined(&_FLASHIO_H_)) {
    eval 'sub _FLASHIO_H_ () {1;}' unless defined(&_FLASHIO_H_);
    require 'sys/ioctl.ph';
    if(defined(&_KERNEL) || defined(&_STANDALONE)) {
	require 'sys/types.ph';
    } else {
	require 'stdint.ph';
	require 'stdbool.ph';
    }
    eval("sub FLASH_ERASE_DONE () { 0x0; }") unless defined(&FLASH_ERASE_DONE);
    eval("sub FLASH_ERASE_FAILED () { 0x1; }") unless defined(&FLASH_ERASE_FAILED);
    eval("sub FLASH_TYPE_UNKNOWN () { 0x0; }") unless defined(&FLASH_TYPE_UNKNOWN);
    eval("sub FLASH_TYPE_NOR () { 0x1; }") unless defined(&FLASH_TYPE_NOR);
    eval("sub FLASH_TYPE_NAND () { 0x2; }") unless defined(&FLASH_TYPE_NAND);
    eval("sub FLASH_IOCTL_ERASE_BLOCK () { 0; }") unless defined(&FLASH_IOCTL_ERASE_BLOCK);
    eval("sub FLASH_IOCTL_DUMP () { 1; }") unless defined(&FLASH_IOCTL_DUMP);
    eval("sub FLASH_IOCTL_GET_INFO () { 2; }") unless defined(&FLASH_IOCTL_GET_INFO);
    eval("sub FLASH_IOCTL_BLOCK_ISBAD () { 3; }") unless defined(&FLASH_IOCTL_BLOCK_ISBAD);
    eval("sub FLASH_IOCTL_BLOCK_MARKBAD () { 4; }") unless defined(&FLASH_IOCTL_BLOCK_MARKBAD);
    eval 'sub FLASH_ERASE_BLOCK () { &_IOW(ord(\'&\'),  &FLASH_IOCTL_ERASE_BLOCK, \'struct flash_erase_params\');}' unless defined(&FLASH_ERASE_BLOCK);
    eval 'sub FLASH_DUMP () { &_IOWR(ord(\'&\'),  &FLASH_IOCTL_DUMP, \'struct flash_dump_params\');}' unless defined(&FLASH_DUMP);
    eval 'sub FLASH_GET_INFO () { &_IOWR(ord(\'&\'),  &FLASH_IOCTL_GET_INFO, \'struct flash_info_params\');}' unless defined(&FLASH_GET_INFO);
    eval 'sub FLASH_BLOCK_ISBAD () { &_IOWR(ord(\'&\'),  &FLASH_IOCTL_BLOCK_ISBAD, \'struct flash_badblock_params\');}' unless defined(&FLASH_BLOCK_ISBAD);
    eval 'sub FLASH_BLOCK_MARKBAD () { &_IOW(ord(\'&\'),  &FLASH_IOCTL_BLOCK_MARKBAD, \'struct flash_badblock_params\');}' unless defined(&FLASH_BLOCK_MARKBAD);
}
1;
