Skip to content

Commit 7b44f07

Browse files
committed
WIP
1 parent c99e34e commit 7b44f07

29 files changed

+3463
-1
lines changed

.clang-format

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
---
2+
IndentWidth: 4
3+
---
4+
Language: Cpp
5+
ColumnLimit: 80
6+
BreakBeforeBraces: Linux
7+
SpaceBeforeParens: ControlStatements
8+
IncludeBlocks: Merge
9+
IncludeCategories:
10+
- Regex: 'osdep.h"$'
11+
Priority: -2
12+
- Regex: '^<'
13+
Priority: -1
14+
- Regex: '.*'
15+
Priority: 1
16+
---
17+
Language: JavaScript
18+
AccessModifierOffset: -2
19+
AlignAfterOpenBracket: Align
20+
AlignConsecutiveMacros: false
21+
AlignConsecutiveAssignments: false
22+
AlignConsecutiveBitFields: false
23+
AlignConsecutiveDeclarations: false
24+
AlignEscapedNewlines: Right
25+
AlignOperands: Align
26+
AlignTrailingComments: true
27+
AllowAllArgumentsOnNextLine: true
28+
AllowAllConstructorInitializersOnNextLine: true
29+
AllowAllParametersOfDeclarationOnNextLine: true
30+
AllowShortEnumsOnASingleLine: true
31+
AllowShortBlocksOnASingleLine: Never
32+
AllowShortCaseLabelsOnASingleLine: false
33+
AllowShortFunctionsOnASingleLine: All
34+
AllowShortLambdasOnASingleLine: All
35+
AllowShortIfStatementsOnASingleLine: Never
36+
AllowShortLoopsOnASingleLine: false
37+
AlwaysBreakAfterDefinitionReturnType: All
38+
AlwaysBreakAfterReturnType: AllDefinitions
39+
AlwaysBreakBeforeMultilineStrings: false
40+
AlwaysBreakTemplateDeclarations: MultiLine
41+
BinPackArguments: true
42+
BinPackParameters: true
43+
BraceWrapping:
44+
AfterCaseLabel: true
45+
AfterClass: true
46+
AfterControlStatement: Always
47+
AfterEnum: true
48+
AfterFunction: true
49+
AfterNamespace: true
50+
AfterObjCDeclaration: true
51+
AfterStruct: true
52+
AfterUnion: true
53+
AfterExternBlock: true
54+
BeforeCatch: true
55+
BeforeElse: true
56+
BeforeLambdaBody: false
57+
BeforeWhile: true
58+
IndentBraces: true
59+
SplitEmptyFunction: true
60+
SplitEmptyRecord: true
61+
SplitEmptyNamespace: true
62+
BreakBeforeBinaryOperators: All
63+
BreakBeforeInheritanceComma: false
64+
BreakInheritanceList: BeforeColon
65+
BreakBeforeTernaryOperators: true
66+
BreakConstructorInitializersBeforeComma: false
67+
BreakConstructorInitializers: BeforeColon
68+
BreakAfterJavaFieldAnnotations: false
69+
BreakStringLiterals: true
70+
CommentPragmas: '^ IWYU pragma:'
71+
CompactNamespaces: false
72+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
73+
ConstructorInitializerIndentWidth: 4
74+
ContinuationIndentWidth: 4
75+
Cpp11BracedListStyle: false
76+
DeriveLineEnding: true
77+
DerivePointerAlignment: false
78+
DisableFormat: false
79+
ExperimentalAutoDetectBinPacking: false
80+
FixNamespaceComments: false
81+
ForEachMacros:
82+
- foreach
83+
- Q_FOREACH
84+
- BOOST_FOREACH
85+
IncludeIsMainRegex: '(Test)?$'
86+
IncludeIsMainSourceRegex: ''
87+
IndentCaseLabels: false
88+
IndentCaseBlocks: false
89+
IndentGotoLabels: true
90+
IndentPPDirectives: None
91+
IndentExternBlock: AfterExternBlock
92+
IndentWidth: 2
93+
IndentWrappedFunctionNames: false
94+
InsertTrailingCommas: None
95+
JavaScriptQuotes: Leave
96+
JavaScriptWrapImports: true
97+
KeepEmptyLinesAtTheStartOfBlocks: true
98+
MacroBlockBegin: ''
99+
MacroBlockEnd: ''
100+
MaxEmptyLinesToKeep: 1
101+
NamespaceIndentation: None
102+
ObjCBinPackProtocolList: Auto
103+
ObjCBlockIndentWidth: 2
104+
ObjCBreakBeforeNestedBlockParam: true
105+
ObjCSpaceAfterProperty: false
106+
ObjCSpaceBeforeProtocolList: true
107+
PenaltyBreakAssignment: 2
108+
PenaltyBreakBeforeFirstCallParameter: 19
109+
PenaltyBreakComment: 300
110+
PenaltyBreakFirstLessLess: 120
111+
PenaltyBreakString: 1000
112+
PenaltyBreakTemplateDeclaration: 10
113+
PenaltyExcessCharacter: 1000000
114+
PointerAlignment: Right
115+
ReflowComments: true
116+
SortIncludes: true
117+
SortUsingDeclarations: true
118+
SpaceAfterCStyleCast: false
119+
SpaceAfterLogicalNot: false
120+
SpaceAfterTemplateKeyword: true
121+
SpaceBeforeAssignmentOperators: true
122+
SpaceBeforeCpp11BracedList: false
123+
SpaceBeforeCtorInitializerColon: true
124+
SpaceBeforeInheritanceColon: true
125+
SpaceBeforeParens: Always
126+
SpaceBeforeRangeBasedForLoopColon: true
127+
SpaceInEmptyBlock: false
128+
SpaceInEmptyParentheses: false
129+
SpacesBeforeTrailingComments: 1
130+
SpacesInAngles: false
131+
SpacesInConditionalStatement: false
132+
SpacesInContainerLiterals: true
133+
SpacesInCStyleCastParentheses: false
134+
SpacesInParentheses: false
135+
SpacesInSquareBrackets: false
136+
SpaceBeforeSquareBrackets: false
137+
Standard: c++03
138+
StatementMacros:
139+
- Q_UNUSED
140+
- QT_REQUIRE_VERSION
141+
TabWidth: 8
142+
UseCRLF: false
143+
UseTab: Never
144+
WhitespaceSensitiveMacros:
145+
- STRINGIZE
146+
- PP_STRINGIZE
147+
- BOOST_PP_STRINGIZE
148+
...
149+

