-
Notifications
You must be signed in to change notification settings - Fork 0
/
foxtrot_harness.c
60 lines (51 loc) · 1.75 KB
/
foxtrot_harness.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "framework.h"
#include "driver.h"
#include "device_emu.h"
extern void nand_set_register(unsigned char offset, unsigned char value);
extern int nand_wait(unsigned int interval_us);
extern int nand_read(unsigned char *buffer, unsigned int length);
extern int nand_program(unsigned char *buffer, unsigned int length);
extern int exec_op(struct nand_operation *);
extern struct nand_device *init_nand_driver(volatile unsigned char *ioregister,
struct nand_device *old_dib);
volatile unsigned long ioregister = 0;
unsigned char read_buff[NUM_BYTES];
unsigned char write_buff[NUM_BYTES];
#define NUM_OPS 10
int main()
{
const unsigned char addrtmp[1] = { 'a'};
unsigned char addr_buff[3] = { 0, 0, 0};
init_nand_driver(&ioregister, NULL);
/*@
loop invariant 0 <= i <= NUM_BYTES;
loop assigns i, write_buff[0 .. NUM_BYTES-1];
loop variant NUM_BYTES-i;
*/
for (int i=0; i < NUM_BYTES; i++) {
write_buff[i] = 0;
}
/*@
loop invariant 0 <= i <= NUM_BYTES;
loop assigns i, read_buff[0 .. NUM_BYTES-1];
loop variant NUM_BYTES-i;
*/
for (int i=0; i < NUM_BYTES; i++) {
read_buff[i] = 0;
}
struct nand_op_cmd_instr cmd = { 0 };
struct nand_op_instr cmd_instr = { NAND_OP_CMD_INSTR, { cmd, addr, data_in, waitrdy }};
//@ assert \initialized {Here} (&cmd_instr);
struct nand_op_instr instrs[NUM_OPS] = {
cmd_instr, cmd_instr, cmd_instr, cmd_instr, cmd_instr,
cmd_instr, cmd_instr, cmd_instr, cmd_instr, cmd_instr
};
struct nand_operation op = { instrs, NUM_OPS };
//@ assert \initialized {Here} (&instrs[0 .. NUM_OPS-1]);
//@ assert \initialized {Here} (op.instrs + (0 .. NUM_OPS-1));
exec_op(&op);
}