Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
278f3592
Commit
278f3592
authored
9 years ago
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
extmod/modmachine: Use uintptr_t instead of mp_uint_t for address type.
parent
5d66b427
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
extmod/modmachine.c
+8
-8
8 additions, 8 deletions
extmod/modmachine.c
with
8 additions
and
8 deletions
extmod/modmachine.c
+
8
−
8
View file @
278f3592
...
...
@@ -40,8 +40,8 @@
#if MICROPY_PY_MACHINE
STATIC
mp_
uint_t
get_addr
(
mp_obj_t
addr_o
,
uint
align
)
{
mp_
uint_t
addr
=
mp_obj_int_get_truncated
(
addr_o
);
STATIC
uint
ptr
_t
get_addr
(
mp_obj_t
addr_o
,
uint
align
)
{
uint
ptr
_t
addr
=
mp_obj_int_get_truncated
(
addr_o
);
if
((
addr
&
(
align
-
1
))
!=
0
)
{
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_ValueError
,
"address %08x is not aligned to %d bytes"
,
addr
,
align
));
}
...
...
@@ -49,8 +49,8 @@ STATIC mp_uint_t get_addr(mp_obj_t addr_o, uint align) {
{
// Not thread-safe
static
int
fd
;
static
mp_
uint_t
last_base
=
(
mp_
uint_t
)
-
1
;
static
mp_
uint_t
map_page
;
static
uint
ptr
_t
last_base
=
(
uint
ptr
_t
)
-
1
;
static
uint
ptr
_t
map_page
;
if
(
!
fd
)
{
fd
=
open
(
"/dev/mem"
,
O_RDWR
|
O_SYNC
);
if
(
fd
==
-
1
)
{
...
...
@@ -58,9 +58,9 @@ STATIC mp_uint_t get_addr(mp_obj_t addr_o, uint align) {
}
}
mp_
uint_t
cur_base
=
addr
&
~
MICROPY_PAGE_MASK
;
uint
ptr
_t
cur_base
=
addr
&
~
MICROPY_PAGE_MASK
;
if
(
cur_base
!=
last_base
)
{
map_page
=
(
mp_
uint_t
)
mmap
(
NULL
,
MICROPY_PAGE_SIZE
,
PROT_READ
|
PROT_WRITE
,
MAP_SHARED
,
fd
,
cur_base
);
map_page
=
(
uint
ptr
_t
)
mmap
(
NULL
,
MICROPY_PAGE_SIZE
,
PROT_READ
|
PROT_WRITE
,
MAP_SHARED
,
fd
,
cur_base
);
last_base
=
cur_base
;
}
addr
=
map_page
+
(
addr
&
MICROPY_PAGE_MASK
);
...
...
@@ -89,7 +89,7 @@ STATIC mp_obj_t machine_mem_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t va
return
MP_OBJ_NULL
;
// op not supported
}
else
if
(
value
==
MP_OBJ_SENTINEL
)
{
// load
mp_
uint_t
addr
=
get_addr
(
index
,
self
->
elem_size
);
uint
ptr
_t
addr
=
get_addr
(
index
,
self
->
elem_size
);
uint32_t
val
;
switch
(
self
->
elem_size
)
{
case
1
:
val
=
(
*
(
uint8_t
*
)
addr
);
break
;
...
...
@@ -99,7 +99,7 @@ STATIC mp_obj_t machine_mem_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t va
return
mp_obj_new_int
(
val
);
}
else
{
// store
mp_
uint_t
addr
=
get_addr
(
index
,
self
->
elem_size
);
uint
ptr
_t
addr
=
get_addr
(
index
,
self
->
elem_size
);
uint32_t
val
=
mp_obj_get_int
(
value
);
switch
(
self
->
elem_size
)
{
case
1
:
(
*
(
uint8_t
*
)
addr
)
=
val
;
break
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment