Skip to content

Commit

Permalink
esp8266: small tweaks to moving jswsyms to flash
Browse files Browse the repository at this point in the history
  • Loading branch information
tve committed Apr 17, 2016
1 parent 30aae54 commit 2c3f6f7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions scripts/build_jswrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def codeOutBuiltins(indent, builtin):
extern int os_printf_plus();
JsVar *jswBinarySearch(const JswSymList *symbolsPtr, JsVar *parent, const char *name) {
//os_printf_plus("bs%p\\n", symbolsPtr);
//os_printf_plus("bs%p %s\\n", symbolsPtr, name);
int searchMin = 0;
int searchMax = symbolsPtr->symbolCount -1;
while (searchMin <= searchMax) {
Expand All @@ -282,7 +282,7 @@ def codeOutBuiltins(indent, builtin):
//os_printf_plus("CMP %s %s = %d\\n", name, buf, cmp);
if (cmp==0) {
unsigned short functionSpec = READ_FLASH_UINT16(&sym->functionSpec);
os_printf_plus("%s found %p: %p %x\\n", name, sym, sym->functionPtr, functionSpec);
//os_printf_plus("%s found %p: %p %x\\n", name, sym, sym->functionPtr, functionSpec);
if ((functionSpec & JSWAT_EXECUTE_IMMEDIATELY_MASK) == JSWAT_EXECUTE_IMMEDIATELY)
return jsnCallFunction(sym->functionPtr, functionSpec, parent, 0, 0);
return jsvNewNativeFunction(sym->functionPtr, functionSpec);
Expand All @@ -296,7 +296,7 @@ def codeOutBuiltins(indent, builtin):
}
}
}
os_printf_plus("%s not found\\n", name);
//os_printf_plus("%s not found\\n", name);
return 0;
}
#endif
Expand Down
3 changes: 2 additions & 1 deletion src/jsutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,12 @@ int flash_strcmp(const char *mem, const char *flash);
On ESP8266 you have to read flash in 32 bit chunks, so force a 32 bit read
and extract just the 8 bits we want */
#define READ_FLASH_UINT8(ptr) ({ uint32_t __p = (uint32_t)(char*)(ptr); volatile uint32_t __d = *(uint32_t*)(__p & (uint32_t)~3); ((uint8_t*)&__d)[__p & 3]; })

/** Read a uint16_t from this pointer, which could be in RAM or Flash. */
#define READ_FLASH_UINT16(ptr) (READ_FLASH_UINT8(ptr) | (READ_FLASH_UINT8(((char*)ptr)+1)<<8) )

/** Read a uint16_t from this pointer, assumes that the target is 16-bit aligned. */
#define READ_FLASH_UINT16(ptr) ({ uint32_t __p = (uint32_t)(ptr); volatile uint32_t __d = *(uint32_t*)(__p & (uint32_t)~3); (uint16_t)(__p&2 ? __d>>16 : __d); })
//#define READ_FLASH_UINT16(ptr) ({ uint32_t __p = (uint32_t)(ptr); volatile uint32_t __d = *(uint32_t*)(__p & (uint32_t)~3); (uint16_t)(__p&2 ? __d>>16 : __d); })

#else

Expand Down

0 comments on commit 2c3f6f7

Please sign in to comment.