[SLOF] [PATCH v2 2/2] usb/storage: Implement block write support
Thomas Huth
thuth at redhat.com
Thu Dec 13 07:14:21 AEDT 2018
On 2018-12-12 15:31, Laurent Vivier wrote:
> The only missing parts were to manage the transfer direction in
> do-bulk-command and to copy the data to the buffer before the
> write operation.
>
> This is needed as GRUB2 wants to write the grubenv file at start
> and hangs because the data are not provided to the disk controller.
>
> I've checked the file is correctly modified by modifying an environment
> variable in GRUB2 with "set saved_entry=2" then "save_env saved_entry"
> and checking the result in linux with "grub2-editenv list".
>
> Fixes: Fixes: a0b96fe66fcd991b407c1d67ca842921e477a6fd
> (Provide "write" function in the disk-label package)
> Signed-off-by: Laurent Vivier <lvivier at redhat.com>
> ---
> slof/fs/usb/dev-storage.fs | 25 +++++++++++++++++++++----
> 1 file changed, 21 insertions(+), 4 deletions(-)
>
> diff --git a/slof/fs/usb/dev-storage.fs b/slof/fs/usb/dev-storage.fs
> index fe5af1c..449659e 100644
> --- a/slof/fs/usb/dev-storage.fs
> +++ b/slof/fs/usb/dev-storage.fs
> @@ -103,7 +103,7 @@ scsi-open
> \ if sense-len is 0 then no sense data is actually present
> \
>
> -: do-bulk-command ( resp-buffer resp-size -- TRUE | FALSE )
> +: do-bulk-command ( dir resp-buffer resp-size -- TRUE | FALSE )
> TO resp-size
> TO resp-buffer
> udev USB_PIPE_OUT td-buf td-buf-phys dma-buf-phys usb>cmd 1F
> @@ -113,13 +113,20 @@ scsi-open
> \ transfer CBW
> resp-size IF
> d# 125 us
> - udev USB_PIPE_IN td-buf td-buf-phys resp-buffer resp-size
> + IF
> + udev USB_PIPE_IN
> + ELSE
> + udev USB_PIPE_OUT
> + THEN
> + td-buf td-buf-phys resp-buffer resp-size
> usb-transfer-bulk 1 = not IF \ transfer data
> usb-disk-debug? IF ." Data phase failed " cr THEN
> \ FALSE EXIT
> \ in case of a stall/halted endpoint we clear the halt
> \ Fall through and try reading the CSW
> THEN
> + ELSE
> + drop
> THEN
> d# 125 us
> udev USB_PIPE_IN td-buf td-buf-phys dma-buf-phys usb>csw 0D
There is another "ELSE FALSE EXIT THEN" at the end of this function. I
think you've got to drop the "dir" stack item in that case, too, don't you?
Thomas
More information about the SLOF
mailing list