hw/arm/amazfit.c

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
2+
#include "qemu/osdep.h"
3+
#include "hw/arm/boot.h"
4+
#include "hw/arm/stm32l467_soc.h"
5+
#include "hw/boards.h"
6+
#include "hw/i2c/i2c.h"
7+
#include "hw/loader.h"
8+
#include "hw/qdev-properties.h"
9+
#include "hw/ssi/ssi.h"
10+
#include "qapi/error.h"
11+
12+
// static uint32_t readu32(hwaddr addr) {
13+
// uint32_t ret;
14+
// ARMCPU *cpu = ARM_CPU(first_cpu);
15+
// cpu_memory_rw_debug(cpu, addr, &ret, 4, false);
16+
//
17+
// return ret;
18+
//}
19+
20+
static void bip_init(MachineState *machine)
21+
{
22+
23+
STM32L467State *dev = STM32L467_SOC(qdev_new(TYPE_STM32L467_SOC));
24+
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
25+
26+
SSIBus *spi_bus = (SSIBus *)qdev_get_child_bus(&dev->spi[2], "ssi"); // SPI3
27+
DeviceState *display = ssi_create_peripheral(spi_bus, "jdi-lpm013m126c");
28+
29+
/* --- QSPI Flash --------------------------------------------- */
30+
SSIBus *qspi = (SSIBus *)qdev_get_child_bus(&dev->qspi, "qspi");
31+
DeviceState *qspi_flash = qdev_new("w25q64fw");
32+
33+
DriveInfo *dinfo = drive_get(IF_MTD, 0, 0);
34+
BlockBackend *blk = dinfo ? blk_by_legacy_dinfo(dinfo) : NULL;
35+
qdev_prop_set_drive(qspi_flash, "drive", blk);
36+
ssi_realize_and_unref(qspi_flash, qspi, &error_fatal);
37+
38+
qemu_irq mx25u_cs = qdev_get_gpio_in_named(qspi_flash, SSI_GPIO_CS, 0);
39+
sysbus_connect_irq(SYS_BUS_DEVICE(&dev->qspi), 1, mx25u_cs);
40+
41+
if (false) {
42+
load_image_targphys("/Users/Marijn/Projects/_pebble/"
43+
"Amazfitbip-FreeRTOS/bin/lcd_test.bin",
44+
0, FLASH_SIZE);
45+
} else {
46+
load_image_targphys("/Users/Marijn/Downloads/bip/image.bin", 0,
47+
FLASH_SIZE);
48+
}
49+
50+
I2CBus *i2c = (I2CBus *)qdev_get_child_bus(&dev->i2c[0], "i2c");
51+
i2c_slave_create_simple(i2c, "it7259", 0x46);
52+
53+
armv7m_load_kernel(ARM_CPU(first_cpu), NULL, 0);
54+
}
55+
56+
static void bip_machine_init(MachineClass *mc)
57+
{
58+
mc->desc = "Amazfit Bip";
59+
mc->init = bip_init;
60+
}
61+
62+
DEFINE_MACHINE("amazfitbip", bip_machine_init)

hw/arm/it7259.c

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#include "qemu/osdep.h"
2+
#include "hw/i2c/i2c.h"
3+
#include "hw/irq.h"
4+
#include "migration/vmstate.h"
5+
#include "qemu/module.h"
6+
#include "qemu/timer.h"
7+
#include "ui/console.h"
8+
9+
#define TYPE_IT7259 "it7259"
10+
#define IT7259(obj) OBJECT_CHECK(IT7259State, (obj), TYPE_IT7259)
11+
12+
typedef struct {
13+
I2CSlave parent_obj;
14+
15+
} IT7259State;
16+
17+
static int it7259_event(I2CSlave *i2c, enum i2c_event event)
18+
{
19+
IT7259State *s = IT7259(i2c);
20+
21+
return 0;
22+
}
23+
24+
static uint8_t it7259_rx(I2CSlave *i2c)
25+
{
26+
IT7259State *s = IT7259(i2c);
27+
28+
return 0;
29+
}
30+
31+
static int it7259_tx(I2CSlave *i2c, uint8_t data)
32+
{
33+
IT7259State *s = IT7259(i2c);
34+
printf("I2C: 0x%02X\n", data);
35+
36+
return 0;
37+
}
38+
39+
static void it7259_realize(DeviceState *dev, Error **errp)
40+
{
41+
IT7259State *s = IT7259(dev);
42+
}
43+
44+
static void it7259_class_init(ObjectClass *klass, void *data)
45+
{
46+
DeviceClass *dc = DEVICE_CLASS(klass);
47+
I2CSlaveClass *k = I2C_SLAVE_CLASS(klass);
48+
49+
dc->realize = it7259_realize;
50+
k->event = it7259_event;
51+
k->recv = it7259_rx;
52+
k->send = it7259_tx;
53+
}
54+
55+
static const TypeInfo it7259_info = {
56+
.name = TYPE_IT7259,
57+
.parent = TYPE_I2C_SLAVE,
58+
.instance_size = sizeof(IT7259State),
59+
.class_init = it7259_class_init,
60+
};
61+
62+
static void it7259_register_types(void) { type_register_static(&it7259_info); }
63+
64+
type_init(it7259_register_types)

hw/arm/meson.build

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,19 @@ arm_ss.add(when: 'CONFIG_ARM_SMMUV3', if_true: files('smmu-common.c', 'smmuv3.c'
5959
arm_ss.add(when: 'CONFIG_FSL_IMX6UL', if_true: files('fsl-imx6ul.c', 'mcimx6ul-evk.c'))
6060
arm_ss.add(when: 'CONFIG_NRF51_SOC', if_true: files('nrf51_soc.c'))
6161

62+
arm_ss.add(files('amazfit.c'))
63+
arm_ss.add(files('stm32l467_soc.c'))
64+
arm_ss.add(files('stm32l476_flash.c'))
65+
arm_ss.add(files('stm32l476_lptim.c'))
66+
arm_ss.add(files('stm32l476_pwr.c'))
67+
arm_ss.add(files('stm32l476_rcc.c'))
68+
arm_ss.add(files('stm32l476_dma.c'))
69+
arm_ss.add(files('stm32l476_spi.c'))
70+
arm_ss.add(files('stm32l476_qspi.c'))
71+
arm_ss.add(files('stm32l476_gpio.c'))
72+
arm_ss.add(files('stm32l476_syscfg.c'))
73+
arm_ss.add(files('stm32l476_i2c.c'))
74+
arm_ss.add(files('it7259.c'))
75+
76+
6277
hw_arch += {'arm': arm_ss}

0 commit comments

Comments
 (0)