Skip to content

Commit 4f9858e

Browse files
committed
stmhal: Move pybstdio.c to lib/utils/sys_stdio_mphal.c for common use.
It provides sys.stdin, sys.stdout, sys.stderr for bare-metal targets based on mp_hal functions.
1 parent 76ec04a commit 4f9858e

File tree

8 files changed

+21
-31
lines changed

8 files changed

+21
-31
lines changed

cc3200/application.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,12 @@ APP_LIB_SRC_C = $(addprefix lib/,\
147147
netutils/netutils.c \
148148
timeutils/timeutils.c \
149149
utils/pyexec.c \
150+
utils/sys_stdio_mphal.c \
150151
)
151152

152153
APP_STM_SRC_C = $(addprefix stmhal/,\
153154
bufhelper.c \
154155
irq.c \
155-
pybstdio.c \
156156
)
157157

158158
OBJ = $(PY_O) $(addprefix $(BUILD)/, $(APP_FATFS_SRC_C:.c=.o) $(APP_RTOS_SRC_C:.c=.o) $(APP_FTP_SRC_C:.c=.o) $(APP_HAL_SRC_C:.c=.o) $(APP_MISC_SRC_C:.c=.o))

esp8266/Makefile

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,6 @@ SRC_C = \
9292
hspi.c \
9393
$(SRC_MOD)
9494

95-
STM_SRC_C = $(addprefix stmhal/,\
96-
pybstdio.c \
97-
)
98-
9995
EXTMOD_SRC_C = $(addprefix extmod/,\
10096
modlwip.c \
10197
)
@@ -125,6 +121,7 @@ LIB_SRC_C = $(addprefix lib/,\
125121
timeutils/timeutils.c \
126122
utils/pyexec.c \
127123
utils/interrupt_char.c \
124+
utils/sys_stdio_mphal.c \
128125
)
129126

130127
ifeq ($(MICROPY_FATFS), 1)
@@ -144,14 +141,13 @@ OBJ =
144141
OBJ += $(PY_O)
145142
OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
146143
OBJ += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))
147-
OBJ += $(addprefix $(BUILD)/, $(STM_SRC_C:.c=.o))
148144
OBJ += $(addprefix $(BUILD)/, $(EXTMOD_SRC_C:.c=.o))
149145
OBJ += $(addprefix $(BUILD)/, $(LIB_SRC_C:.c=.o))
150146
OBJ += $(addprefix $(BUILD)/, $(DRIVERS_SRC_C:.c=.o))
151147
#OBJ += $(BUILD)/pins_$(BOARD).o
152148

153149
# List of sources for qstr extraction
154-
SRC_QSTR += $(SRC_C) $(STM_SRC_C) $(EXTMOD_SRC_C) $(DRIVERS_SRC_C)
150+
SRC_QSTR += $(SRC_C) $(EXTMOD_SRC_C) $(DRIVERS_SRC_C)
155151
# Append any auto-generated sources that are needed by sources listed in SRC_QSTR
156152
SRC_QSTR_AUTO_DEPS +=
157153

esp8266/esp8266_common.ld

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,6 @@ SECTIONS
125125
*lib/timeutils/*.o*(.literal*, .text*)
126126
*lib/utils/*.o*(.literal*, .text*)
127127

128-
*stmhal/pybstdio.o(.literal*, .text*)
129-
130128
build/main.o(.literal* .text*)
131129
*gccollect.o(.literal* .text*)
132130
*gchelper.o(.literal* .text*)

stmhal/pybstdio.c renamed to lib/utils/sys_stdio_mphal.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/*
2-
* This file is part of the Micro Python project, http://micropython.org/
2+
* This file is part of the MicroPython project, http://micropython.org/
33
*
44
* The MIT License (MIT)
55
*
6-
* Copyright (c) 2013, 2014, 2015 Damien P. George
6+
* Copyright (c) 2013-2017 Damien P. George
77
*
88
* Permission is hereby granted, free of charge, to any person obtaining a copy
99
* of this software and associated documentation files (the "Software"), to deal
@@ -37,28 +37,28 @@
3737
// objects are in a read-only module (py/modsys.c).
3838

3939
/******************************************************************************/
40-
// Micro Python bindings
40+
// MicroPython bindings
4141

4242
#define STDIO_FD_IN (0)
4343
#define STDIO_FD_OUT (1)
4444
#define STDIO_FD_ERR (2)
4545

46-
typedef struct _pyb_stdio_obj_t {
46+
typedef struct _sys_stdio_obj_t {
4747
mp_obj_base_t base;
4848
int fd;
49-
} pyb_stdio_obj_t;
49+
} sys_stdio_obj_t;
5050

5151
#if MICROPY_PY_SYS_STDIO_BUFFER
52-
STATIC const pyb_stdio_obj_t stdio_buffer_obj;
52+
STATIC const sys_stdio_obj_t stdio_buffer_obj;
5353
#endif
5454

5555
void stdio_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
56-
pyb_stdio_obj_t *self = self_in;
56+
sys_stdio_obj_t *self = self_in;
5757
mp_printf(print, "<io.FileIO %d>", self->fd);
5858
}
5959

