xref: /rk3399_rockchip-uboot/lib/avb/libavb/avb_sysdeps_posix.c (revision 4454e90b43786bac3a0d4c3bfddeafddf794d6c0)
137a7bc39SJason Zhu /*
237a7bc39SJason Zhu  * Copyright (C) 2016 The Android Open Source Project
337a7bc39SJason Zhu  *
437a7bc39SJason Zhu  * Permission is hereby granted, free of charge, to any person
537a7bc39SJason Zhu  * obtaining a copy of this software and associated documentation
637a7bc39SJason Zhu  * files (the "Software"), to deal in the Software without
737a7bc39SJason Zhu  * restriction, including without limitation the rights to use, copy,
837a7bc39SJason Zhu  * modify, merge, publish, distribute, sublicense, and/or sell copies
937a7bc39SJason Zhu  * of the Software, and to permit persons to whom the Software is
1037a7bc39SJason Zhu  * furnished to do so, subject to the following conditions:
1137a7bc39SJason Zhu  *
1237a7bc39SJason Zhu  * The above copyright notice and this permission notice shall be
1337a7bc39SJason Zhu  * included in all copies or substantial portions of the Software.
1437a7bc39SJason Zhu  *
1537a7bc39SJason Zhu  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1637a7bc39SJason Zhu  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1737a7bc39SJason Zhu  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1837a7bc39SJason Zhu  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
1937a7bc39SJason Zhu  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
2037a7bc39SJason Zhu  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
2137a7bc39SJason Zhu  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2237a7bc39SJason Zhu  * SOFTWARE.
2337a7bc39SJason Zhu  */
2437a7bc39SJason Zhu 
25ab608f80SJason Zhu #include <stdio.h>
2637a7bc39SJason Zhu #include <common.h>
2737a7bc39SJason Zhu #include <stdarg.h>
2837a7bc39SJason Zhu #include <stdlib.h>
2937a7bc39SJason Zhu #include <malloc.h>
3037a7bc39SJason Zhu #include <errno.h>
3137a7bc39SJason Zhu #include <asm/io.h>
3237a7bc39SJason Zhu 
3337a7bc39SJason Zhu #include <android_avb/avb_sysdeps.h>
3437a7bc39SJason Zhu 
35ab608f80SJason Zhu void abort(void)
36ab608f80SJason Zhu {
3737a7bc39SJason Zhu 
38ab608f80SJason Zhu }
3937a7bc39SJason Zhu int avb_memcmp(const void* src1, const void* src2, size_t n) {
4037a7bc39SJason Zhu   return memcmp(src1, src2, n);
4137a7bc39SJason Zhu }
4237a7bc39SJason Zhu 
4337a7bc39SJason Zhu void* avb_memcpy(void* dest, const void* src, size_t n) {
4437a7bc39SJason Zhu   return memcpy(dest, src, n);
4537a7bc39SJason Zhu }
4637a7bc39SJason Zhu 
4737a7bc39SJason Zhu void* avb_memset(void* dest, const int c, size_t n) {
4837a7bc39SJason Zhu   return memset(dest, c, n);
4937a7bc39SJason Zhu }
5037a7bc39SJason Zhu 
5137a7bc39SJason Zhu int avb_strcmp(const char* s1, const char* s2) {
5237a7bc39SJason Zhu   return strcmp(s1, s2);
5337a7bc39SJason Zhu }
5437a7bc39SJason Zhu 
5537a7bc39SJason Zhu size_t avb_strlen(const char* str) {
5637a7bc39SJason Zhu   return strlen(str);
5737a7bc39SJason Zhu }
5837a7bc39SJason Zhu 
5937a7bc39SJason Zhu void avb_abort(void) {
6037a7bc39SJason Zhu   abort();
6137a7bc39SJason Zhu }
6237a7bc39SJason Zhu 
6337a7bc39SJason Zhu void avb_print(const char* message) {
64*4454e90bSJason Zhu   printf("%s", message);
6537a7bc39SJason Zhu }
6637a7bc39SJason Zhu 
6737a7bc39SJason Zhu void avb_printv(const char* message, ...) {
6837a7bc39SJason Zhu   va_list ap;
6937a7bc39SJason Zhu   const char* m;
7037a7bc39SJason Zhu 
7137a7bc39SJason Zhu   va_start(ap, message);
7237a7bc39SJason Zhu   for (m = message; m != NULL; m = va_arg(ap, const char*)) {
73*4454e90bSJason Zhu     printf("%s", m);
7437a7bc39SJason Zhu   }
7537a7bc39SJason Zhu   va_end(ap);
7637a7bc39SJason Zhu }
7737a7bc39SJason Zhu 
7837a7bc39SJason Zhu void* avb_malloc_(size_t size) {
7937a7bc39SJason Zhu   return malloc(size);
8037a7bc39SJason Zhu }
8137a7bc39SJason Zhu 
8237a7bc39SJason Zhu void avb_free(void* ptr) {
8337a7bc39SJason Zhu   free(ptr);
8437a7bc39SJason Zhu }
8537a7bc39SJason Zhu 
8637a7bc39SJason Zhu uint32_t avb_div_by_10(uint64_t* dividend) {
8737a7bc39SJason Zhu   uint32_t rem = (uint32_t)(*dividend % 10);
8837a7bc39SJason Zhu   *dividend /= 10;
8937a7bc39SJason Zhu   return rem;
9037a7bc39SJason Zhu }
91