[warnings] add -Wshadow which helps detect local variables that override globals
Nothing particularly bad showed up but cleaned up a bit of code.
This commit is contained in:
@@ -129,13 +129,11 @@ static int do_boot(lkb_t *lkb, size_t len, const char **result) {
|
||||
/* sniff it to see if it's a bootimage or a raw image */
|
||||
bootimage_t *bi;
|
||||
if (bootimage_open(buf, len, &bi) >= 0) {
|
||||
size_t len;
|
||||
|
||||
/* it's a bootimage */
|
||||
TRACEF("detected bootimage\n");
|
||||
|
||||
/* find the lk image */
|
||||
if (bootimage_get_file_section(bi, TYPE_LK, &ptr, &len) >= 0) {
|
||||
if (bootimage_get_file_section(bi, TYPE_LK, &ptr, NULL) >= 0) {
|
||||
TRACEF("found lk section at %p\n", ptr);
|
||||
|
||||
/* add the boot image to the argument list */
|
||||
@@ -378,9 +376,9 @@ int lkb_handle_command(lkb_t *lkb, const char *cmd, const char *arg, size_t len,
|
||||
return do_boot(lkb, len, result);
|
||||
} else if (!strcmp(cmd, "getsysparam")) {
|
||||
const void *ptr;
|
||||
size_t len;
|
||||
if (sysparam_get_ptr(arg, &ptr, &len) == 0) {
|
||||
lkb_write(lkb, ptr, len);
|
||||
size_t len_local;
|
||||
if (sysparam_get_ptr(arg, &ptr, &len_local) == 0) {
|
||||
lkb_write(lkb, ptr, len_local);
|
||||
}
|
||||
} else if (!strcmp(cmd, "reboot")) {
|
||||
thread_resume(thread_create("reboot", &do_reboot, NULL,
|
||||
|
||||
@@ -23,8 +23,8 @@ static uint8_t *dst2;
|
||||
#define ITERATIONS (256*1024*1024 / BUFFER_SIZE) // enough iterations to have to copy/set 256MB of memory
|
||||
|
||||
#if 1
|
||||
static inline void *mymemcpy(void *dst, const void *src, size_t len) { return memcpy(dst, src, len); }
|
||||
static inline void *mymemset(void *dst, int c, size_t len) { return memset(dst, c, len); }
|
||||
static inline void *mymemcpy(void *dest, const void *source, size_t len) { return memcpy(dest, source, len); }
|
||||
static inline void *mymemset(void *dest, int c, size_t len) { return memset(dest, c, len); }
|
||||
#else
|
||||
// if we're testing our own memcpy, use this
|
||||
extern void *mymemcpy(void *dst, const void *src, size_t len);
|
||||
@@ -37,17 +37,17 @@ typedef long word;
|
||||
#define lsize sizeof(word)
|
||||
#define lmask (lsize - 1)
|
||||
|
||||
static void *c_memmove(void *dest, void const *src, size_t count) {
|
||||
static void *c_memmove(void *dest, void const *source, size_t count) {
|
||||
char *d = (char *)dest;
|
||||
const char *s = (const char *)src;
|
||||
const char *s = (const char *)source;
|
||||
int len;
|
||||
|
||||
if (count == 0 || dest == src)
|
||||
if (count == 0 || dest == source)
|
||||
return dest;
|
||||
|
||||
if ((long)d < (long)s) {
|
||||
if (((long)d | (long)s) & lmask) {
|
||||
// src and/or dest do not align on word boundary
|
||||
// source and/or dest do not align on word boundary
|
||||
if ((((long)d ^ (long)s) & lmask) || (count < lsize))
|
||||
len = count; // copy the rest of the buffer with the byte mover
|
||||
else
|
||||
@@ -122,8 +122,8 @@ static void *c_memset(void *s, int c, size_t count) {
|
||||
return s;
|
||||
}
|
||||
|
||||
static void *null_memcpy(void *dst, const void *src, size_t len) {
|
||||
return dst;
|
||||
static void *null_memcpy(void *dest, const void *source, size_t len) {
|
||||
return dest;
|
||||
}
|
||||
|
||||
static lk_time_t bench_memcpy_routine(void *memcpy_routine(void *, const void *, size_t), size_t srcalign, size_t dstalign) {
|
||||
|
||||
@@ -294,7 +294,7 @@ int two_threads_basic(void) {
|
||||
// wait for the pong port to be created, the two threads race to do it.
|
||||
port_t r_port;
|
||||
while (true) {
|
||||
status_t st = port_open("pong_port", NULL, &r_port);
|
||||
st = port_open("pong_port", NULL, &r_port);
|
||||
if (st == NO_ERROR) {
|
||||
break;
|
||||
} else if (st == ERR_NOT_FOUND) {
|
||||
@@ -402,8 +402,8 @@ typedef struct {
|
||||
} watcher_cmd;
|
||||
|
||||
status_t send_watcher_cmd(port_t cmd_port, action_t action, port_t port) {
|
||||
watcher_cmd cmd = {action, port};
|
||||
return port_write(cmd_port, ((port_packet_t *) &cmd), 1);;
|
||||
watcher_cmd _cmd = {action, port};
|
||||
return port_write(cmd_port, ((port_packet_t *) &_cmd), 1);;
|
||||
}
|
||||
|
||||
static int group_watcher_thread(void *arg) {
|
||||
|
||||
@@ -101,7 +101,7 @@ static void zynq_common_target_init(uint level) {
|
||||
/* we were loaded from spi flash, go look at it to see if we can find it */
|
||||
if (spi) {
|
||||
void *ptr = 0;
|
||||
int err = bio_ioctl(spi, BIO_IOCTL_GET_MEM_MAP, (void *)&ptr);
|
||||
err = bio_ioctl(spi, BIO_IOCTL_GET_MEM_MAP, (void *)&ptr);
|
||||
if (err >= 0) {
|
||||
put_bio_memmap = true;
|
||||
ptr = (uint8_t *)ptr + bootimage_phys;
|
||||
|
||||
@@ -155,7 +155,7 @@ void arm_cm_irq_exit(bool reschedule) {
|
||||
void arch_chain_load(void *entry, ulong arg0, ulong arg1, ulong arg2, ulong arg3) {
|
||||
#if (__CORTEX_M >= 0x03)
|
||||
|
||||
uint32_t *vectab = (uint32_t *)entry;
|
||||
uint32_t *entry_vector = (uint32_t *)entry;
|
||||
|
||||
__asm__ volatile(
|
||||
"mov r0, %[arg0]; "
|
||||
@@ -169,8 +169,8 @@ void arch_chain_load(void *entry, ulong arg0, ulong arg1, ulong arg2, ulong arg3
|
||||
[arg1]"r"(arg1),
|
||||
[arg2]"r"(arg2),
|
||||
[arg3]"r"(arg3),
|
||||
[SP]"r"(vectab[0]),
|
||||
[entry]"r"(vectab[1])
|
||||
[SP]"r"(entry_vector[0]),
|
||||
[entry]"r"(entry_vector[1])
|
||||
: "r0", "r1", "r2", "r3"
|
||||
);
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
#define LOCAL_TRACE 0
|
||||
|
||||
static volatile uint64_t ticks;
|
||||
static volatile uint64_t current_ticks;
|
||||
static uint32_t tick_rate = 0;
|
||||
static uint32_t tick_rate_mhz = 0;
|
||||
static lk_time_t tick_interval_ms;
|
||||
@@ -52,7 +52,7 @@ static void arm_cm_systick_cancel_periodic(void) {
|
||||
|
||||
/* main systick irq handler */
|
||||
void _systick(void) {
|
||||
ticks++;
|
||||
current_ticks++;
|
||||
|
||||
arm_cm_irq_entry();
|
||||
|
||||
@@ -87,10 +87,10 @@ lk_time_t current_time(void) {
|
||||
uint64_t t;
|
||||
uint32_t delta;
|
||||
do {
|
||||
t = ticks;
|
||||
t = current_ticks;
|
||||
delta = (volatile uint32_t)SysTick->VAL;
|
||||
DMB;
|
||||
} while (ticks != t);
|
||||
} while (current_ticks != t);
|
||||
|
||||
/* convert ticks to msec */
|
||||
delta = (reload - delta) / (tick_rate_mhz * 1000);
|
||||
@@ -105,10 +105,10 @@ lk_bigtime_t current_time_hires(void) {
|
||||
uint64_t t;
|
||||
uint32_t delta;
|
||||
do {
|
||||
t = ticks;
|
||||
t = current_ticks;
|
||||
delta = (volatile uint32_t)SysTick->VAL;
|
||||
DMB;
|
||||
} while (ticks != t);
|
||||
} while (current_ticks != t);
|
||||
|
||||
/* convert ticks to usec */
|
||||
delta = (reload - delta) / tick_rate_mhz;
|
||||
|
||||
@@ -43,8 +43,7 @@ enum sbi_return_code {
|
||||
: "+r" (a0), "+r" (a1) \
|
||||
: "r" (a2), "r" (a3), "r" (a4), "r" (a5), "r"(a6), "r"(a7) \
|
||||
: "memory"); \
|
||||
struct sbiret ret = { .error = a0, .value = a1 }; \
|
||||
ret; \
|
||||
(struct sbiret){ .error = a0, .value = a1 }; \
|
||||
})
|
||||
#define sbi_call(...) \
|
||||
_sbi_call(__VA_ARGS__, 0, 0, 0, 0, 0, 0, 0)
|
||||
|
||||
@@ -27,13 +27,13 @@
|
||||
|
||||
/* top level kernel page tables, initialized in start.S */
|
||||
#ifdef PAE_MODE_ENABLED
|
||||
map_addr_t pdp[NO_OF_PT_ENTRIES] __ALIGNED(PAGE_SIZE);
|
||||
map_addr_t pdpt[NO_OF_PT_ENTRIES] __ALIGNED(PAGE_SIZE);
|
||||
map_addr_t kernel_pdp[NO_OF_PT_ENTRIES] __ALIGNED(PAGE_SIZE);
|
||||
map_addr_t kernel_pdpt[NO_OF_PT_ENTRIES] __ALIGNED(PAGE_SIZE);
|
||||
#elif X86_LEGACY
|
||||
/* enough page tables to map 16MB ram */
|
||||
map_addr_t pt[NO_OF_PT_ENTRIES][4] __ALIGNED(PAGE_SIZE);
|
||||
map_addr_t kernel_pt[NO_OF_PT_ENTRIES][4] __ALIGNED(PAGE_SIZE);
|
||||
#endif
|
||||
map_addr_t pd[NO_OF_PT_ENTRIES] __ALIGNED(PAGE_SIZE);
|
||||
map_addr_t kernel_pd[NO_OF_PT_ENTRIES] __ALIGNED(PAGE_SIZE);
|
||||
|
||||
#ifdef PAE_MODE_ENABLED
|
||||
/* PDP table address is 32 bit wide when on PAE mode, but the PDP entries are 64 bit wide */
|
||||
@@ -596,7 +596,7 @@ void x86_mmu_early_init(void) {
|
||||
|
||||
/* unmap the lower identity mapping */
|
||||
for (uint i = 0; i < (1024*1024*1024) / (4*1024*1024); i++) {
|
||||
pd[i] = 0;
|
||||
kernel_pd[i] = 0;
|
||||
}
|
||||
|
||||
/* tlb flush */
|
||||
|
||||
@@ -139,7 +139,7 @@ fill_pdp:
|
||||
/* map the first 16MB 1:1 with 4KB pages and again at 0x8000.0000 */
|
||||
|
||||
/* set up 4 page tables worth of entries */
|
||||
movl $PHYS(pt), %edi
|
||||
movl $PHYS(kernel_pt), %edi
|
||||
movl $1024*4,%ecx
|
||||
movl $X86_KERNEL_PT_FLAGS, %eax
|
||||
|
||||
@@ -152,9 +152,9 @@ fill_pdp:
|
||||
/* set up the page dir with 4 entries at 0 and 0x8000.0000 pointing
|
||||
* to 4 page tables that will map physical address 0 - 16MB
|
||||
*/
|
||||
movl $PHYS(pd), %esi
|
||||
movl $PHYS(pd) + 512*4, %edi
|
||||
movl $PHYS(pt) + X86_KERNEL_PT_FLAGS, %eax
|
||||
movl $PHYS(kernel_pd), %esi
|
||||
movl $PHYS(kernel_pd) + 512*4, %edi
|
||||
movl $PHYS(kernel_pt) + X86_KERNEL_PT_FLAGS, %eax
|
||||
movl %eax, (%esi)
|
||||
movl %eax, (%edi)
|
||||
addl $4096, %eax
|
||||
@@ -168,7 +168,7 @@ fill_pdp:
|
||||
movl %eax, 12(%edi)
|
||||
|
||||
/* Set PD in CR3 */
|
||||
movl $PHYS(pd), %eax
|
||||
movl $PHYS(kernel_pd), %eax
|
||||
mov %eax, %cr3
|
||||
|
||||
/* Enabling Paging and from this point we are in */
|
||||
@@ -177,7 +177,7 @@ fill_pdp:
|
||||
mov %eax, %cr0
|
||||
#else
|
||||
/* map the first 1GB 1:1 using 4MB pages */
|
||||
movl $PHYS(pd), %esi
|
||||
movl $PHYS(kernel_pd), %esi
|
||||
movl $0x100, %ecx
|
||||
xor %eax, %eax
|
||||
|
||||
@@ -190,7 +190,7 @@ fill_pdp:
|
||||
loop .Lfill_pd
|
||||
|
||||
/* map the first 1GB to KERNEL_ASPACE_BASE */
|
||||
movl $(PHYS(pd) + 0x800), %esi
|
||||
movl $(PHYS(kernel_pd) + 0x800), %esi
|
||||
movl $0x100, %ecx
|
||||
xor %eax, %eax
|
||||
|
||||
@@ -203,7 +203,7 @@ fill_pdp:
|
||||
loop .Lfill_pd2
|
||||
|
||||
/* Set PD in CR3 */
|
||||
movl $PHYS(pd), %eax
|
||||
movl $PHYS(kernel_pd), %eax
|
||||
mov %eax, %cr3
|
||||
|
||||
/* Enabling Paging and from this point we are in */
|
||||
|
||||
@@ -29,15 +29,15 @@ uint8_t g_vaddr_width = 0;
|
||||
uint8_t g_paddr_width = 0;
|
||||
|
||||
/* top level kernel page tables, initialized in start.S */
|
||||
map_addr_t pml4[NO_OF_PT_ENTRIES] __ALIGNED(PAGE_SIZE);
|
||||
map_addr_t pdp[NO_OF_PT_ENTRIES] __ALIGNED(PAGE_SIZE); /* temporary */
|
||||
map_addr_t pte[NO_OF_PT_ENTRIES] __ALIGNED(PAGE_SIZE);
|
||||
map_addr_t kernel_pml4[NO_OF_PT_ENTRIES] __ALIGNED(PAGE_SIZE);
|
||||
map_addr_t kernel_pdp[NO_OF_PT_ENTRIES] __ALIGNED(PAGE_SIZE); /* temporary */
|
||||
map_addr_t kernel_pte[NO_OF_PT_ENTRIES] __ALIGNED(PAGE_SIZE);
|
||||
|
||||
/* top level pdp needed to map the -512GB..0 space */
|
||||
map_addr_t pdp_high[NO_OF_PT_ENTRIES] __ALIGNED(PAGE_SIZE);
|
||||
map_addr_t kernel_pdp_high[NO_OF_PT_ENTRIES] __ALIGNED(PAGE_SIZE);
|
||||
|
||||
/* a big pile of page tables needed to map 64GB of memory into kernel space using 2MB pages */
|
||||
map_addr_t linear_map_pdp[(64ULL*GB) / (2*MB)];
|
||||
map_addr_t kernel_linear_map_pdp[(64ULL*GB) / (2*MB)];
|
||||
|
||||
/**
|
||||
* @brief check if the virtual address is aligned and canonical
|
||||
@@ -707,7 +707,7 @@ void x86_mmu_early_init(void) {
|
||||
LTRACEF("paddr_width %u vaddr_width %u\n", g_paddr_width, g_vaddr_width);
|
||||
|
||||
/* unmap the lower identity mapping */
|
||||
pml4[0] = 0;
|
||||
kernel_pml4[0] = 0;
|
||||
|
||||
/* tlb flush */
|
||||
x86_set_cr3(x86_get_cr3());
|
||||
|
||||
@@ -110,7 +110,7 @@ paging_setup:
|
||||
mov %eax, %cr4
|
||||
|
||||
/* load the physical pointer to the top level page table */
|
||||
movl $PHYS(pml4), %eax
|
||||
movl $PHYS(kernel_pml4), %eax
|
||||
mov %eax, %cr3
|
||||
|
||||
/* Long Mode Enabled at this point*/
|
||||
@@ -120,27 +120,27 @@ paging_setup:
|
||||
wrmsr
|
||||
|
||||
/* Setting the First PML4E with a PDP table reference*/
|
||||
movl $PHYS(pdp), %eax
|
||||
movl $PHYS(kernel_pdp), %eax
|
||||
orl $X86_KERNEL_PD_FLAGS, %eax
|
||||
movl %eax, PHYS(pml4)
|
||||
movl %eax, PHYS(kernel_pml4)
|
||||
|
||||
/* Setting the First PDPTE with a Page table reference*/
|
||||
movl $PHYS(pte), %eax
|
||||
movl $PHYS(kernel_pte), %eax
|
||||
orl $X86_KERNEL_PD_FLAGS, %eax
|
||||
movl %eax, PHYS(pdp)
|
||||
movl %eax, PHYS(kernel_pdp)
|
||||
|
||||
/* point the pml4e at the second high PDP (for -2GB mapping) */
|
||||
movl $PHYS(pdp_high), %eax
|
||||
movl $PHYS(kernel_pdp_high), %eax
|
||||
orl $X86_KERNEL_PD_FLAGS, %eax
|
||||
movl %eax, PHYS(pml4 + 8*511)
|
||||
movl %eax, PHYS(kernel_pml4 + 8*511)
|
||||
|
||||
/* point the second pdp at the same low level page table */
|
||||
movl $PHYS(pte), %eax
|
||||
movl $PHYS(kernel_pte), %eax
|
||||
orl $X86_KERNEL_PD_FLAGS, %eax
|
||||
movl %eax, PHYS(pdp_high + 8*510)
|
||||
movl %eax, PHYS(kernel_pdp_high + 8*510)
|
||||
|
||||
/* map the first 1GB in this table */
|
||||
movl $PHYS(pte), %esi
|
||||
movl $PHYS(kernel_pte), %esi
|
||||
movl $0x200, %ecx
|
||||
xor %eax, %eax
|
||||
|
||||
@@ -154,7 +154,7 @@ paging_setup:
|
||||
loop 0b
|
||||
|
||||
/* set up a linear map of the first 64GB at 0xffffff8000000000 */
|
||||
movl $PHYS(linear_map_pdp), %esi
|
||||
movl $PHYS(kernel_linear_map_pdp), %esi
|
||||
movl $32768, %ecx
|
||||
xor %eax, %eax
|
||||
|
||||
@@ -172,9 +172,9 @@ paging_setup:
|
||||
loop 0b
|
||||
|
||||
/* point the high pdp at our linear mapping page tables */
|
||||
movl $PHYS(pdp_high), %esi
|
||||
movl $PHYS(kernel_pdp_high), %esi
|
||||
movl $64, %ecx
|
||||
movl $PHYS(linear_map_pdp), %eax
|
||||
movl $PHYS(kernel_linear_map_pdp), %eax
|
||||
orl $X86_KERNEL_PD_FLAGS, %eax
|
||||
|
||||
0:
|
||||
|
||||
@@ -56,7 +56,8 @@ CONFIGHEADER := $(BUILDDIR)/config.h
|
||||
GLOBAL_INCLUDES := $(BUILDDIR) $(addsuffix /include,$(LKINC))
|
||||
GLOBAL_OPTFLAGS ?= $(ARCH_OPTFLAGS)
|
||||
GLOBAL_COMPILEFLAGS := -g -include $(CONFIGHEADER)
|
||||
GLOBAL_COMPILEFLAGS += -W -Wall -Wno-multichar -Wno-unused-parameter -Wno-unused-function -Wno-unused-label -Werror=return-type -Wno-nonnull-compare
|
||||
GLOBAL_COMPILEFLAGS += -W -Wall -Werror=return-type -Wshadow
|
||||
GLOBAL_COMPILEFLAGS += -Wno-multichar -Wno-unused-parameter -Wno-unused-function -Wno-unused-label -Wno-nonnull-compare
|
||||
GLOBAL_COMPILEFLAGS += -fno-common
|
||||
GLOBAL_CFLAGS := --std=gnu11 -Werror-implicit-function-declaration -Wstrict-prototypes -Wwrite-strings
|
||||
GLOBAL_CPPFLAGS := --std=c++11 -fno-exceptions -fno-rtti -fno-threadsafe-statics
|
||||
|
||||
@@ -498,11 +498,11 @@ typedef struct {
|
||||
* @{
|
||||
*/
|
||||
#define __HAL_RCC_SYSCFG_CLK_ENABLE() do { \
|
||||
__IO uint32_t tmpreg; \
|
||||
__IO uint32_t __tmpreg; \
|
||||
SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SYSCFGEN);\
|
||||
/* Delay after an RCC peripheral clock enabling */ \
|
||||
tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SYSCFGEN);\
|
||||
UNUSED(tmpreg); \
|
||||
__tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SYSCFGEN);\
|
||||
UNUSED(__tmpreg); \
|
||||
} while(0)
|
||||
|
||||
#define __HAL_RCC_SYSCFG_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_SYSCFGEN))
|
||||
|
||||
@@ -71,7 +71,7 @@ MODULE_SRCS += \
|
||||
|
||||
include $(LOCAL_DIR)/CMSIS/rules.mk
|
||||
|
||||
MODULE_COMPILEFLAGS += -Wno-error
|
||||
MODULE_COMPILEFLAGS += -Wno-error -Wno-shadow
|
||||
|
||||
include make/module.mk
|
||||
|
||||
|
||||
@@ -122,18 +122,18 @@ usage:
|
||||
ssize_t err = 0;
|
||||
while (len > 0) {
|
||||
size_t amt = MIN(256, len);
|
||||
ssize_t err = bio_read(dev, buf, offset, amt);
|
||||
ssize_t err_len = bio_read(dev, buf, offset, amt);
|
||||
|
||||
if (err < 0) {
|
||||
dprintf(ALWAYS, "read error %s %zu@%zu (err %d)\n",
|
||||
argv[2].str, amt, (size_t)offset, (int)err);
|
||||
if (err_len < 0) {
|
||||
dprintf(ALWAYS, "read error %s %zu@%zu (err_len %ld)\n",
|
||||
argv[2].str, amt, (size_t)offset, err_len);
|
||||
break;
|
||||
}
|
||||
|
||||
DEBUG_ASSERT((size_t)err <= amt);
|
||||
hexdump8_ex(buf, err, offset);
|
||||
DEBUG_ASSERT((size_t)err_len <= amt);
|
||||
hexdump8_ex(buf, err_len, offset);
|
||||
|
||||
if ((size_t)err != amt) {
|
||||
if ((size_t)err_len != amt) {
|
||||
dprintf(ALWAYS, "short read from %s @%zu (wanted %zu, got %zu)\n",
|
||||
argv[2].str, (size_t)offset, amt, (size_t)err);
|
||||
break;
|
||||
|
||||
@@ -113,7 +113,7 @@ static status_t validate_bootimage(bootimage_t *bi) {
|
||||
|
||||
LTRACEF("\tvalidating SHA256 hash\n");
|
||||
SHA256_update(&ctx, (const uint8_t *)bi->ptr + be[i].file.offset, be[i].file.length);
|
||||
const uint8_t *hash = SHA256_final(&ctx);
|
||||
hash = SHA256_final(&ctx);
|
||||
|
||||
if (memcmp(hash, be[i].file.sha256, sizeof(be[i].file.sha256)) != 0) {
|
||||
LTRACEF("bad hash of file section\n");
|
||||
|
||||
@@ -554,7 +554,7 @@ usage:
|
||||
|
||||
iovec_t vec[2];
|
||||
memset(vec, 0x99, sizeof(vec));
|
||||
int err = klog_get_buffer(buffer, vec);
|
||||
err = klog_get_buffer(buffer, vec);
|
||||
printf("klog_get_buffer returns %d\n", err);
|
||||
printf("vec %d: base %p, len %zu\n", 0, vec[0].iov_base, vec[0].iov_len);
|
||||
printf("vec %d: base %p, len %zu\n", 1, vec[1].iov_base, vec[1].iov_len);
|
||||
|
||||
@@ -32,7 +32,7 @@ _Unwind_Reason_Code __aeabi_unwind_cpp_pr2(_Unwind_State state, _Unwind_Control_
|
||||
void raise(void) {
|
||||
}
|
||||
|
||||
int __cxa_atexit(void (*destructor)(void *), void *arg, void *__dso_handle) {
|
||||
int __cxa_atexit(void (*destructor)(void *), void *arg, void *dso_handle) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -194,11 +194,11 @@ __NO_INLINE static size_t exponent_to_string(char *buf, int32_t exponent) {
|
||||
|
||||
__NO_INLINE static char *double_to_string(char *buf, size_t len, double d, uint flag) {
|
||||
size_t pos = 0;
|
||||
union double_int u = { d };
|
||||
union double_int du = { d };
|
||||
|
||||
uint32_t exponent = (u.i >> 52) & 0x7ff;
|
||||
uint64_t fraction = (u.i & ((1ULL << 52) - 1));
|
||||
bool neg = !!(u.i & (1ULL << 63));
|
||||
uint32_t exponent = (du.i >> 52) & 0x7ff;
|
||||
uint64_t fraction = (du.i & ((1ULL << 52) - 1));
|
||||
bool neg = !!(du.i & (1ULL << 63));
|
||||
|
||||
/* start constructing the string */
|
||||
if (neg) {
|
||||
|
||||
@@ -41,14 +41,12 @@ void arp_usage(void) {
|
||||
}
|
||||
|
||||
static int cmd_arp(int argc, const console_cmd_args *argv) {
|
||||
const char *cmd;
|
||||
|
||||
if (argc == 1) {
|
||||
arp_usage();
|
||||
return -1;
|
||||
}
|
||||
|
||||
cmd = argv[1].str;
|
||||
const char *cmd = argv[1].str;
|
||||
if (argc == 2 && strncmp(cmd, "list", sizeof("list")) == 0) {
|
||||
arp_cache_dump();
|
||||
} else if (argc == 3 && strncmp(cmd, "query", sizeof("query")) == 0) {
|
||||
|
||||
@@ -1178,8 +1178,6 @@ out:
|
||||
|
||||
/* debug stuff */
|
||||
static int cmd_tcp(int argc, const console_cmd_args *argv) {
|
||||
status_t err;
|
||||
|
||||
if (argc < 2) {
|
||||
notenoughargs:
|
||||
printf("ERROR not enough arguments\n");
|
||||
@@ -1205,7 +1203,7 @@ usage:
|
||||
|
||||
tcp_socket_t *handle;
|
||||
|
||||
err = tcp_open_listen(&handle, argv[2].u);
|
||||
status_t err = tcp_open_listen(&handle, argv[2].u);
|
||||
printf("tcp_open_listen returns %d, handle %p\n", err, handle);
|
||||
|
||||
tcp_socket_t *accepted;
|
||||
@@ -1222,7 +1220,7 @@ usage:
|
||||
|
||||
tcp_socket_t *handle;
|
||||
|
||||
err = tcp_open_listen(&handle, argv[2].u);
|
||||
status_t err = tcp_open_listen(&handle, argv[2].u);
|
||||
printf("tcp_open_listen returns %d, handle %p\n", err, handle);
|
||||
|
||||
tcp_socket_t *accepted;
|
||||
@@ -1232,17 +1230,17 @@ usage:
|
||||
for (;;) {
|
||||
uint8_t buf[512];
|
||||
|
||||
ssize_t err = tcp_read(accepted, buf, sizeof(buf));
|
||||
printf("tcp_read returns %ld\n", err);
|
||||
if (err < 0)
|
||||
ssize_t err_len = tcp_read(accepted, buf, sizeof(buf));
|
||||
printf("tcp_read returns %ld\n", err_len);
|
||||
if (err_len < 0)
|
||||
break;
|
||||
if (err > 0) {
|
||||
hexdump8(buf, err);
|
||||
if (err_len > 0) {
|
||||
hexdump8(buf, err_len);
|
||||
}
|
||||
|
||||
err = tcp_write(accepted, buf, err);
|
||||
printf("tcp_write returns %ld\n", err);
|
||||
if (err < 0)
|
||||
err_len = tcp_write(accepted, buf, err_len);
|
||||
printf("tcp_write returns %ld\n", err_len);
|
||||
if (err_len < 0)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ static status_t ptable_write(void) {
|
||||
/* This is a subdevice, it should have a homogeneous erase geometry */
|
||||
DEBUG_ASSERT(1 == bdev->geometry_count);
|
||||
|
||||
ssize_t err = bio_erase(bdev, 0, bdev->total_size);
|
||||
err = bio_erase(bdev, 0, bdev->total_size);
|
||||
if (err != (ssize_t)bdev->total_size) {
|
||||
LTRACEF("error %d erasing device\n", (int)err);
|
||||
BAIL(ERR_IO);
|
||||
@@ -836,11 +836,11 @@ usage:
|
||||
status_t err;
|
||||
if (!strcmp(argv[1].str, "scan")) {
|
||||
if (argc < 4) goto notenoughargs;
|
||||
status_t err = ptable_scan(argv[2].str, argv[3].u);
|
||||
err = ptable_scan(argv[2].str, argv[3].u);
|
||||
printf("ptable_scan returns %d\n", err);
|
||||
} else if (!strcmp(argv[1].str, "default")) {
|
||||
if (argc < 4) goto notenoughargs;
|
||||
status_t err = ptable_create_default(argv[2].str, argv[3].u);
|
||||
err = ptable_create_default(argv[2].str, argv[3].u);
|
||||
printf("ptable_create_default returns %d\n", err);
|
||||
} else if (!strcmp(argv[1].str, "list")) {
|
||||
ptable_dump();
|
||||
@@ -848,7 +848,6 @@ usage:
|
||||
bdev_t *ptable_dev = bio_open(PTABLE_PART_NAME);
|
||||
|
||||
if (ptable_dev) {
|
||||
status_t err;
|
||||
err = bio_erase(ptable_dev, 0, ptable_dev->total_size);
|
||||
if (err < 0) {
|
||||
printf("ptable nuke failed (err %d)\n", err);
|
||||
|
||||
@@ -614,8 +614,8 @@ usage:
|
||||
} else if (!strcmp(argv[1].str, "write")) {
|
||||
err = sysparam_write();
|
||||
} else if (!strcmp(argv[1].str, "nuke")) {
|
||||
ssize_t err = bio_erase(params.bdev, params.offset, params.len);
|
||||
printf("erase returns %d\n", (int)err);
|
||||
ssize_t err_len = bio_erase(params.bdev, params.offset, params.len);
|
||||
printf("erase returns %ld\n", err_len);
|
||||
#endif // SYSPARAM_ALLOW_WRITE
|
||||
} else if (!strcmp(argv[1].str, "length")) {
|
||||
if (argc < 3) goto notenoughargs;
|
||||
|
||||
@@ -14,8 +14,6 @@
|
||||
#include <lib/bio.h>
|
||||
#include <lk/reg.h>
|
||||
|
||||
static bdev_t dev;
|
||||
|
||||
static uint64_t get_blkdev_len(void) {
|
||||
return *REG64(BDEV_LEN);
|
||||
}
|
||||
@@ -51,6 +49,8 @@ ssize_t write_block(struct bdev *dev, const void *buf, bnum_t block, uint count)
|
||||
}
|
||||
|
||||
void platform_init_blkdev(void) {
|
||||
static bdev_t dev;
|
||||
|
||||
if ((*REG32(SYSINFO_FEATURES) & SYSINFO_FEATURE_BLOCKDEV) == 0)
|
||||
return; // no block device
|
||||
|
||||
|
||||
@@ -77,12 +77,12 @@ static status_t mailbox_read(enum mailbox_channel ch, uint32_t *result) {
|
||||
}
|
||||
|
||||
|
||||
static status_t mailbox_get_framebuffer(fb_mbox_t *fb_desc) {
|
||||
static status_t mailbox_get_framebuffer(fb_mbox_t *fb) {
|
||||
status_t ret = NO_ERROR;
|
||||
|
||||
arch_clean_cache_range((addr_t)fb_desc,sizeof(fb_mbox_t));
|
||||
arch_clean_cache_range((addr_t)fb,sizeof(fb_mbox_t));
|
||||
|
||||
ret = mailbox_write(ch_framebuffer, kvaddr_to_vc_bus((addr_t)fb_desc));
|
||||
ret = mailbox_write(ch_framebuffer, kvaddr_to_vc_bus((addr_t)fb));
|
||||
if (ret != NO_ERROR)
|
||||
return ret;
|
||||
|
||||
@@ -91,7 +91,7 @@ static status_t mailbox_get_framebuffer(fb_mbox_t *fb_desc) {
|
||||
if (ret != NO_ERROR)
|
||||
return ret;
|
||||
|
||||
arch_invalidate_cache_range((addr_t)fb_desc,sizeof(fb_mbox_t));
|
||||
arch_invalidate_cache_range((addr_t)fb,sizeof(fb_mbox_t));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
|
||||
static volatile uint64_t ticks;
|
||||
static volatile uint64_t current_ticks;
|
||||
static uint32_t tick_rate = 0;
|
||||
static uint32_t tick_rate_mhz = 0;
|
||||
static lk_time_t tick_interval_ms;
|
||||
@@ -52,8 +52,8 @@ lk_time_t current_time(void) {
|
||||
uint64_t t;
|
||||
|
||||
do {
|
||||
t = ticks;
|
||||
} while (ticks != t);
|
||||
t = current_ticks;
|
||||
} while (current_ticks != t);
|
||||
|
||||
return t * tick_interval_ms;
|
||||
}
|
||||
@@ -63,7 +63,7 @@ lk_bigtime_t current_time_hires(void) {
|
||||
}
|
||||
|
||||
void nrf51_RTC1_IRQ(void) {
|
||||
ticks++;
|
||||
current_ticks++;
|
||||
arm_cm_irq_entry();
|
||||
|
||||
NRF_RTC1->EVENTS_TICK = 0;
|
||||
|
||||
@@ -141,7 +141,6 @@ void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) {
|
||||
|
||||
LTRACEF("completing transfer %p\n", t);
|
||||
|
||||
PCD_EPTypeDef *ep = &hpcd->IN_ep[epnum];
|
||||
t->bufpos = ep->xfer_count;
|
||||
t->result = 0;
|
||||
t->callback(epnum, t);
|
||||
|
||||
@@ -722,9 +722,9 @@ static ssize_t qspi_erase_subsector(bdev_t *device, uint32_t block_addr) {
|
||||
return qspi_erase(device, block_addr, SUBSECTOR_ERASE_CMD);
|
||||
}
|
||||
|
||||
static HAL_StatusTypeDef qspi_cmd(QSPI_HandleTypeDef *qspi_handle,
|
||||
static HAL_StatusTypeDef qspi_cmd(QSPI_HandleTypeDef *handle,
|
||||
QSPI_CommandTypeDef *s_command) {
|
||||
HAL_StatusTypeDef result = HAL_QSPI_Command_IT(qspi_handle, s_command);
|
||||
HAL_StatusTypeDef result = HAL_QSPI_Command_IT(handle, s_command);
|
||||
|
||||
if (result != HAL_OK) {
|
||||
return result;
|
||||
@@ -781,8 +781,8 @@ void DMA_ErrorCallback(void) {
|
||||
}
|
||||
|
||||
// Send data and wait for interrupt.
|
||||
static HAL_StatusTypeDef qspi_tx_dma(QSPI_HandleTypeDef *qspi_handle, QSPI_CommandTypeDef *s_command, uint8_t *buf) {
|
||||
MODIFY_REG(qspi_handle->Instance->CCR, QUADSPI_CCR_FMODE, 0);
|
||||
static HAL_StatusTypeDef qspi_tx_dma(QSPI_HandleTypeDef *handle, QSPI_CommandTypeDef *s_command, uint8_t *buf) {
|
||||
MODIFY_REG(handle->Instance->CCR, QUADSPI_CCR_FMODE, 0);
|
||||
|
||||
if (dma_disable(dma2_stream7) != NO_ERROR) {
|
||||
dprintf(CRITICAL, "%s: timed out while waiting for DMA to disable.\n", __func__);
|
||||
@@ -791,7 +791,7 @@ static HAL_StatusTypeDef qspi_tx_dma(QSPI_HandleTypeDef *qspi_handle, QSPI_Comma
|
||||
|
||||
setup_dma(
|
||||
dma2_stream7,
|
||||
(uint32_t)&(qspi_handle->Instance->DR),
|
||||
(uint32_t)&(handle->Instance->DR),
|
||||
(uint32_t)buf,
|
||||
s_command->NbData,
|
||||
DMA_MEMORY_TO_PERIPH
|
||||
@@ -804,7 +804,7 @@ static HAL_StatusTypeDef qspi_tx_dma(QSPI_HandleTypeDef *qspi_handle, QSPI_Comma
|
||||
|
||||
// And we're off to the races...
|
||||
dma2_stream7->CR |= DMA_SxCR_EN;
|
||||
qspi_handle->Instance->CR |= QUADSPI_CR_DMAEN;
|
||||
handle->Instance->CR |= QUADSPI_CR_DMAEN;
|
||||
|
||||
event_wait(&tx_event);
|
||||
|
||||
@@ -812,12 +812,12 @@ static HAL_StatusTypeDef qspi_tx_dma(QSPI_HandleTypeDef *qspi_handle, QSPI_Comma
|
||||
}
|
||||
|
||||
// Send data and wait for interrupt.
|
||||
static HAL_StatusTypeDef qspi_rx_dma(QSPI_HandleTypeDef *qspi_handle, QSPI_CommandTypeDef *s_command, uint8_t *buf) {
|
||||
static HAL_StatusTypeDef qspi_rx_dma(QSPI_HandleTypeDef *handle, QSPI_CommandTypeDef *s_command, uint8_t *buf) {
|
||||
// Make sure the front and back of the buffer are cache aligned.
|
||||
DEBUG_ASSERT(IS_ALIGNED((uintptr_t)buf, CACHE_LINE));
|
||||
DEBUG_ASSERT(IS_ALIGNED(((uintptr_t)buf) + s_command->NbData, CACHE_LINE));
|
||||
|
||||
MODIFY_REG(qspi_handle->Instance->CCR, QUADSPI_CCR_FMODE, QUADSPI_CCR_FMODE_0);
|
||||
MODIFY_REG(handle->Instance->CCR, QUADSPI_CCR_FMODE, QUADSPI_CCR_FMODE_0);
|
||||
|
||||
if (dma_disable(dma2_stream7) != NO_ERROR) {
|
||||
dprintf(CRITICAL, "%s: timed out while waiting for DMA to disable.\n", __func__);
|
||||
@@ -826,7 +826,7 @@ static HAL_StatusTypeDef qspi_rx_dma(QSPI_HandleTypeDef *qspi_handle, QSPI_Comma
|
||||
|
||||
setup_dma(
|
||||
dma2_stream7,
|
||||
(uint32_t)&(qspi_handle->Instance->DR),
|
||||
(uint32_t)&(handle->Instance->DR),
|
||||
(uint32_t)buf,
|
||||
s_command->NbData,
|
||||
DMA_PERIPH_TO_MEMORY
|
||||
@@ -838,9 +838,9 @@ static HAL_StatusTypeDef qspi_rx_dma(QSPI_HandleTypeDef *qspi_handle, QSPI_Comma
|
||||
|
||||
// And we're off to the races...
|
||||
dma2_stream7->CR |= DMA_SxCR_EN;
|
||||
uint32_t addr_reg = qspi_handle->Instance->AR;
|
||||
qspi_handle->Instance->AR = addr_reg;
|
||||
qspi_handle->Instance->CR |= QUADSPI_CR_DMAEN;
|
||||
uint32_t addr_reg = handle->Instance->AR;
|
||||
handle->Instance->AR = addr_reg;
|
||||
handle->Instance->CR |= QUADSPI_CR_DMAEN;
|
||||
|
||||
event_wait(&rx_event);
|
||||
|
||||
@@ -1030,4 +1030,4 @@ static bool qspi_is_linear(void) {
|
||||
result = (QSPI_STATE_LINEAR == device_state);
|
||||
mutex_release(&spiflash_mutex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +108,6 @@ void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) {
|
||||
|
||||
LTRACEF("completing transfer %p\n", t);
|
||||
|
||||
PCD_EPTypeDef *ep = &hpcd->IN_ep[epnum];
|
||||
t->bufpos = ep->xfer_count;
|
||||
t->result = 0;
|
||||
t->callback(epnum, t);
|
||||
|
||||
Reference in New Issue
Block a user