aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.main5
-rw-r--r--libflash/ecc.c18
2 files changed, 19 insertions, 4 deletions
diff --git a/Makefile.main b/Makefile.main
index a5eb01e..b206ee1 100644
--- a/Makefile.main
+++ b/Makefile.main
@@ -157,7 +157,6 @@ OBJS += $(LIBPORE)
endif
OBJS += $(LIBC) $(CCAN) $(DEVSRC_OBJ)
OBJS_NO_VER = $(OBJS)
-EXTRA_LIBS = -Wl,-lgcc
ALL_OBJS = $(OBJS) version.o
ALL_OBJS_1 = $(ALL_OBJS) asm/dummy_map.o
@@ -167,12 +166,12 @@ $(TARGET).lid: $(TARGET).elf
$(call Q,OBJCOPY, $(OBJCOPY) -O binary -S $^ $@, $@)
$(TARGET).tmp.elf: $(ALL_OBJS_1) $(TARGET).lds $(KERNEL)
- $(call Q,LD, $(CC) $(LDFLAGS) -T $(TARGET).lds $(ALL_OBJS_1) $(EXTRA_LIBS) -o $@, $@)
+ $(call Q,LD, $(CC) $(LDFLAGS) -T $(TARGET).lds $(ALL_OBJS_1) -o $@, $@)
asm/real_map.o : $(TARGET).tmp.map
$(TARGET).elf: $(ALL_OBJS_2) $(TARGET).lds $(KERNEL)
- $(call Q,LD, $(CC) $(LDFLAGS) -T $(TARGET).lds $(ALL_OBJS_2) $(EXTRA_LIBS) -o $@, $@)
+ $(call Q,LD, $(CC) $(LDFLAGS) -T $(TARGET).lds $(ALL_OBJS_2) -o $@, $@)
$(SUBDIRS):
$(call Q,MKDIR,mkdir $@, $@)
diff --git a/libflash/ecc.c b/libflash/ecc.c
index 05c0e14..9cd6ad2 100644
--- a/libflash/ecc.c
+++ b/libflash/ecc.c
@@ -108,6 +108,22 @@ static enum eccbitfields syndromematrix[] = {
UE, UE, UE, UE, 4, UE, UE, UE, UE, UE, UE, UE, UE, UE, UE, UE,
};
+static uint8_t parity(uint64_t data)
+{
+#ifdef __SKIBOOT__
+ uint8_t p;
+
+ asm volatile(
+ "popcntb %1,%0\n"
+ "prtyd %1,%1\n"
+ : "=r"(p) : "r"(data));
+
+ return p;
+#else
+ return __builtin_parityl(data);
+#endif
+}
+
/**
* Create the ECC field corresponding to a 8-byte data field
*
@@ -120,7 +136,7 @@ static uint8_t eccgenerate(uint64_t data)
uint8_t result = 0;
for (i = 0; i < 8; i++)
- result |= __builtin_parityl(eccmatrix[i] & data) << i;
+ result |= parity(eccmatrix[i] & data) << i;
return result;
}