6060
STATIC mp_uint_t stdio_read(mp_obj_t self_in, void *buf, mp_uint_t size, int *errcode) {
61-
pyb_stdio_obj_t *self = self_in;
61+
sys_stdio_obj_t *self = self_in;
6262
if (self->fd == STDIO_FD_IN) {
6363
for (uint i = 0; i < size; i++) {
6464
int c = mp_hal_stdin_rx_chr();
@@ -75,7 +75,7 @@ STATIC mp_uint_t stdio_read(mp_obj_t self_in, void *buf, mp_uint_t size, int *er
7575
}
7676

7777
STATIC mp_uint_t stdio_write(mp_obj_t self_in, const void *buf, mp_uint_t size, int *errcode) {
78-
pyb_stdio_obj_t *self = self_in;
78+
sys_stdio_obj_t *self = self_in;
7979
if (self->fd == STDIO_FD_OUT || self->fd == STDIO_FD_ERR) {
8080
mp_hal_stdout_tx_strn_cooked(buf, size);
8181
return size;
@@ -126,9 +126,9 @@ STATIC const mp_obj_type_t stdio_obj_type = {
126126
.locals_dict = (mp_obj_dict_t*)&stdio_locals_dict,
127127
};
128128

129-
const pyb_stdio_obj_t mp_sys_stdin_obj = {{&stdio_obj_type}, .fd = STDIO_FD_IN};
130-
const pyb_stdio_obj_t mp_sys_stdout_obj = {{&stdio_obj_type}, .fd = STDIO_FD_OUT};
131-
const pyb_stdio_obj_t mp_sys_stderr_obj = {{&stdio_obj_type}, .fd = STDIO_FD_ERR};
129+
const sys_stdio_obj_t mp_sys_stdin_obj = {{&stdio_obj_type}, .fd = STDIO_FD_IN};
130+
const sys_stdio_obj_t mp_sys_stdout_obj = {{&stdio_obj_type}, .fd = STDIO_FD_OUT};
131+
const sys_stdio_obj_t mp_sys_stderr_obj = {{&stdio_obj_type}, .fd = STDIO_FD_ERR};
132132

133133
#if MICROPY_PY_SYS_STDIO_BUFFER
134134
STATIC mp_uint_t stdio_buffer_read(mp_obj_t self_in, void *buf, mp_uint_t size, int *errcode) {
@@ -159,5 +159,5 @@ STATIC const mp_obj_type_t stdio_buffer_obj_type = {
159159
.locals_dict = (mp_obj_t)&stdio_locals_dict,
160160
};
161161

162-
STATIC const pyb_stdio_obj_t stdio_buffer_obj = {{&stdio_buffer_obj_type}, .fd = 0}; // fd unused
162+
STATIC const sys_stdio_obj_t stdio_buffer_obj = {{&stdio_buffer_obj_type}, .fd = 0}; // fd unused
163163
#endif

pic16bit/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ SRC_C = \
3939
modpyb.c \
4040
modpybled.c \
4141
modpybswitch.c \
42-
stmhal/pybstdio.c \
4342
lib/utils/pyexec.c \
43+
lib/utils/sys_stdio_mphal.c \
4444
lib/mp-readline/readline.c \
4545

4646
SRC_S = \

qemu-arm/Makefile

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,13 @@ LIB_SRC_C = $(addprefix lib/,\
6363
libm/asinfacosf.c \
6464
libm/atanf.c \
6565
libm/atan2f.c \
66-
)
67-
68-
STM_SRC_C = $(addprefix stmhal/,\
69-
pybstdio.c \
66+
utils/sys_stdio_mphal.c \
7067
)
7168

7269
OBJ_COMMON =
7370
OBJ_COMMON += $(PY_O)
7471
OBJ_COMMON += $(addprefix $(BUILD)/, $(SRC_COMMON_C:.c=.o))
7572
OBJ_COMMON += $(addprefix $(BUILD)/, $(LIB_SRC_C:.c=.o))
76-
OBJ_COMMON += $(addprefix $(BUILD)/, $(STM_SRC_C:.c=.o))
7773

7874
OBJ_RUN =
7975
OBJ_RUN += $(addprefix $(BUILD)/, $(SRC_RUN_C:.c=.o))
@@ -86,7 +82,7 @@ OBJ_TEST += $(BUILD)/tinytest.o
8682
OBJ = $(OBJ_COMMON) $(OBJ_RUN) $(OBJ_TEST)
8783

8884
# List of sources for qstr extraction
89-
SRC_QSTR += $(SRC_COMMON_C) $(SRC_RUN_C) $(STM_SRC_C)
85+
SRC_QSTR += $(SRC_COMMON_C) $(SRC_RUN_C)
9086

9187
all: run
9288

stmhal/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ SRC_LIB = $(addprefix lib/,\
110110
timeutils/timeutils.c \
111111
utils/pyexec.c \
112112
utils/interrupt_char.c \
113+
utils/sys_stdio_mphal.c \
113114
)
114115

115116
DRIVERS_SRC_C = $(addprefix drivers/,\
@@ -145,7 +146,6 @@ SRC_C = \
145146
usb.c \
146147
wdt.c \
147148
gccollect.c \
148-
pybstdio.c \
149149
help.c \
150150
machine_i2c.c \
151151
modmachine.c \

teensy/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ STM_SRC_C = $(addprefix stmhal/,\
9696
irq.c \
9797
pin.c \
9898
pin_named_pins.c \
99-
pybstdio.c \
10099
)
101100

102101
STM_SRC_S = $(addprefix stmhal/,\
@@ -107,6 +106,7 @@ LIB_SRC_C = $(addprefix lib/,\
107106
libc/string0.c \
108107
mp-readline/readline.c \
109108
utils/pyexec.c \
109+
utils/sys_stdio_mphal.c \
110110
)
111111

112112
SRC_TEENSY = $(addprefix core/,\

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy