Commit 70951fa9 authored by Bernhard Nortmann's avatar Bernhard Nortmann
Browse files

fel: Introduce progress framework



This patch adds two new source files that will deal with code
related to progress callbacks and display. I have decided to
keep this separate, as there will be many smaller routines
involved, which otherwise would bloat fel.c unnecessarily.

For starters, let's also move the gettime() function there.
Signed-off-by: default avatarBernhard Nortmann <bernhard.nortmann@web.de>
Reviewed-by: default avatarSiarhei Siamashka <siarhei.siamashka@gmail.com>
parent c32eeb88
......@@ -83,7 +83,7 @@ LIBUSB = libusb-1.0
LIBUSB_CFLAGS = `pkg-config --cflags $(LIBUSB)`
LIBUSB_LIBS = `pkg-config --libs $(LIBUSB)`
sunxi-fel: fel.c fel-to-spl-thunk.h
sunxi-fel: fel.c fel-to-spl-thunk.h progress.c progress.h
$(CC) $(CFLAGS) $(LIBUSB_CFLAGS) $(LDFLAGS) -o $@ $(filter %.c,$^) $(LIBS) $(LIBUSB_LIBS)
sunxi-nand-part: nand-part-main.c nand-part.c nand-part-a10.h nand-part-a20.h
......
......@@ -32,9 +32,9 @@
#include <stdarg.h>
#include <errno.h>
#include <unistd.h>
#include <sys/time.h>
#include "endian_compat.h"
#include "progress.h"
struct aw_usb_request {
char signature[8];
......@@ -1186,14 +1186,6 @@ static int aw_fel_get_endpoint(libusb_device_handle *usb)
return 0;
}
/* Less reliable than clock_gettime, but does not require linking with -lrt */
static double gettime(void)
{
struct timeval tv;
gettimeofday(&tv, NULL);
return tv.tv_sec + (double)tv.tv_usec / 1000000.;
}
int main(int argc, char **argv)
{
int rc;
......
/*
* Copyright (C) 2015 Bernhard Nortmann <bernhard.nortmann@web.de>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "progress.h"
#include <stdio.h>
#include <sys/time.h>
#include <unistd.h>
#include "common.h"
/* Less reliable than clock_gettime, but does not require linking with -lrt */
inline double gettime(void)
{
struct timeval tv;
gettimeofday(&tv, NULL);
return tv.tv_sec + (double)tv.tv_usec / 1000000.;
}
/* Update progress status, passing information to the callback function. */
void progress_update(size_t UNUSED(bytes_done))
{
/*
* This is a non-functional placeholder!
* It will be replaced in a later patch.
*/
}
/*
* Copyright (C) 2015 Bernhard Nortmann <bernhard.nortmann@web.de>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _SUNXI_TOOLS_PROGRESS_H
#define _SUNXI_TOOLS_PROGRESS_H
#include <stddef.h>
/* function pointer type for a progress callback / notification */
typedef void (*progress_cb_t)(size_t total, size_t done);
/* conversion helper macros */
#define kilo(value) ((double)(value) / 1000.) /* SI prefix "k" */
#define kibi(value) ((double)(value) / 1024.) /* binary prefix "Ki", "K" */
double gettime(void);
void progress_update(size_t bytes_done);
#endif /* _SUNXI_TOOLS_PROGRESS_H */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment