1 /** @file
2   Functions declaration related with Mtftp for UefiPxeBc Driver.
3 
4   Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>
5 
6   This program and the accompanying materials
7   are licensed and made available under the terms and conditions of the BSD License
8   which accompanies this distribution.  The full text of the license may be found at
9   http://opensource.org/licenses/bsd-license.php.
10 
11   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 
14 **/
15 
16 #ifndef __EFI_PXEBC_MTFTP_H__
17 #define __EFI_PXEBC_MTFTP_H__
18 
19 #define PXE_MTFTP_OPTION_BLKSIZE_INDEX     0
20 #define PXE_MTFTP_OPTION_TIMEOUT_INDEX     1
21 #define PXE_MTFTP_OPTION_TSIZE_INDEX       2
22 #define PXE_MTFTP_OPTION_MULTICAST_INDEX   3
23 #define PXE_MTFTP_OPTION_MAXIMUM_INDEX     4
24 #define PXE_MTFTP_OPTBUF_MAXNUM_INDEX      128
25 
26 #define PXE_MTFTP_ERROR_STRING_LENGTH      127   // refer to definition of struct EFI_PXE_BASE_CODE_TFTP_ERROR.
27 #define PXE_MTFTP_DEFAULT_BLOCK_SIZE       512   // refer to rfc-1350.
28 
29 
30 /**
31   This function is wrapper to get the file size using TFTP.
32 
33   @param[in]      Private        Pointer to PxeBc private data.
34   @param[in]      Config         Pointer to configure data.
35   @param[in]      Filename       Pointer to boot file name.
36   @param[in]      BlockSize      Pointer to required block size.
37   @param[in, out] BufferSize     Pointer to buffer size.
38 
39   @retval EFI_SUCCESS        Successfully obtained the size of file.
40   @retval EFI_NOT_FOUND      Parse the tftp ptions failed.
41   @retval EFI_DEVICE_ERROR   The network device encountered an error during this operation.
42   @retval Others             Did not obtain the size of the file.
43 
44 **/
45 EFI_STATUS
46 PxeBcTftpGetFileSize (
47   IN     PXEBC_PRIVATE_DATA         *Private,
48   IN     VOID                       *Config,
49   IN     UINT8                      *Filename,
50   IN     UINTN                      *BlockSize,
51   IN OUT UINT64                     *BufferSize
52   );
53 
54 
55 /**
56   This function is a wrapper to get a file using TFTP.
57 
58   @param[in]      Private        Pointer to PxeBc private data.
59   @param[in]      Config         Pointer to config data.
60   @param[in]      Filename       Pointer to boot file name.
61   @param[in]      BlockSize      Pointer to required block size.
62   @param[in]      BufferPtr      Pointer to buffer.
63   @param[in, out] BufferSize     Pointer to buffer size.
64   @param[in]      DontUseBuffer  Indicates whether to use a receive buffer.
65 
66   @retval EFI_SUCCESS        Successfully read the data from the special file.
67   @retval EFI_DEVICE_ERROR   The network device encountered an error during this operation.
68   @retval Others             Read data from file failed.
69 
70 **/
71 EFI_STATUS
72 PxeBcTftpReadFile (
73   IN     PXEBC_PRIVATE_DATA         *Private,
74   IN     VOID                       *Config,
75   IN     UINT8                      *Filename,
76   IN     UINTN                      *BlockSize,
77   IN     UINT8                      *BufferPtr,
78   IN OUT UINT64                     *BufferSize,
79   IN     BOOLEAN                    DontUseBuffer
80   );
81 
82 
83 /**
84   This function is a wrapper to put file with TFTP.
85 
86   @param[in]       Private        Pointer to PxeBc private data.
87   @param[in]       Config         Pointer to config data.
88   @param[in]       Filename       Pointer to boot file name.
89   @param[in]       Overwrite      Indicates whether to use an overwrite attribute.
90   @param[in]       BlockSize      Pointer to required block size.
91   @param[in]       BufferPtr      Pointer to buffer.
92   @param[in, out]  BufferSize     Pointer to buffer size.
93 
94   @retval EFI_SUCCESS        Successfully wrote the data into the special file.
95   @retval EFI_DEVICE_ERROR   The network device encountered an error during this operation.
96   @retval other              Write data into file failed.
97 
98 **/
99 EFI_STATUS
100 PxeBcTftpWriteFile (
101   IN     PXEBC_PRIVATE_DATA         *Private,
102   IN     VOID                       *Config,
103   IN     UINT8                      *Filename,
104   IN     BOOLEAN                    Overwrite,
105   IN     UINTN                      *BlockSize,
106   IN     UINT8                      *BufferPtr,
107   IN OUT UINT64                     *BufferSize
108   );
109 
110 
111 /**
112   This function is a wrapper to get the data (file) from a directory using TFTP.
113 
114   @param[in]       Private        Pointer to PxeBc private data.
115   @param[in]       Config         Pointer to config data.
116   @param[in]       Filename       Pointer to boot file name.
117   @param[in]       BlockSize      Pointer to required block size.
118   @param[in]       BufferPtr      Pointer to buffer.
119   @param[in, out]  BufferSize     Pointer to buffer size.
120   @param[in]       DontUseBuffer  Indicates whether with a receive buffer.
121 
122   @retval EFI_SUCCES         Successfully obtained the data from the file included in directory.
123   @retval EFI_DEVICE_ERROR   The network device encountered an error during this operation.
124   @retval Others             Operation failed.
125 
126 **/
127 EFI_STATUS
128 PxeBcTftpReadDirectory (
129   IN     PXEBC_PRIVATE_DATA            *Private,
130   IN     VOID                          *Config,
131   IN     UINT8                         *Filename,
132   IN     UINTN                         *BlockSize,
133   IN     UINT8                         *BufferPtr,
134   IN OUT UINT64                        *BufferSize,
135   IN     BOOLEAN                       DontUseBuffer
136   );
137 #endif
138