LPCOpen Platform
LPCOpen Platform for NXP LPC Microcontrollers
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
hostemu.c
Go to the documentation of this file.
1
/*
2
hostemu.c
3
DOSFS Embedded FAT-Compatible Filesystem
4
Host-Side Emulation Code
5
(C) 2005 Lewin A.R.W. Edwards (sysadm@zws.com)
6
*/
7
8
#include <stdio.h>
9
#include <stdlib.h>
10
11
#include "
dosfs.h
"
12
#include "
hostemu.h
"
13
14
//===================================================================
15
// Globals
16
FILE *
hostfile
;
// references host-side image file
17
18
/*
19
Attach emulation to a host-side disk image file
20
Returns 0 OK, nonzero for any error
21
*/
22
int
DFS_HostAttach
(
char
*imagefile)
23
{
24
hostfile
= fopen(imagefile,
"r+b"
);
25
if
(
hostfile
==
NULL
)
26
return
-1;
27
28
return
0;
// OK
29
}
30
31
/*
32
Read sector from image
33
Returns 0 OK, nonzero for any error
34
*/
35
int
DFS_HostReadSector
(uint8_t *buffer,
uint32_t
sector,
uint32_t
count)
36
{
37
if
(fseek(
hostfile
, sector *
SECTOR_SIZE
, SEEK_SET))
38
return
-1;
39
40
fread(buffer, SECTOR_SIZE, count,
hostfile
);
41
return
0;
42
}
43
44
/*
45
Write sector to image
46
Returns 0 OK, nonzero for any error
47
*/
48
int
DFS_HostWriteSector
(uint8_t *buffer,
uint32_t
sector,
uint32_t
count)
49
{
50
if
(fseek(
hostfile
, sector *
SECTOR_SIZE
, SEEK_SET))
51
return
-1;
52
53
fwrite(buffer, SECTOR_SIZE, count,
hostfile
);
54
fflush(
hostfile
);
55
return
0;
56
}
applications
lpc18xx_43xx
examples
43xx_dualcore
lwip
lwip_httpserver
dos_fs
hostemu.c
Generated on Fri Nov 16 2012 13:36:34 for LPCOpen Platform by
1.8.2