Changeset View
Changeset View
Standalone View
Standalone View
stand/efi/libefi/efihttp.c
Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | |||||
static EFI_GUID httpsb_guid = EFI_HTTP_SERVICE_BINDING_PROTOCOL_GUID; | static EFI_GUID httpsb_guid = EFI_HTTP_SERVICE_BINDING_PROTOCOL_GUID; | ||||
static EFI_GUID ip4config2_guid = EFI_IP4_CONFIG2_PROTOCOL_GUID; | static EFI_GUID ip4config2_guid = EFI_IP4_CONFIG2_PROTOCOL_GUID; | ||||
static bool efihttp_init_done = false; | static bool efihttp_init_done = false; | ||||
static int efihttp_dev_init(void); | static int efihttp_dev_init(void); | ||||
static int efihttp_dev_strategy(void *devdata, int rw, daddr_t blk, size_t size, | static int efihttp_dev_strategy(void *devdata, int rw, daddr_t blk, size_t size, | ||||
char *buf, size_t *rsize); | char *buf, size_t *rsize); | ||||
static int efihttp_dev_open(struct open_file *f, ...); | static int efihttp_dev_open(struct open_file *f, struct devdesc *dev); | ||||
static int efihttp_dev_close(struct open_file *f); | static int efihttp_dev_close(struct open_file *f); | ||||
static int efihttp_fs_open(const char *path, struct open_file *f); | static int efihttp_fs_open(const char *path, struct open_file *f); | ||||
static int efihttp_fs_close(struct open_file *f); | static int efihttp_fs_close(struct open_file *f); | ||||
static int efihttp_fs_read(struct open_file *f, void *buf, size_t size, | static int efihttp_fs_read(struct open_file *f, void *buf, size_t size, | ||||
size_t *resid); | size_t *resid); | ||||
static int efihttp_fs_write(struct open_file *f, const void *buf, size_t size, | static int efihttp_fs_write(struct open_file *f, const void *buf, size_t size, | ||||
size_t *resid); | size_t *resid); | ||||
▲ Show 20 Lines • Show All 153 Lines • ▼ Show 20 Lines | |||||
efihttp_dev_strategy(void *devdata __unused, int rw __unused, | efihttp_dev_strategy(void *devdata __unused, int rw __unused, | ||||
daddr_t blk __unused, size_t size __unused, char *buf __unused, | daddr_t blk __unused, size_t size __unused, char *buf __unused, | ||||
size_t *rsize __unused) | size_t *rsize __unused) | ||||
{ | { | ||||
return (EIO); | return (EIO); | ||||
} | } | ||||
static int | static int | ||||
efihttp_dev_open(struct open_file *f, ...) | efihttp_dev_open(struct open_file *f, struct devdesc *dev) | ||||
tsoome: f is unused.. | |||||
{ | { | ||||
EFI_HTTP_CONFIG_DATA config; | EFI_HTTP_CONFIG_DATA config; | ||||
EFI_HTTPv4_ACCESS_POINT config_access; | EFI_HTTPv4_ACCESS_POINT config_access; | ||||
DNS_DEVICE_PATH *dns; | DNS_DEVICE_PATH *dns; | ||||
EFI_DEVICE_PATH *devpath, *imgpath; | EFI_DEVICE_PATH *devpath, *imgpath; | ||||
EFI_SERVICE_BINDING_PROTOCOL *sb; | EFI_SERVICE_BINDING_PROTOCOL *sb; | ||||
IPv4_DEVICE_PATH *ipv4; | IPv4_DEVICE_PATH *ipv4; | ||||
MAC_ADDR_DEVICE_PATH *mac; | MAC_ADDR_DEVICE_PATH *mac; | ||||
URI_DEVICE_PATH *uri; | URI_DEVICE_PATH *uri; | ||||
struct devdesc *dev; | |||||
struct open_efihttp *oh; | struct open_efihttp *oh; | ||||
char *c; | char *c; | ||||
EFI_HANDLE handle; | EFI_HANDLE handle; | ||||
EFI_STATUS status; | EFI_STATUS status; | ||||
int err, len; | int err, len; | ||||
if (!efihttp_init_done) | if (!efihttp_init_done) | ||||
return (ENXIO); | return (ENXIO); | ||||
Show All 37 Lines | efihttp_dev_open(struct open_file *f, struct devdesc *dev) | ||||
err = setup_ipv4_config2(handle, mac, ipv4, dns); | err = setup_ipv4_config2(handle, mac, ipv4, dns); | ||||
if (err) | if (err) | ||||
return (err); | return (err); | ||||
oh = calloc(1, sizeof(struct open_efihttp)); | oh = calloc(1, sizeof(struct open_efihttp)); | ||||
if (!oh) | if (!oh) | ||||
return (ENOMEM); | return (ENOMEM); | ||||
oh->dev_handle = handle; | oh->dev_handle = handle; | ||||
dev = (struct devdesc *)f->f_devdata; | |||||
dev->d_opendata = oh; | dev->d_opendata = oh; | ||||
status = BS->OpenProtocol(handle, &httpsb_guid, (void **)&sb, IH, NULL, | status = BS->OpenProtocol(handle, &httpsb_guid, (void **)&sb, IH, NULL, | ||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL); | EFI_OPEN_PROTOCOL_GET_PROTOCOL); | ||||
if (EFI_ERROR(status)) { | if (EFI_ERROR(status)) { | ||||
err = efi_status_to_errno(status); | err = efi_status_to_errno(status); | ||||
goto end; | goto end; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 274 Lines • ▼ Show 20 Lines | efihttp_fs_open(const char *path, struct open_file *f) | ||||
if (err != 0) { | if (err != 0) { | ||||
/* | /* | ||||
* Work around a bug in the EFI HTTP implementation which | * Work around a bug in the EFI HTTP implementation which | ||||
* causes a crash if the http instance isn't torn down | * causes a crash if the http instance isn't torn down | ||||
* between requests. | * between requests. | ||||
* See https://bugzilla.tianocore.org/show_bug.cgi?id=1917 | * See https://bugzilla.tianocore.org/show_bug.cgi?id=1917 | ||||
*/ | */ | ||||
efihttp_dev_close(f); | efihttp_dev_close(f); | ||||
efihttp_dev_open(f); | efihttp_dev_open(f, f->f_devdata); | ||||
path_slash = malloc(strlen(path) + 2); | path_slash = malloc(strlen(path) + 2); | ||||
if (path_slash == NULL) | if (path_slash == NULL) | ||||
return (ENOMEM); | return (ENOMEM); | ||||
strcpy(path_slash, path); | strcpy(path_slash, path); | ||||
strcat(path_slash, "/"); | strcat(path_slash, "/"); | ||||
err = _efihttp_fs_open(path_slash, f); | err = _efihttp_fs_open(path_slash, f); | ||||
free(path_slash); | free(path_slash); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 134 Lines • ▼ Show 20 Lines | if (where == SEEK_SET && fh->offset < offset) { | ||||
efihttp_fs_close(f); | efihttp_fs_close(f); | ||||
/* | /* | ||||
* Work around a bug in the EFI HTTP implementation which | * Work around a bug in the EFI HTTP implementation which | ||||
* causes a crash if the http instance isn't torn down | * causes a crash if the http instance isn't torn down | ||||
* between requests. | * between requests. | ||||
* See https://bugzilla.tianocore.org/show_bug.cgi?id=1917 | * See https://bugzilla.tianocore.org/show_bug.cgi?id=1917 | ||||
*/ | */ | ||||
efihttp_dev_close(f); | efihttp_dev_close(f); | ||||
efihttp_dev_open(f); | efihttp_dev_open(f, f->f_devdata); | ||||
err = efihttp_fs_open(path, f); | err = efihttp_fs_open(path, f); | ||||
free(path); | free(path); | ||||
if (err != 0) | if (err != 0) | ||||
return (err); | return (err); | ||||
return efihttp_fs_seek(f, offset, where); | return efihttp_fs_seek(f, offset, where); | ||||
} | } | ||||
return (EIO); | return (EIO); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 55 Lines • Show Last 20 Lines |
f is unused..