Fix TCC on some architectures, -pedantic build, replaced binary literals with hex numbers
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
f018396b1d
commit
60963aa01a
|
@ -1,4 +1,4 @@
|
|||
local Pipeline(image, version, arch, depinstall, extra) = {
|
||||
local Pipeline(image, version, arch, depinstall, extra, gccExtra, clangExtra, tccExtra) = {
|
||||
kind: "pipeline",
|
||||
type: "docker",
|
||||
name: image+"-"+version+"-"+arch,
|
||||
|
@ -11,7 +11,7 @@ local Pipeline(image, version, arch, depinstall, extra) = {
|
|||
name: "build-gcc",
|
||||
image: image+":"+version,
|
||||
commands: [
|
||||
depinstall+" make gcc "+extra,
|
||||
depinstall+" make "+extra+" "+gccExtra,
|
||||
"make clean",
|
||||
"make CC=gcc all"
|
||||
]
|
||||
|
@ -20,32 +20,36 @@ local Pipeline(image, version, arch, depinstall, extra) = {
|
|||
name: "build-clang",
|
||||
image: image+":"+version,
|
||||
commands: [
|
||||
depinstall+" make clang "+extra,
|
||||
depinstall+" make "+extra+" "+clangExtra,
|
||||
"make clean",
|
||||
"make CC=clang all"
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "build-tcc",
|
||||
image: image+":"+version,
|
||||
commands: [
|
||||
depinstall+" make tcc "+extra,
|
||||
"make clean",
|
||||
"make CC=tcc all"
|
||||
]
|
||||
}
|
||||
]
|
||||
] + (if tccExtra != "" then [
|
||||
{
|
||||
name: "build-tcc",
|
||||
image: image+":"+version,
|
||||
commands: [
|
||||
depinstall+" make "+extra+" "+tccExtra,
|
||||
"make clean",
|
||||
"make CC=tcc all"
|
||||
]
|
||||
}
|
||||
] else []
|
||||
)
|
||||
};
|
||||
|
||||
local AptPipeline(image, version, arch, extra="") = Pipeline(image, version, arch, "apt update && DEBIAN_FRONTEND=noninteractive apt install -y", extra);
|
||||
local AptPipeline(image, version, arch, extra="", gccExtra="gcc", clangExtra="clang", tccExtra="tcc") = Pipeline(image, version, arch, "apt update && DEBIAN_FRONTEND=noninteractive apt install -y", extra, gccExtra, clangExtra, tccExtra);
|
||||
|
||||
local PacManPipeline(image, version, arch, extra="") = Pipeline(image, version, arch, "pacman -Syy && pacman --noconfirm -S", extra);
|
||||
local PacManPipeline(image, version, arch, extra="", gccExtra="gcc", clangExtra="clang", tccExtra="tcc") = Pipeline(image, version, arch, "pacman -Syy && pacman --noconfirm -S", extra, gccExtra, clangExtra, tccExtra);
|
||||
|
||||
local ApkPipeline(image, version, arch, extra="") = Pipeline(image, version, arch, "apk add --update gcc musl-dev", extra);
|
||||
local ApkPipeline(image, version, arch, extra="musl-dev linux-headers", gccExtra="gcc", clangExtra="gcc clang", tccExtra="tcc") = Pipeline(image, version, arch, "apk add --update", extra, gccExtra, clangExtra, tccExtra);
|
||||
|
||||
local YumPipeline(image, version, arch, extra="") = Pipeline(image, version, arch, "yum install -y", extra);
|
||||
local YumPipeline(image, version, arch, extra="", gccExtra="gcc", clangExtra="clang", tccExtra="") = Pipeline(image, version, arch, "yum install -y", extra, gccExtra, clangExtra, tccExtra);
|
||||
|
||||
local XbpsPipeline(image, version, arch, extra="") = Pipeline(image, version, arch, "xbps-install -Sy", extra);
|
||||
local XbpsPipeline(image, version, arch, extra="", gccExtra="gcc", clangExtra="clang", tccExtra="tcc kernel-libc-headers") = Pipeline(image, version, arch, "xbps-install -Sy", extra, gccExtra, clangExtra, tccExtra);
|
||||
|
||||
#
|
||||
|
||||
[
|
||||
AptPipeline("ubuntu", "20.04", "amd64"),
|
||||
|
@ -70,8 +74,8 @@ local XbpsPipeline(image, version, arch, extra="") = Pipeline(image, version, ar
|
|||
PacManPipeline("archlinux", "latest", "amd64"),
|
||||
|
||||
|
||||
ApkPipeline("alpine", "latest", "amd64", "linux-headers"),
|
||||
ApkPipeline("alpine", "latest", "arm64", "linux-headers"),
|
||||
ApkPipeline("alpine", "edge", "amd64"),
|
||||
ApkPipeline("alpine", "edge", "arm64"),
|
||||
|
||||
|
||||
XbpsPipeline("voidlinux/voidlinux", "latest", "amd64"),
|
||||
|
|
8
Makefile
8
Makefile
|
@ -1,10 +1,12 @@
|
|||
CC=cc
|
||||
CFLAGS=-ggdb -std=gnu99 -Wall -Werror -Wno-unknown-pragmas -Wno-packed-bitfield-compat
|
||||
CFLAGS=-ggdb -Wall -Werror -pedantic -Wno-unknown-pragmas -Wno-packed-bitfield-compat
|
||||
|
||||
ifeq ($(shell $(CC) -v 2>&1 | grep -c "clang version"), 1)
|
||||
CFLAGS += -O0 -Wno-unknown-warning-option
|
||||
CFLAGS += -O0 -std=gnu99 -Wno-unknown-warning-option
|
||||
else ifeq ($(shell $(CC) -v 2>&1 | grep -c "tcc version"), 1)
|
||||
CFLAGS += -std=c99
|
||||
else
|
||||
CFLAGS += -Og
|
||||
CFLAGS += -Og -std=gnu99
|
||||
endif
|
||||
|
||||
default: fm10k-dump fm10k-flash
|
||||
|
|
|
@ -149,4 +149,4 @@ int main(int argc, char **argv) {
|
|||
printf("\nRead %u bytes\n", bootImageSize);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -264,4 +264,4 @@ int main(int argc, char **argv) {
|
|||
printf("\nWritten %u bytes\n", bootImageSizeMax);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
42
src/fm10k.c
42
src/fm10k.c
|
@ -160,10 +160,10 @@ SPI_COMMAND_READ_MANUFACTURER_RESULT fm10k_mem_spi_ReadManufacturerData(uintptr_
|
|||
WriteRegister32(mem, FM10K_REGISTER_SPI_HEADER, header);
|
||||
|
||||
/* first loop only: set send header flag. Following loops: shift only data. */
|
||||
spiCtrl.fields.Command |= 0b0001;
|
||||
spiCtrl.fields.Command |= 0b0100;
|
||||
spiCtrl.fields.Command |= 0x1;
|
||||
spiCtrl.fields.Command |= 0x4;
|
||||
spiCtrl.fields.HeaderSize = 1;
|
||||
spiCtrl.fields.DataSize = 4 & 0b11;
|
||||
spiCtrl.fields.DataSize = 0x4 & 3;
|
||||
|
||||
if (fm10k_mem_spi_SetCtrlReg(mem, spiCtrl)) {
|
||||
return result;
|
||||
|
@ -178,7 +178,7 @@ SPI_COMMAND_READ_MANUFACTURER_RESULT fm10k_mem_spi_ReadManufacturerData(uintptr_
|
|||
|
||||
|
||||
/* release CS */
|
||||
spiCtrl.fields.Command = 0b1000;
|
||||
spiCtrl.fields.Command = 0x8;
|
||||
if (fm10k_mem_spi_SetCtrlReg(mem, spiCtrl)) {
|
||||
result.value = 0;
|
||||
return result;
|
||||
|
@ -221,15 +221,15 @@ uint32_t fm10k_mem_spi_ReadFlash(uintptr_t mem, uint32_t address, uint8_t *data,
|
|||
WriteRegister32(mem, FM10K_REGISTER_SPI_HEADER, header);
|
||||
|
||||
/* first loop only: set send header flag. Following loops: shift only data. */
|
||||
spiCtrl.fields.Command |= 0b0001;
|
||||
spiCtrl.fields.Command |= 0x1;
|
||||
|
||||
cnt = 0;
|
||||
while (cnt < len) {
|
||||
/* determine the number of data bytes to read [1..4] */
|
||||
numRead = (len - cnt) > 3 ? 4 : (len - cnt);
|
||||
/* set 'shift data' flag and number of data bytes */
|
||||
spiCtrl.fields.Command |= 0b0100;
|
||||
spiCtrl.fields.DataSize = numRead & 0b11;
|
||||
spiCtrl.fields.Command |= 0x4;
|
||||
spiCtrl.fields.DataSize = numRead & 3;
|
||||
|
||||
if (fm10k_mem_spi_SetCtrlReg(mem, spiCtrl)) {
|
||||
return 1;
|
||||
|
@ -244,12 +244,12 @@ uint32_t fm10k_mem_spi_ReadFlash(uintptr_t mem, uint32_t address, uint8_t *data,
|
|||
data[cnt++] = (rxData >> (numRead * 8)) & 0xff;
|
||||
}
|
||||
|
||||
spiCtrl.fields.Command = 0b0000;
|
||||
spiCtrl.fields.DataSize = 0b0000;
|
||||
spiCtrl.fields.Command = 0;
|
||||
spiCtrl.fields.DataSize = 0;
|
||||
}
|
||||
|
||||
/* release CS */
|
||||
spiCtrl.fields.Command = 0b1000;
|
||||
spiCtrl.fields.Command = 0x8;
|
||||
if (fm10k_mem_spi_SetCtrlReg(mem, spiCtrl)) {
|
||||
return 1;
|
||||
}
|
||||
|
@ -286,7 +286,7 @@ uint32_t fm10k_mem_spi_EnableSectorProtection(uintptr_t mem) {
|
|||
WriteRegister32(mem, FM10K_REGISTER_SPI_HEADER, header);
|
||||
|
||||
/* first loop only: set send header flag. Following loops: shift only data. */
|
||||
spiCtrl.fields.Command |= 0b0001;
|
||||
spiCtrl.fields.Command |= 0x1;
|
||||
|
||||
/* send command to the flash */
|
||||
if (fm10k_mem_spi_SetCtrlReg(mem, spiCtrl)) {
|
||||
|
@ -294,7 +294,7 @@ uint32_t fm10k_mem_spi_EnableSectorProtection(uintptr_t mem) {
|
|||
}
|
||||
|
||||
/* release CS */
|
||||
spiCtrl.fields.Command = 0b1000;
|
||||
spiCtrl.fields.Command = 0x8;
|
||||
if (fm10k_mem_spi_SetCtrlReg(mem, spiCtrl)) {
|
||||
return 1;
|
||||
}
|
||||
|
@ -330,7 +330,7 @@ uint32_t fm10k_mem_spi_DisableSectorProtection(uintptr_t mem) {
|
|||
WriteRegister32(mem, FM10K_REGISTER_SPI_HEADER, header);
|
||||
|
||||
/* first loop only: set send header flag. Following loops: shift only data. */
|
||||
spiCtrl.fields.Command |= 0b0001;
|
||||
spiCtrl.fields.Command |= 0x1;
|
||||
|
||||
/* send command to the flash */
|
||||
if (fm10k_mem_spi_SetCtrlReg(mem, spiCtrl)) {
|
||||
|
@ -338,7 +338,7 @@ uint32_t fm10k_mem_spi_DisableSectorProtection(uintptr_t mem) {
|
|||
}
|
||||
|
||||
/* release CS */
|
||||
spiCtrl.fields.Command = 0b1000;
|
||||
spiCtrl.fields.Command = 0x8;
|
||||
if (fm10k_mem_spi_SetCtrlReg(mem, spiCtrl)) {
|
||||
return 1;
|
||||
}
|
||||
|
@ -379,15 +379,15 @@ uint32_t fm10k_mem_spi_WriteFlash(uintptr_t mem, uint32_t address, const uint8_t
|
|||
WriteRegister32(mem, FM10K_REGISTER_SPI_HEADER, header);
|
||||
|
||||
/* first loop only: set send header flag. Following loops: shift only data. */
|
||||
spiCtrl.fields.Command |= 0b0001;
|
||||
spiCtrl.fields.Command |= 0x1;
|
||||
|
||||
cnt = 0;
|
||||
while (cnt < len) {
|
||||
/* determine the number of data bytes to read [1..4] */
|
||||
numWrite = (len - cnt) > 3 ? 4 : (len - cnt);
|
||||
/* set 'shift data' flag and number of data bytes */
|
||||
spiCtrl.fields.Command |= 0b0100;
|
||||
spiCtrl.fields.DataSize = numWrite & 0b11;
|
||||
spiCtrl.fields.Command |= 0x4;
|
||||
spiCtrl.fields.DataSize = numWrite & 3;
|
||||
|
||||
txData = 0;
|
||||
while (numWrite--) {
|
||||
|
@ -401,12 +401,12 @@ uint32_t fm10k_mem_spi_WriteFlash(uintptr_t mem, uint32_t address, const uint8_t
|
|||
return 1;
|
||||
}
|
||||
|
||||
spiCtrl.fields.Command = 0b0000;
|
||||
spiCtrl.fields.DataSize = 0b0000;
|
||||
spiCtrl.fields.Command = 0;
|
||||
spiCtrl.fields.DataSize = 0;
|
||||
}
|
||||
|
||||
/* release CS */
|
||||
spiCtrl.fields.Command = 0b1000;
|
||||
spiCtrl.fields.Command = 0x8;
|
||||
if (fm10k_mem_spi_SetCtrlReg(mem, spiCtrl)) {
|
||||
return 1;
|
||||
}
|
||||
|
@ -573,4 +573,4 @@ FM10K_PCI_DEVICE fm10k_pci_findDevice() {
|
|||
closedir(folder);
|
||||
|
||||
return device;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -166,4 +166,5 @@ typedef struct {
|
|||
char bar4Path[PATH_MAX];
|
||||
} FM10K_PCI_DEVICE;
|
||||
|
||||
FM10K_PCI_DEVICE fm10k_pci_findDevice();
|
||||
FM10K_PCI_DEVICE fm10k_pci_findDevice();
|
||||
|
||||
|
|
|
@ -54,4 +54,4 @@ int main(int argc, char **argv) {
|
|||
|
||||
printf("\nTests run, failed %u/%u\n", testsFailed, tests);
|
||||
return testsFailed > 0 ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue