1 /* 2 * Copyright (c) 2015 Travis Geiselbrecht 3 * 4 * Use of this source code is governed by a MIT-style 5 * license that can be found in the LICENSE file or at 6 * https://opensource.org/licenses/MIT 7 */ 8 9 #if WITH_LIB_MINIP 10 #include <app.h> 11 12 #include <platform.h> 13 #include <stdio.h> 14 #include <lk/debug.h> 15 #include <string.h> 16 #include <lk/pow2.h> 17 #include <lk/err.h> 18 #include <assert.h> 19 #include <lk/trace.h> 20 21 #include <app/lkboot.h> 22 23 #include "lkboot.h" 24 25 #include <lib/minip.h> 26 27 #define LOCAL_TRACE 0 28 tcp_readx(void * s,void * _data,size_t len)29static ssize_t tcp_readx(void *s, void *_data, size_t len) { 30 char *data = _data; 31 while (len > 0) { 32 int r = tcp_read(s, data, len); 33 if (r <= 0) return -1; 34 data += r; 35 len -= r; 36 } 37 return 0; 38 } 39 lkboot_tcp_opened(void * s)40lkb_t *lkboot_tcp_opened(void *s) { 41 lkb_t *lkb; 42 43 lkb = lkboot_create_lkb(s, tcp_readx, (void *)tcp_write); 44 if (!lkb) 45 return NULL; 46 47 return lkb; 48 } 49 50 #endif 51