ARM: sc8830: fdl: remove build warnings
[profile/mobile/platform/kernel/u-boot-tm1.git] / nand_fdl / common / src / dl_engine.c
1 #include <asm/arch/dl_engine.h>
2 #include <asm/arch/packet.h>
3 #include <asm/arch/fdl_stdio.h>
4 #include <linux/string.h>
5
6 typedef struct _DL_STATUS
7 {
8     DL_STAGE stage;
9     int      data_verify;   /* Record the result of the latest file download
10                              * operation. */
11 } DL_STATUS, *PDL_STATUS;
12
13 typedef struct _CMDPROC_TAB
14 {
15     CMDPROC    proc;
16     void      *arg;
17 } CMDPROC_TAB, *PCMDPROC_TAB;
18
19 CMDPROC_TAB g_proctab[BSL_CMD_TYPE_MAX - BSL_CMD_TYPE_MIN] = {{0, 0}};
20
21 #define IS_VALID_CMD(cmd)           ((cmd >= BSL_CMD_TYPE_MIN) && (cmd < BSL_CMD_TYPE_MAX))
22 #define CMD_IND(cmd)                ((cmd) - BSL_CMD_TYPE_MIN)
23 #define CMD_PROC(cmd)               (g_proctab[CMD_IND(cmd)].proc)
24 #define CMD_ARG(cmd)                (g_proctab[CMD_IND(cmd)].arg)
25 #define CALL_PROC(cmd, packet)      (CMD_PROC(cmd)((packet), CMD_ARG(cmd)))
26
27 unsigned char FDL_DlInit (void)
28 {
29     memset (g_proctab, 0, sizeof (g_proctab));
30     return 1;
31 }
32
33 unsigned char FDL_DlReg (CMD_TYPE cmd, CMDPROC proc, void *arg)
34 {
35     if (!IS_VALID_CMD (cmd))
36     {
37         return 0;
38     }
39
40     CMD_PROC (cmd) = proc;
41     CMD_ARG (cmd) = arg;
42     return 1;
43 }
44
45
46 int FDL_DlEntry (DL_STAGE start)
47 {
48     cmd_pkt_type pkt_type;
49     PACKET_T    *packet_ptr;
50
51     while (1)
52     {
53         //receive packet
54         packet_ptr = FDL_GetPacket();
55
56         pkt_type = (cmd_pkt_type) (packet_ptr->packet_body.type);
57         pkt_type = (cmd_pkt_type)(EndianConv_16((unsigned short)pkt_type));
58         packet_ptr->packet_body.size = EndianConv_16(packet_ptr->packet_body.size);
59         
60         CALL_PROC(pkt_type, packet_ptr);
61
62         FDL_FreePacket (packet_ptr);
63     }
64
65     // return BSL_PHONE_SUCCEED;
66 }
67
68
69