bulk_process.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #include <stdlib.h>
  2. #include <app.h>
  3. #include <debug.h>
  4. #include <arch/arm.h>
  5. #include <dev/udc.h>
  6. #include <string.h>
  7. #include <kernel/thread.h>
  8. #include <kernel/event.h>
  9. #include <arch/ops.h>
  10. #include <target.h>
  11. #include <platform.h>
  12. #include <platform/mt_gpt.h>
  13. #include "bulk_process.h"
  14. #include "transfer.h"
  15. #include "pal_log.h"
  16. #if (defined(MTK_UFS_SUPPORT) || defined(MTK_EMMC_SUPPORT))
  17. extern u64 emmc_write(u32 part_id, u64 offset, void *data, u64 size);
  18. static void write_bulk_internal(bulk_status_t* status);
  19. void init_bulk_process_status(bulk_status_t* status, partition_info_struct_t* partition)
  20. {
  21. status->partition = partition;
  22. status->image_address_offset = 0;
  23. }
  24. void end_write_bulk(bulk_status_t* status)
  25. {
  26. }
  27. static void write_bulk_internal(bulk_status_t* status)
  28. {
  29. if (emmc_write(status->partition->part_id, status->partition->base_addr+status->image_address_offset , status->buf, status->byte_to_process) != status->byte_to_process)
  30. {
  31. status->handle_status = STATUS_EMMC_ERR;
  32. }
  33. if (status->handle_status != STATUS_OK)
  34. {
  35. pal_log_err("[BULK] S_STORAGE_WRITE_FAILED:%d, status=%d, size=%d\n",__LINE__, status->handle_status, status->byte_to_process);
  36. return;
  37. }
  38. status->image_address_offset += status->byte_to_process;
  39. status->byte_to_process = 0;
  40. return ;
  41. }
  42. void write_bulk_data(bulk_status_t* status, uint8* data, uint32 length)
  43. {
  44. status->buf = data;
  45. status->byte_to_process = length;
  46. do
  47. {
  48. write_bulk_internal(status);
  49. if (status->handle_status != STATUS_OK)
  50. {
  51. return;
  52. }
  53. } while (status->byte_to_process > 0);
  54. return;
  55. }
  56. #endif