[GitHub] [incubator-nuttx] Ouss4 commented on pull request #980: Improve proxy/stub parameter passing for variadic OS interfaces.
Ouss4 commented on pull request #980: URL: https://github.com/apache/incubator-nuttx/pull/980#issuecomment-624373493 @xiaoxiang781216 I merged this but I figured that maybe you'd want to take a look since you and Greg had some conversation about this in an earlier PR. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] patacongo opened a new pull request #981: syscall/README.txt: Describe new sycall.csv extensions.
patacongo opened a new pull request #981: URL: https://github.com/apache/incubator-nuttx/pull/981 ## Summary Provides documentation of recent extensions to the format of the syscall/sycall.csv file. ## Impact Improved documentation ## Testing Not applicable. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] btashton commented on pull request #970: K210 pll
btashton commented on pull request #970: URL: https://github.com/apache/incubator-nuttx/pull/970#issuecomment-624374759 I think this looks good. And on the licensing side should be fine long as we keep the original header in place. https://www.apache.org/legal/src-headers.html#3party This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx-apps] xiaoxiang781216 commented on pull request #231: Hdc1008
xiaoxiang781216 commented on pull request #231: URL: https://github.com/apache/incubator-nuttx-apps/pull/231#issuecomment-624409713 If something get wrong, create a new branch, cherry-pick and rebase the change again. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx-apps] xiaoxiang781216 edited a comment on pull request #231: Hdc1008
xiaoxiang781216 edited a comment on pull request #231: URL: https://github.com/apache/incubator-nuttx-apps/pull/231#issuecomment-624409713 If something get wrong, create a new branch, cherry-pick and rebase the change again. Don't worry, nothing can be lost after you commit. you can even find the lost change by "git reflog". This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] sonicyang commented on pull request #979: PCI-E support with x86_64/qemu example
sonicyang commented on pull request #979: URL: https://github.com/apache/incubator-nuttx/pull/979#issuecomment-624415804 @patacongo @btashton I will try to force push it, but where should I rebase to? About the licensing problem, if we have another implementation, it will be great. Let's first find a way to cooperate. The affected files are the `driver/pcie` and `board/` files. Not all of them were copied, though. I tried to rewrite most of them based on the same logic. I should be able to identify those and make a list. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] sonicyang commented on pull request #979: PCI-E support with x86_64/qemu example
sonicyang commented on pull request #979: URL: https://github.com/apache/incubator-nuttx/pull/979#issuecomment-624420616 The affected list * pre-processor definitions * pci_find_cap() * qemu_pci_enumerate() * qemu_pci_msix_register() * qemu_pci_msi_register() * Whole qemu_pcie_readwrite.h file * driver/virt/qemu_pci_test.c has a structure definition taken from qemu documentation. I can do a full rewrite, but I doubt those has a totally different implementation though. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] sonicyang commented on pull request #979: PCI-E support with x86_64/qemu example
sonicyang commented on pull request #979: URL: https://github.com/apache/incubator-nuttx/pull/979#issuecomment-624422211 Oh, good. It's running now. I did some cosmetic changes. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx-testing] liuguo09 commented on a change in pull request #42: Some cibuild.sh improvements
liuguo09 commented on a change in pull request #42: URL: https://github.com/apache/incubator-nuttx-testing/pull/42#discussion_r420532197 ## File path: cibuild.sh ## @@ -48,6 +48,14 @@ function python-tools { PYTHONUSERBASE=$prebuilt/pylocal export PYTHONUSERBASE add_path $PYTHONUSERBASE/bin + case $os in +Darwin) + PIP=pip3 Review comment: The latest apache nightly build server build break without pip3 installed : ( ./cibuild.sh: line 214: pip3: command not found This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx-testing] btashton commented on a change in pull request #42: Some cibuild.sh improvements
btashton commented on a change in pull request #42: URL: https://github.com/apache/incubator-nuttx-testing/pull/42#discussion_r420533197 ## File path: cibuild.sh ## @@ -48,6 +48,14 @@ function python-tools { PYTHONUSERBASE=$prebuilt/pylocal export PYTHONUSERBASE add_path $PYTHONUSERBASE/bin + case $os in +Darwin) + PIP=pip3 Review comment: I wonder if they have python3 installed at all (we should since python 2 is EOL). We could try |python3 -m pip` for pip3. Do we have any information on what the build machine is built with? This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx-apps] iceaway opened a new pull request #233: Example application for the hdc1008 driver.
iceaway opened a new pull request #233: URL: https://github.com/apache/incubator-nuttx-apps/pull/233 ## Summary New version of the hdc1008 pull request with the not-so-messed-up history. ## Impact ## Testing This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx-apps] iceaway commented on pull request #231: Hdc1008
iceaway commented on pull request #231: URL: https://github.com/apache/incubator-nuttx-apps/pull/231#issuecomment-624430651 Go ahead and close this one, I opened up a new pull request. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx-testing] btashton commented on a change in pull request #42: Some cibuild.sh improvements
btashton commented on a change in pull request #42: URL: https://github.com/apache/incubator-nuttx-testing/pull/42#discussion_r420534263 ## File path: cibuild.sh ## @@ -48,6 +48,14 @@ function python-tools { PYTHONUSERBASE=$prebuilt/pylocal export PYTHONUSERBASE add_path $PYTHONUSERBASE/bin + case $os in +Darwin) + PIP=pip3 Review comment: I see that it would be fairly trivial to have it use our docker container to the build if that would be easier for us to maintain This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] btashton commented on pull request #974: x86_64: Jailhouse support
btashton commented on pull request #974: URL: https://github.com/apache/incubator-nuttx/pull/974#issuecomment-624439132 @sonicyang I think I got fairly far through setting up jailhouse, but I am afraid I am a little lost. I created the jailhouse environment via https://github.com/siemens/jailhouse-images which was fine and when I start qemu I am able to run the demo applications in cells no problem. I built nuttx with the flag to turn off multiboot2 and the acpi config flags you added and also turned on raw bin output. When I try to load `nuttx.bin` into the cell it fails ``` root@demo~# jailhouse cell load tiny-demo nuttx.bin JAILHOUSE_CELL_LOAD: invalid argument ``` Also which cell config were you using? This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] sonicyang commented on pull request #974: x86_64: Jailhouse support
sonicyang commented on pull request #974: URL: https://github.com/apache/incubator-nuttx/pull/974#issuecomment-624439927 @sonicyang The memory address and PIO regions might not be properly configured . I am using a custom config. Let me fire up my test machine and paste as a gist first. Should it be included in this patch? This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] sonicyang edited a comment on pull request #974: x86_64: Jailhouse support
sonicyang edited a comment on pull request #974: URL: https://github.com/apache/incubator-nuttx/pull/974#issuecomment-624439927 @btashton The memory address and PIO regions might not be properly configured . I am using a custom config. Let me fire up my test machine and paste as a gist first. Should it be included in this patch? This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] btashton commented on pull request #974: x86_64: Jailhouse support
btashton commented on pull request #974: URL: https://github.com/apache/incubator-nuttx/pull/974#issuecomment-624441004 We can put it in a follow on patch with a defconfig and a readme (happy to document my setup since I am new to it). This is really cool and I want to explore it more some time. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] sonicyang commented on pull request #974: x86_64: Jailhouse support
sonicyang commented on pull request #974: URL: https://github.com/apache/incubator-nuttx/pull/974#issuecomment-624442896 @btashton Good, because I always works on a real host machine. Willing to see some one test it out on a qemu+Jailhouse environment. Here is my config: https://gist.github.com/sonicyang/6503b9607e82cd92400f71f278823dd6 Some points: 1. I allocated a quite large memory block for Nuttx 2. You should adjust the low memory physical address according to your root-cell config, find a piece of large and reserved memory for it. 3. For your reference, I created my root config with: ``` sudo jailhouse config create -c ttyS1 --mem-hv 128M --mem-inmates 1536M sysconfig.c ``` This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] sonicyang commented on pull request #974: x86_64: Jailhouse support
sonicyang commented on pull request #974: URL: https://github.com/apache/incubator-nuttx/pull/974#issuecomment-624457184 @btashton Seems like PR #944 breaks my bootstrap code. I am fixing this at the moment. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx-apps] xiaoxiang781216 commented on pull request #233: Example application for the hdc1008 driver.
xiaoxiang781216 commented on pull request #233: URL: https://github.com/apache/incubator-nuttx-apps/pull/233#issuecomment-624457962 So should we close this one: https://github.com/apache/incubator-nuttx-apps/pull/231? This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx-apps] iceaway commented on pull request #233: Example application for the hdc1008 driver.
iceaway commented on pull request #233: URL: https://github.com/apache/incubator-nuttx-apps/pull/233#issuecomment-624460489 > So should we close this one: #231? Yes, please do. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a change in pull request #980: Improve proxy/stub parameter passing for variadic OS interfaces.
xiaoxiang781216 commented on a change in pull request #980: URL: https://github.com/apache/incubator-nuttx/pull/980#discussion_r420512107 ## File path: syscall/syscall.csv ## @@ -41,7 +41,7 @@ "if_indextoname","net/if.h","defined(CONFIG_NETDEV_IFINDEX)","FAR char *","unsigned int","FAR char *" "if_nametoindex","net/if.h","defined(CONFIG_NETDEV_IFINDEX)","unsigned int","FAR const char *" "insmod","nuttx/module.h","defined(CONFIG_MODULE)","FAR void *","FAR const char *","FAR const char *" -"ioctl","sys/ioctl.h","","int","int","int","..." +"ioctl","sys/ioctl.h","","int","int","int","...","unsigned int" Review comment: should be unsigned long This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] xiaoxiang781216 commented on pull request #980: Improve proxy/stub parameter passing for variadic OS interfaces.
xiaoxiang781216 commented on pull request #980: URL: https://github.com/apache/incubator-nuttx/pull/980#issuecomment-624473576 > @xiaoxiang781216 I merged this but I figured that maybe you'd want to take a look since you and Greg had some conversation about this in an earlier PR. I found several issues, will provide PR later. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx-testing] liuguo09 commented on a change in pull request #42: Some cibuild.sh improvements
liuguo09 commented on a change in pull request #42: URL: https://github.com/apache/incubator-nuttx-testing/pull/42#discussion_r420590308 ## File path: cibuild.sh ## @@ -48,6 +48,14 @@ function python-tools { PYTHONUSERBASE=$prebuilt/pylocal export PYTHONUSERBASE add_path $PYTHONUSERBASE/bin + case $os in +Darwin) + PIP=pip3 Review comment: Just issue a jira to ask infra team to help: https://issues.apache.org/jira/browse/INFRA-20237. There is still parallel build issue which could only be reproduced in apache build server with more powerful cpus. Once it's fixed, I think use github docker container to run the nightly build would be good. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx-testing] btashton commented on a change in pull request #42: Some cibuild.sh improvements
btashton commented on a change in pull request #42: URL: https://github.com/apache/incubator-nuttx-testing/pull/42#discussion_r420600770 ## File path: cibuild.sh ## @@ -48,6 +48,14 @@ function python-tools { PYTHONUSERBASE=$prebuilt/pylocal export PYTHONUSERBASE add_path $PYTHONUSERBASE/bin + case $os in +Darwin) + PIP=pip3 Review comment: I'm not suggesting removing it, I'm just saying I can change the Jenkins config to run the container instead. It would still run the parallel job we just would have better control of the software on the host. I don't have a strong opinion just wanted people to know it is an option This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] btashton commented on pull request #974: x86_64: Jailhouse support
btashton commented on pull request #974: URL: https://github.com/apache/incubator-nuttx/pull/974#issuecomment-624495400 I was not able to get my jailroot environment working correctly tonight (kept getting MMIO and PIO crashes unrelated to NuttX). I'll try it again another time, in the meantime once you have that bootstrap fix (sorry my fix broke this) ready I'll be happy to merge this in. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] btashton edited a comment on pull request #974: x86_64: Jailhouse support
btashton edited a comment on pull request #974: URL: https://github.com/apache/incubator-nuttx/pull/974#issuecomment-624495400 I was not able to get my jailhouse environment working correctly tonight (kept getting MMIO and PIO crashes unrelated to NuttX). I'll try it again another time, in the meantime once you have that bootstrap fix (sorry my fix broke this) ready I'll be happy to merge this in. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] sonicyang commented on issue #955: x86_64 ostest mqueue_test failing
sonicyang commented on issue #955: URL: https://github.com/apache/incubator-nuttx/issues/955#issuecomment-624497058 @btashton I am also getting this. I will try look into it. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] sonicyang commented on issue #955: x86_64 ostest mqueue_test failing
sonicyang commented on issue #955: URL: https://github.com/apache/incubator-nuttx/issues/955#issuecomment-624498061 Well, actually a bit different, mine only appears when set `CONFIG_DEBUG_ASSERTIONS=yes` It fails with a assert fail in semaphore holder management, during message queue test. Something related to signaling I think. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] sonicyang commented on issue #955: x86_64 ostest mqueue_test failing
sonicyang commented on issue #955: URL: https://github.com/apache/incubator-nuttx/issues/955#issuecomment-624501090 Now I am getting another assertion fail at ``` [ 53.749589] up_assert: Assertion failed at file:sched/sched_waitpid.c line: 419 task: init ``` This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] sonicyang opened a new pull request #982: arch: x86_64: remove leftover debug output
sonicyang opened a new pull request #982: URL: https://github.com/apache/incubator-nuttx/pull/982 ## Summary Remove a potential source of race condition in x86_64 up_sigdeliver. I left a piece of debug output in the up_sigdeliver function during porting. ## Impact No more race condition around multiple signals. ## Testing Ostest and nsh of x86_64 qemu port should work as normally without the removed verbose output message during signal handling. However, these still being affected by Issue #955 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx-testing] liuguo09 commented on a change in pull request #42: Some cibuild.sh improvements
liuguo09 commented on a change in pull request #42: URL: https://github.com/apache/incubator-nuttx-testing/pull/42#discussion_r420629105 ## File path: cibuild.sh ## @@ -48,6 +48,14 @@ function python-tools { PYTHONUSERBASE=$prebuilt/pylocal export PYTHONUSERBASE add_path $PYTHONUSERBASE/bin + case $os in +Darwin) + PIP=pip3 Review comment: @btashton Sorry for my misunderstanding. Glad to hear that you could help to change Jenkins config to run the contianer. There used to be several times asking for infra team to install new tools in need. This could make it more easy to maintain. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] sonicyang commented on pull request #974: x86_64: Jailhouse support
sonicyang commented on pull request #974: URL: https://github.com/apache/incubator-nuttx/pull/974#issuecomment-624523205 @btashton Here is the patch. Nan, that not your fault. I did this patch while you were fixing the 4M -> 1M issue. I should have check and found out this issue when I rebased. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] baoxiaowei-xiaomi commented on a change in pull request #979: PCI-E support with x86_64/qemu example
baoxiaowei-xiaomi commented on a change in pull request #979: URL: https://github.com/apache/incubator-nuttx/pull/979#discussion_r420644572 ## File path: drivers/pcie/pcie_root.c ## @@ -0,0 +1,358 @@ +/ + * nuttx/drivers/pcie/pcie_root.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + / + +/ + * Included Files + / + +#include + +#include +#include +#include + +#include +#include + +/ + * Pre-processor Definitions + / + +/ + * Public Data + / + +struct pcie_dev_type_s *pci_device_types[] = +{ +#ifdef CONFIG_VIRT_QEMU_PCI_TEST + &pcie_type_qemu_pci_test, +#endif /* CONFIG_VIRT_QEMU_PCI_TEST */ + NULL, +}; + +/ + * Public Functions + / + +/ + * Name: pcie_initialize + * + * Description: + * Initialize the PCI-E bus and enumerate the devices with give devices + * type array + * + * Input Parameters: + * bus- An PCIE bus + * types - A array of PCIE device types + * num- Number of device types + * + * Returned Value: + * OK if the driver was successfully register; A negated errno value is + * returned on any failure. + * + / + +int pcie_initialize(FAR struct pcie_bus_s *bus) +{ + return bus->ops->pcie_enumerate(bus, pci_device_types); +} + +/ + * Name: pci_enable_device + * + * Description: + * Enable device with flags + * + * Input Parameters: + * bdf - device BDF + * flags - device ability to be enabled + * + * Return value: + * -EINVAL: error + * OK: OK + * + / + +int pci_enable_device(FAR struct pcie_dev_s *dev, uint32_t flags) +{ Review comment: I think we don't need the flags parameter, as my understand, enable PCIe device is do the MEM access enable, so set this bit in this function is OK. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] baoxiaowei-xiaomi commented on a change in pull request #979: PCI-E support with x86_64/qemu example
baoxiaowei-xiaomi commented on a change in pull request #979: URL: https://github.com/apache/incubator-nuttx/pull/979#discussion_r420646115 ## File path: drivers/pcie/pcie_root.c ## @@ -0,0 +1,358 @@ +/ + * nuttx/drivers/pcie/pcie_root.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + / + +/ + * Included Files + / + +#include + +#include +#include +#include + +#include +#include + +/ + * Pre-processor Definitions + / + +/ + * Public Data + / + +struct pcie_dev_type_s *pci_device_types[] = +{ +#ifdef CONFIG_VIRT_QEMU_PCI_TEST + &pcie_type_qemu_pci_test, +#endif /* CONFIG_VIRT_QEMU_PCI_TEST */ + NULL, +}; + +/ + * Public Functions + / + +/ + * Name: pcie_initialize + * + * Description: + * Initialize the PCI-E bus and enumerate the devices with give devices + * type array + * + * Input Parameters: + * bus- An PCIE bus + * types - A array of PCIE device types + * num- Number of device types + * + * Returned Value: + * OK if the driver was successfully register; A negated errno value is + * returned on any failure. + * + / + +int pcie_initialize(FAR struct pcie_bus_s *bus) +{ + return bus->ops->pcie_enumerate(bus, pci_device_types); +} + +/ + * Name: pci_enable_device + * + * Description: + * Enable device with flags + * + * Input Parameters: + * bdf - device BDF + * flags - device ability to be enabled + * + * Return value: + * -EINVAL: error + * OK: OK + * + / + +int pci_enable_device(FAR struct pcie_dev_s *dev, uint32_t flags) +{ + uint16_t old_cmd; + uint16_t cmd; + + dev->bus->ops->pci_cfg_read(dev, PCI_CFG_COMMAND, &old_cmd, 2); + + cmd = old_cmd | flags; + + dev->bus->ops->pci_cfg_write(dev, PCI_CFG_COMMAND, &cmd, 2); + + pciinfo("%02x:%02x.%x, CMD: %x -> %x\n", + dev->bdf >> 8, (dev->bdf >> 3) & 0x1f, dev->bdf & 0x3, + old_cmd, cmd); + + return OK; +} + +/ + * Name: pci_find_cap + * + * Description: + * Search through the PCI-e device capability list to find given capability. + * + * Input Parameters: + * dev - Device + * cap - Bitmask of capability + * + * Returned Value: + * -1: Capability not supported + * other: the offset in PCI configuration space to the capability structure + * + / + +int pci_find_cap(FAR struct pcie_dev_s *dev, uint16_t cap) +{ + uint8_t pos = PCI_CFG_CAP_PTR - 1; + uint16_t status; + uint8_t rcap; + + dev->bus->ops->pci_cfg_read(dev, PCI_CFG_STATUS, &status, 2); + + if (!(status & PCI_STS_CAPS)) + return -EINVAL; + + while (1) +{ + dev->bus->ops->pci_cfg_read(dev, pos + 1, &pos, 1); + if (pos == 0) + return -EINVAL; + + dev->bus->ops->pci_cfg_read(dev, pos, &rcap, 1); + + if (rcap == cap) + return pos; +} +} + +/ + * Name: pci_get_bar + * + * Description: + * Get a 32 bits bar + * + * Input Parameters: + * dev- Device private data + * bar- Bar number + * ret- Bar Content + * + * Returned
[GitHub] [incubator-nuttx] baoxiaowei-xiaomi commented on a change in pull request #979: PCI-E support with x86_64/qemu example
baoxiaowei-xiaomi commented on a change in pull request #979: URL: https://github.com/apache/incubator-nuttx/pull/979#discussion_r420647360 ## File path: drivers/pcie/pcie_root.c ## @@ -0,0 +1,358 @@ +/ + * nuttx/drivers/pcie/pcie_root.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + / + +/ + * Included Files + / + +#include + +#include +#include +#include + +#include +#include + +/ + * Pre-processor Definitions + / + +/ + * Public Data + / + +struct pcie_dev_type_s *pci_device_types[] = +{ +#ifdef CONFIG_VIRT_QEMU_PCI_TEST + &pcie_type_qemu_pci_test, +#endif /* CONFIG_VIRT_QEMU_PCI_TEST */ + NULL, +}; + +/ + * Public Functions + / + +/ + * Name: pcie_initialize + * + * Description: + * Initialize the PCI-E bus and enumerate the devices with give devices + * type array + * + * Input Parameters: + * bus- An PCIE bus + * types - A array of PCIE device types + * num- Number of device types + * + * Returned Value: + * OK if the driver was successfully register; A negated errno value is + * returned on any failure. + * + / + +int pcie_initialize(FAR struct pcie_bus_s *bus) +{ + return bus->ops->pcie_enumerate(bus, pci_device_types); +} + +/ + * Name: pci_enable_device + * + * Description: + * Enable device with flags + * + * Input Parameters: + * bdf - device BDF + * flags - device ability to be enabled + * + * Return value: + * -EINVAL: error + * OK: OK + * + / + +int pci_enable_device(FAR struct pcie_dev_s *dev, uint32_t flags) +{ + uint16_t old_cmd; + uint16_t cmd; + + dev->bus->ops->pci_cfg_read(dev, PCI_CFG_COMMAND, &old_cmd, 2); + + cmd = old_cmd | flags; + + dev->bus->ops->pci_cfg_write(dev, PCI_CFG_COMMAND, &cmd, 2); + + pciinfo("%02x:%02x.%x, CMD: %x -> %x\n", + dev->bdf >> 8, (dev->bdf >> 3) & 0x1f, dev->bdf & 0x3, + old_cmd, cmd); + + return OK; +} + +/ + * Name: pci_find_cap + * + * Description: + * Search through the PCI-e device capability list to find given capability. + * + * Input Parameters: + * dev - Device + * cap - Bitmask of capability + * + * Returned Value: + * -1: Capability not supported + * other: the offset in PCI configuration space to the capability structure + * + / + +int pci_find_cap(FAR struct pcie_dev_s *dev, uint16_t cap) +{ + uint8_t pos = PCI_CFG_CAP_PTR - 1; + uint16_t status; + uint8_t rcap; + + dev->bus->ops->pci_cfg_read(dev, PCI_CFG_STATUS, &status, 2); + + if (!(status & PCI_STS_CAPS)) + return -EINVAL; + + while (1) +{ + dev->bus->ops->pci_cfg_read(dev, pos + 1, &pos, 1); + if (pos == 0) + return -EINVAL; + + dev->bus->ops->pci_cfg_read(dev, pos, &rcap, 1); + + if (rcap == cap) + return pos; +} +} + +/ + * Name: pci_get_bar + * + * Description: + * Get a 32 bits bar + * + * Input Parameters: + * dev- Device private data + * bar- Bar number + * ret- Bar Content + * + * Returned
[GitHub] [incubator-nuttx] sonicyang commented on a change in pull request #979: PCI-E support with x86_64/qemu example
sonicyang commented on a change in pull request #979: URL: https://github.com/apache/incubator-nuttx/pull/979#discussion_r420648077 ## File path: drivers/pcie/pcie_root.c ## @@ -0,0 +1,358 @@ +/ + * nuttx/drivers/pcie/pcie_root.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + / + +/ + * Included Files + / + +#include + +#include +#include +#include + +#include +#include + +/ + * Pre-processor Definitions + / + +/ + * Public Data + / + +struct pcie_dev_type_s *pci_device_types[] = +{ +#ifdef CONFIG_VIRT_QEMU_PCI_TEST + &pcie_type_qemu_pci_test, +#endif /* CONFIG_VIRT_QEMU_PCI_TEST */ + NULL, +}; + +/ + * Public Functions + / + +/ + * Name: pcie_initialize + * + * Description: + * Initialize the PCI-E bus and enumerate the devices with give devices + * type array + * + * Input Parameters: + * bus- An PCIE bus + * types - A array of PCIE device types + * num- Number of device types + * + * Returned Value: + * OK if the driver was successfully register; A negated errno value is + * returned on any failure. + * + / + +int pcie_initialize(FAR struct pcie_bus_s *bus) +{ + return bus->ops->pcie_enumerate(bus, pci_device_types); +} + +/ + * Name: pci_enable_device + * + * Description: + * Enable device with flags + * + * Input Parameters: + * bdf - device BDF + * flags - device ability to be enabled + * + * Return value: + * -EINVAL: error + * OK: OK + * + / + +int pci_enable_device(FAR struct pcie_dev_s *dev, uint32_t flags) +{ + uint16_t old_cmd; + uint16_t cmd; + + dev->bus->ops->pci_cfg_read(dev, PCI_CFG_COMMAND, &old_cmd, 2); + + cmd = old_cmd | flags; + + dev->bus->ops->pci_cfg_write(dev, PCI_CFG_COMMAND, &cmd, 2); + + pciinfo("%02x:%02x.%x, CMD: %x -> %x\n", + dev->bdf >> 8, (dev->bdf >> 3) & 0x1f, dev->bdf & 0x3, + old_cmd, cmd); + + return OK; +} + +/ + * Name: pci_find_cap + * + * Description: + * Search through the PCI-e device capability list to find given capability. + * + * Input Parameters: + * dev - Device + * cap - Bitmask of capability + * + * Returned Value: + * -1: Capability not supported + * other: the offset in PCI configuration space to the capability structure + * + / + +int pci_find_cap(FAR struct pcie_dev_s *dev, uint16_t cap) +{ + uint8_t pos = PCI_CFG_CAP_PTR - 1; + uint16_t status; + uint8_t rcap; + + dev->bus->ops->pci_cfg_read(dev, PCI_CFG_STATUS, &status, 2); + + if (!(status & PCI_STS_CAPS)) + return -EINVAL; + + while (1) +{ + dev->bus->ops->pci_cfg_read(dev, pos + 1, &pos, 1); + if (pos == 0) + return -EINVAL; + + dev->bus->ops->pci_cfg_read(dev, pos, &rcap, 1); + + if (rcap == cap) + return pos; +} +} + +/ + * Name: pci_get_bar + * + * Description: + * Get a 32 bits bar + * + * Input Parameters: + * dev- Device private data + * bar- Bar number + * ret- Bar Content + * + * Returned Value:
[GitHub] [incubator-nuttx] sonicyang commented on a change in pull request #979: PCI-E support with x86_64/qemu example
sonicyang commented on a change in pull request #979: URL: https://github.com/apache/incubator-nuttx/pull/979#discussion_r420648865 ## File path: drivers/pcie/pcie_root.c ## @@ -0,0 +1,358 @@ +/ + * nuttx/drivers/pcie/pcie_root.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + / + +/ + * Included Files + / + +#include + +#include +#include +#include + +#include +#include + +/ + * Pre-processor Definitions + / + +/ + * Public Data + / + +struct pcie_dev_type_s *pci_device_types[] = +{ +#ifdef CONFIG_VIRT_QEMU_PCI_TEST + &pcie_type_qemu_pci_test, +#endif /* CONFIG_VIRT_QEMU_PCI_TEST */ + NULL, +}; + +/ + * Public Functions + / + +/ + * Name: pcie_initialize + * + * Description: + * Initialize the PCI-E bus and enumerate the devices with give devices + * type array + * + * Input Parameters: + * bus- An PCIE bus + * types - A array of PCIE device types + * num- Number of device types + * + * Returned Value: + * OK if the driver was successfully register; A negated errno value is + * returned on any failure. + * + / + +int pcie_initialize(FAR struct pcie_bus_s *bus) +{ + return bus->ops->pcie_enumerate(bus, pci_device_types); +} + +/ + * Name: pci_enable_device + * + * Description: + * Enable device with flags + * + * Input Parameters: + * bdf - device BDF + * flags - device ability to be enabled + * + * Return value: + * -EINVAL: error + * OK: OK + * + / + +int pci_enable_device(FAR struct pcie_dev_s *dev, uint32_t flags) +{ Review comment: I agree, patching now. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] baoxiaowei-xiaomi commented on a change in pull request #979: PCI-E support with x86_64/qemu example
baoxiaowei-xiaomi commented on a change in pull request #979: URL: https://github.com/apache/incubator-nuttx/pull/979#discussion_r420652375 ## File path: boards/x86_64/intel64/qemu-intel64/src/qemu_pcie_readwrite.h ## @@ -0,0 +1,229 @@ +/ + * boards/x86_64/intel64/qemu-intel64/src/qemu_pcie_readwrite.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + / + +/* The PCI-E Definitions and part of the access routines are taken from + * Jailhouse inmate library + * + * Jailhouse, a Linux-based partitioning hypervisor + * + * Copyright (c) Siemens AG, 2014 + * + * Authors: + * Jan Kiszka + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + * Alternatively, you can use or redistribute this file under the following + * BSD license: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __INCLUDE_NUTTX_PCIE_PCIE_READWRITE_H +#define __INCLUDE_NUTTX_PCIE_PCIE_READWRITE_H + +/ + * Included Files + / + +#include + +#include + +#include + +#include +#include +#include + +#include "up_arch.h" +#include "up_internal.h" + +/ + * Pre-processor Definitions + / + +#define PCI_REG_ADDR_PORT 0xcf8 +#define PCI_REG_DATA_PORT 0xcfc + +#define PCI_CONE(1 << 31) + +/ + * Name: __qemu_pci_cfg_write + * + * Description: + * Write 8, 16, 32 bits data to PCI-E configuration space of device + * specified by dev + * + * Input Parameters: + * bfd- Device private data + * buffer - A pointer to the read-only buffer of data to be written + * size - The number of bytes to send from the buffer + * + * Returned Value: + * 0: success, <0: A negated errno + * + / + +static inline int __qemu_pci_cfg_write(uint16_t bfd, uintptr_t addr, + FAR const void *buffer, + unsigned int size) +{ Review comment: this is X86 IO mode, yes? This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] baoxiaowei-xiaomi commented on a change in pull request #979: PCI-E support with x86_64/qemu example
baoxiaowei-xiaomi commented on a change in pull request #979: URL: https://github.com/apache/incubator-nuttx/pull/979#discussion_r420663754 ## File path: boards/x86_64/intel64/qemu-intel64/src/qemu_pcie.c ## @@ -0,0 +1,461 @@ +/ + * boards/x86_64/intel64/qemu-intel64/src/qemu_pcie.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + / + +/* The MSI and MSI-X vector setup function are taken from Jailhouse inmate + * library + * + * Jailhouse, a Linux-based partitioning hypervisor + * + * Copyright (c) Siemens AG, 2014 + * + * Authors: + * Jan Kiszka + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + * Alternatively, you can use or redistribute this file under the following + * BSD license: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/ + * Included Files + / + +#include + +#include + +#include + +#include "qemu_pcie_readwrite.h" + +/ + * Pre-processor Definitions + / + +#define QEMU_PCIE_MAX_BDF 0x1 + +/ + * Private Functions Definitions + / + +static int qemu_pci_enumerate(FAR struct pcie_bus_s *bus, + FAR struct pcie_dev_type_s **types); + +static int qemu_pci_cfg_write(FAR struct pcie_dev_s *dev, uintptr_t addr, + FAR const void *buffer, unsigned int size); + +static int qemu_pci_cfg_read(FAR struct pcie_dev_s *dev, uintptr_t addr, + FAR void *buffer, unsigned int size); + +static int qemu_pci_map_bar(FAR struct pcie_dev_s *dev, uint32_t addr, +unsigned long length); + +static int qemu_pci_map_bar64(FAR struct pcie_dev_s *dev, uint64_t addr, + unsigned long length); + +static int qemu_pci_msix_register(FAR struct pcie_dev_s *dev, + uint32_t vector, uint32_t index); + +static int qemu_pci_msi_register(FAR struct pcie_dev_s *dev, + uint16_t vector); + +/ + * Public Data + / + +struct pcie_bus_ops_s qemu_pcie_bus_ops = +{ +.pcie_enumerate= qemu_pci_enumerate, +.pci_cfg_write = qemu_pci_cfg_write, +.
[GitHub] [incubator-nuttx] baoxiaowei-xiaomi commented on a change in pull request #979: PCI-E support with x86_64/qemu example
baoxiaowei-xiaomi commented on a change in pull request #979: URL: https://github.com/apache/incubator-nuttx/pull/979#discussion_r420663754 ## File path: boards/x86_64/intel64/qemu-intel64/src/qemu_pcie.c ## @@ -0,0 +1,461 @@ +/ + * boards/x86_64/intel64/qemu-intel64/src/qemu_pcie.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + / + +/* The MSI and MSI-X vector setup function are taken from Jailhouse inmate + * library + * + * Jailhouse, a Linux-based partitioning hypervisor + * + * Copyright (c) Siemens AG, 2014 + * + * Authors: + * Jan Kiszka + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + * Alternatively, you can use or redistribute this file under the following + * BSD license: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/ + * Included Files + / + +#include + +#include + +#include + +#include "qemu_pcie_readwrite.h" + +/ + * Pre-processor Definitions + / + +#define QEMU_PCIE_MAX_BDF 0x1 + +/ + * Private Functions Definitions + / + +static int qemu_pci_enumerate(FAR struct pcie_bus_s *bus, + FAR struct pcie_dev_type_s **types); + +static int qemu_pci_cfg_write(FAR struct pcie_dev_s *dev, uintptr_t addr, + FAR const void *buffer, unsigned int size); + +static int qemu_pci_cfg_read(FAR struct pcie_dev_s *dev, uintptr_t addr, + FAR void *buffer, unsigned int size); + +static int qemu_pci_map_bar(FAR struct pcie_dev_s *dev, uint32_t addr, +unsigned long length); + +static int qemu_pci_map_bar64(FAR struct pcie_dev_s *dev, uint64_t addr, + unsigned long length); + +static int qemu_pci_msix_register(FAR struct pcie_dev_s *dev, + uint32_t vector, uint32_t index); + +static int qemu_pci_msi_register(FAR struct pcie_dev_s *dev, + uint16_t vector); + +/ + * Public Data + / + +struct pcie_bus_ops_s qemu_pcie_bus_ops = +{ +.pcie_enumerate= qemu_pci_enumerate, +.pci_cfg_write = qemu_pci_cfg_write, +.
[GitHub] [incubator-nuttx] baoxiaowei-xiaomi commented on a change in pull request #979: PCI-E support with x86_64/qemu example
baoxiaowei-xiaomi commented on a change in pull request #979: URL: https://github.com/apache/incubator-nuttx/pull/979#discussion_r420670706 ## File path: boards/x86_64/intel64/qemu-intel64/src/qemu_pcie_readwrite.h ## @@ -0,0 +1,229 @@ +/ + * boards/x86_64/intel64/qemu-intel64/src/qemu_pcie_readwrite.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + / + +/* The PCI-E Definitions and part of the access routines are taken from + * Jailhouse inmate library + * + * Jailhouse, a Linux-based partitioning hypervisor + * + * Copyright (c) Siemens AG, 2014 + * + * Authors: + * Jan Kiszka + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + * Alternatively, you can use or redistribute this file under the following + * BSD license: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __INCLUDE_NUTTX_PCIE_PCIE_READWRITE_H +#define __INCLUDE_NUTTX_PCIE_PCIE_READWRITE_H + +/ + * Included Files + / + +#include + +#include + +#include + +#include +#include Review comment: why add the uart_16550.h, for printing? This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] sonicyang commented on a change in pull request #979: PCI-E support with x86_64/qemu example
sonicyang commented on a change in pull request #979: URL: https://github.com/apache/incubator-nuttx/pull/979#discussion_r420673764 ## File path: boards/x86_64/intel64/qemu-intel64/src/qemu_pcie.c ## @@ -0,0 +1,461 @@ +/ + * boards/x86_64/intel64/qemu-intel64/src/qemu_pcie.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + / + +/* The MSI and MSI-X vector setup function are taken from Jailhouse inmate + * library + * + * Jailhouse, a Linux-based partitioning hypervisor + * + * Copyright (c) Siemens AG, 2014 + * + * Authors: + * Jan Kiszka + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + * Alternatively, you can use or redistribute this file under the following + * BSD license: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/ + * Included Files + / + +#include + +#include + +#include + +#include "qemu_pcie_readwrite.h" + +/ + * Pre-processor Definitions + / + +#define QEMU_PCIE_MAX_BDF 0x1 + +/ + * Private Functions Definitions + / + +static int qemu_pci_enumerate(FAR struct pcie_bus_s *bus, + FAR struct pcie_dev_type_s **types); + +static int qemu_pci_cfg_write(FAR struct pcie_dev_s *dev, uintptr_t addr, + FAR const void *buffer, unsigned int size); + +static int qemu_pci_cfg_read(FAR struct pcie_dev_s *dev, uintptr_t addr, + FAR void *buffer, unsigned int size); + +static int qemu_pci_map_bar(FAR struct pcie_dev_s *dev, uint32_t addr, +unsigned long length); + +static int qemu_pci_map_bar64(FAR struct pcie_dev_s *dev, uint64_t addr, + unsigned long length); + +static int qemu_pci_msix_register(FAR struct pcie_dev_s *dev, + uint32_t vector, uint32_t index); + +static int qemu_pci_msi_register(FAR struct pcie_dev_s *dev, + uint16_t vector); + +/ + * Public Data + / + +struct pcie_bus_ops_s qemu_pcie_bus_ops = +{ +.pcie_enumerate= qemu_pci_enumerate, +.pci_cfg_write = qemu_pci_cfg_write, +.pci_cfg_
[GitHub] [incubator-nuttx] sonicyang commented on a change in pull request #979: PCI-E support with x86_64/qemu example
sonicyang commented on a change in pull request #979: URL: https://github.com/apache/incubator-nuttx/pull/979#discussion_r420674125 ## File path: boards/x86_64/intel64/qemu-intel64/src/qemu_pcie_readwrite.h ## @@ -0,0 +1,229 @@ +/ + * boards/x86_64/intel64/qemu-intel64/src/qemu_pcie_readwrite.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + / + +/* The PCI-E Definitions and part of the access routines are taken from + * Jailhouse inmate library + * + * Jailhouse, a Linux-based partitioning hypervisor + * + * Copyright (c) Siemens AG, 2014 + * + * Authors: + * Jan Kiszka + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + * Alternatively, you can use or redistribute this file under the following + * BSD license: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __INCLUDE_NUTTX_PCIE_PCIE_READWRITE_H +#define __INCLUDE_NUTTX_PCIE_PCIE_READWRITE_H + +/ + * Included Files + / + +#include + +#include + +#include + +#include +#include Review comment: By accident, I will remove it. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] baoxiaowei-xiaomi commented on a change in pull request #979: PCI-E support with x86_64/qemu example
baoxiaowei-xiaomi commented on a change in pull request #979: URL: https://github.com/apache/incubator-nuttx/pull/979#discussion_r420652375 ## File path: boards/x86_64/intel64/qemu-intel64/src/qemu_pcie_readwrite.h ## @@ -0,0 +1,229 @@ +/ + * boards/x86_64/intel64/qemu-intel64/src/qemu_pcie_readwrite.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + / + +/* The PCI-E Definitions and part of the access routines are taken from + * Jailhouse inmate library + * + * Jailhouse, a Linux-based partitioning hypervisor + * + * Copyright (c) Siemens AG, 2014 + * + * Authors: + * Jan Kiszka + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + * Alternatively, you can use or redistribute this file under the following + * BSD license: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __INCLUDE_NUTTX_PCIE_PCIE_READWRITE_H +#define __INCLUDE_NUTTX_PCIE_PCIE_READWRITE_H + +/ + * Included Files + / + +#include + +#include + +#include + +#include +#include +#include + +#include "up_arch.h" +#include "up_internal.h" + +/ + * Pre-processor Definitions + / + +#define PCI_REG_ADDR_PORT 0xcf8 +#define PCI_REG_DATA_PORT 0xcfc + +#define PCI_CONE(1 << 31) + +/ + * Name: __qemu_pci_cfg_write + * + * Description: + * Write 8, 16, 32 bits data to PCI-E configuration space of device + * specified by dev + * + * Input Parameters: + * bfd- Device private data + * buffer - A pointer to the read-only buffer of data to be written + * size - The number of bytes to send from the buffer + * + * Returned Value: + * 0: success, <0: A negated errno + * + / + +static inline int __qemu_pci_cfg_write(uint16_t bfd, uintptr_t addr, + FAR const void *buffer, + unsigned int size) +{ Review comment: this is X86 IO mode, yes? I think we'd better to judge the buffer whether is NULL. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.or
[GitHub] [incubator-nuttx] sonicyang commented on a change in pull request #979: PCI-E support with x86_64/qemu example
sonicyang commented on a change in pull request #979: URL: https://github.com/apache/incubator-nuttx/pull/979#discussion_r420674458 ## File path: boards/x86_64/intel64/qemu-intel64/src/qemu_pcie_readwrite.h ## @@ -0,0 +1,229 @@ +/ + * boards/x86_64/intel64/qemu-intel64/src/qemu_pcie_readwrite.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + / + +/* The PCI-E Definitions and part of the access routines are taken from + * Jailhouse inmate library + * + * Jailhouse, a Linux-based partitioning hypervisor + * + * Copyright (c) Siemens AG, 2014 + * + * Authors: + * Jan Kiszka + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + * Alternatively, you can use or redistribute this file under the following + * BSD license: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __INCLUDE_NUTTX_PCIE_PCIE_READWRITE_H +#define __INCLUDE_NUTTX_PCIE_PCIE_READWRITE_H + +/ + * Included Files + / + +#include + +#include + +#include + +#include +#include +#include + +#include "up_arch.h" +#include "up_internal.h" + +/ + * Pre-processor Definitions + / + +#define PCI_REG_ADDR_PORT 0xcf8 +#define PCI_REG_DATA_PORT 0xcfc + +#define PCI_CONE(1 << 31) + +/ + * Name: __qemu_pci_cfg_write + * + * Description: + * Write 8, 16, 32 bits data to PCI-E configuration space of device + * specified by dev + * + * Input Parameters: + * bfd- Device private data + * buffer - A pointer to the read-only buffer of data to be written + * size - The number of bytes to send from the buffer + * + * Returned Value: + * 0: success, <0: A negated errno + * + / + +static inline int __qemu_pci_cfg_write(uint16_t bfd, uintptr_t addr, + FAR const void *buffer, + unsigned int size) +{ Review comment: What do you mean IO mode? Is it IO mode access to PCI configuration space? If so, then yes. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.ap
[GitHub] [incubator-nuttx] baoxiaowei-xiaomi commented on a change in pull request #979: PCI-E support with x86_64/qemu example
baoxiaowei-xiaomi commented on a change in pull request #979: URL: https://github.com/apache/incubator-nuttx/pull/979#discussion_r420678056 ## File path: boards/x86_64/intel64/qemu-intel64/src/qemu_pcie_readwrite.h ## @@ -0,0 +1,229 @@ +/ + * boards/x86_64/intel64/qemu-intel64/src/qemu_pcie_readwrite.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + / + +/* The PCI-E Definitions and part of the access routines are taken from + * Jailhouse inmate library + * + * Jailhouse, a Linux-based partitioning hypervisor + * + * Copyright (c) Siemens AG, 2014 + * + * Authors: + * Jan Kiszka + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + * Alternatively, you can use or redistribute this file under the following + * BSD license: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __INCLUDE_NUTTX_PCIE_PCIE_READWRITE_H +#define __INCLUDE_NUTTX_PCIE_PCIE_READWRITE_H + +/ + * Included Files + / + +#include + +#include + +#include + +#include +#include +#include + +#include "up_arch.h" +#include "up_internal.h" + +/ + * Pre-processor Definitions + / + +#define PCI_REG_ADDR_PORT 0xcf8 +#define PCI_REG_DATA_PORT 0xcfc + +#define PCI_CONE(1 << 31) + +/ + * Name: __qemu_pci_cfg_write + * + * Description: + * Write 8, 16, 32 bits data to PCI-E configuration space of device + * specified by dev + * + * Input Parameters: + * bfd- Device private data + * buffer - A pointer to the read-only buffer of data to be written + * size - The number of bytes to send from the buffer + * + * Returned Value: + * 0: success, <0: A negated errno + * + / + +static inline int __qemu_pci_cfg_write(uint16_t bfd, uintptr_t addr, + FAR const void *buffer, + unsigned int size) +{ Review comment: Yes, I mean that, do we need to judge the buffer whether is NULL? This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] baoxiaowei-xiaomi commented on a change in pull request #979: PCI-E support with x86_64/qemu example
baoxiaowei-xiaomi commented on a change in pull request #979: URL: https://github.com/apache/incubator-nuttx/pull/979#discussion_r420679740 ## File path: boards/x86_64/intel64/qemu-intel64/src/qemu_pcie.c ## @@ -0,0 +1,461 @@ +/ + * boards/x86_64/intel64/qemu-intel64/src/qemu_pcie.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + / + +/* The MSI and MSI-X vector setup function are taken from Jailhouse inmate + * library + * + * Jailhouse, a Linux-based partitioning hypervisor + * + * Copyright (c) Siemens AG, 2014 + * + * Authors: + * Jan Kiszka + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + * Alternatively, you can use or redistribute this file under the following + * BSD license: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/ + * Included Files + / + +#include + +#include + +#include + +#include "qemu_pcie_readwrite.h" + +/ + * Pre-processor Definitions + / + +#define QEMU_PCIE_MAX_BDF 0x1 + +/ + * Private Functions Definitions + / + +static int qemu_pci_enumerate(FAR struct pcie_bus_s *bus, + FAR struct pcie_dev_type_s **types); + +static int qemu_pci_cfg_write(FAR struct pcie_dev_s *dev, uintptr_t addr, + FAR const void *buffer, unsigned int size); + +static int qemu_pci_cfg_read(FAR struct pcie_dev_s *dev, uintptr_t addr, + FAR void *buffer, unsigned int size); + +static int qemu_pci_map_bar(FAR struct pcie_dev_s *dev, uint32_t addr, +unsigned long length); + +static int qemu_pci_map_bar64(FAR struct pcie_dev_s *dev, uint64_t addr, + unsigned long length); + +static int qemu_pci_msix_register(FAR struct pcie_dev_s *dev, + uint32_t vector, uint32_t index); + +static int qemu_pci_msi_register(FAR struct pcie_dev_s *dev, + uint16_t vector); + +/ + * Public Data + / + +struct pcie_bus_ops_s qemu_pcie_bus_ops = +{ +.pcie_enumerate= qemu_pci_enumerate, +.pci_cfg_write = qemu_pci_cfg_write, +.
[GitHub] [incubator-nuttx] sonicyang commented on a change in pull request #979: PCI-E support with x86_64/qemu example
sonicyang commented on a change in pull request #979: URL: https://github.com/apache/incubator-nuttx/pull/979#discussion_r420707924 ## File path: boards/x86_64/intel64/qemu-intel64/src/qemu_pcie.c ## @@ -0,0 +1,461 @@ +/ + * boards/x86_64/intel64/qemu-intel64/src/qemu_pcie.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + / + +/* The MSI and MSI-X vector setup function are taken from Jailhouse inmate + * library + * + * Jailhouse, a Linux-based partitioning hypervisor + * + * Copyright (c) Siemens AG, 2014 + * + * Authors: + * Jan Kiszka + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + * Alternatively, you can use or redistribute this file under the following + * BSD license: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/ + * Included Files + / + +#include + +#include + +#include + +#include "qemu_pcie_readwrite.h" + +/ + * Pre-processor Definitions + / + +#define QEMU_PCIE_MAX_BDF 0x1 + +/ + * Private Functions Definitions + / + +static int qemu_pci_enumerate(FAR struct pcie_bus_s *bus, + FAR struct pcie_dev_type_s **types); + +static int qemu_pci_cfg_write(FAR struct pcie_dev_s *dev, uintptr_t addr, + FAR const void *buffer, unsigned int size); + +static int qemu_pci_cfg_read(FAR struct pcie_dev_s *dev, uintptr_t addr, + FAR void *buffer, unsigned int size); + +static int qemu_pci_map_bar(FAR struct pcie_dev_s *dev, uint32_t addr, +unsigned long length); + +static int qemu_pci_map_bar64(FAR struct pcie_dev_s *dev, uint64_t addr, + unsigned long length); + +static int qemu_pci_msix_register(FAR struct pcie_dev_s *dev, + uint32_t vector, uint32_t index); + +static int qemu_pci_msi_register(FAR struct pcie_dev_s *dev, + uint16_t vector); + +/ + * Public Data + / + +struct pcie_bus_ops_s qemu_pcie_bus_ops = +{ +.pcie_enumerate= qemu_pci_enumerate, +.pci_cfg_write = qemu_pci_cfg_write, +.pci_cfg_
[GitHub] [incubator-nuttx] sonicyang commented on a change in pull request #979: PCI-E support with x86_64/qemu example
sonicyang commented on a change in pull request #979: URL: https://github.com/apache/incubator-nuttx/pull/979#discussion_r420708159 ## File path: boards/x86_64/intel64/qemu-intel64/src/qemu_pcie_readwrite.h ## @@ -0,0 +1,229 @@ +/ + * boards/x86_64/intel64/qemu-intel64/src/qemu_pcie_readwrite.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + / + +/* The PCI-E Definitions and part of the access routines are taken from + * Jailhouse inmate library + * + * Jailhouse, a Linux-based partitioning hypervisor + * + * Copyright (c) Siemens AG, 2014 + * + * Authors: + * Jan Kiszka + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + * Alternatively, you can use or redistribute this file under the following + * BSD license: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __INCLUDE_NUTTX_PCIE_PCIE_READWRITE_H +#define __INCLUDE_NUTTX_PCIE_PCIE_READWRITE_H + +/ + * Included Files + / + +#include + +#include + +#include + +#include +#include +#include + +#include "up_arch.h" +#include "up_internal.h" + +/ + * Pre-processor Definitions + / + +#define PCI_REG_ADDR_PORT 0xcf8 +#define PCI_REG_DATA_PORT 0xcfc + +#define PCI_CONE(1 << 31) + +/ + * Name: __qemu_pci_cfg_write + * + * Description: + * Write 8, 16, 32 bits data to PCI-E configuration space of device + * specified by dev + * + * Input Parameters: + * bfd- Device private data + * buffer - A pointer to the read-only buffer of data to be written + * size - The number of bytes to send from the buffer + * + * Returned Value: + * 0: success, <0: A negated errno + * + / + +static inline int __qemu_pci_cfg_write(uint16_t bfd, uintptr_t addr, + FAR const void *buffer, + unsigned int size) +{ Review comment: That's a good idea, will do. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] baoxiaowei-xiaomi commented on a change in pull request #979: PCI-E support with x86_64/qemu example
baoxiaowei-xiaomi commented on a change in pull request #979: URL: https://github.com/apache/incubator-nuttx/pull/979#discussion_r420713285 ## File path: boards/x86_64/intel64/qemu-intel64/src/qemu_pcie.c ## @@ -0,0 +1,467 @@ +/ + * boards/x86_64/intel64/qemu-intel64/src/qemu_pcie.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + / + +/* The MSI and MSI-X vector setup function are taken from Jailhouse inmate + * library + * + * Jailhouse, a Linux-based partitioning hypervisor + * + * Copyright (c) Siemens AG, 2014 + * + * Authors: + * Jan Kiszka + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + * Alternatively, you can use or redistribute this file under the following + * BSD license: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/ + * Included Files + / + +#include + +#include + +#include + +#include "qemu_pcie_readwrite.h" + +/ + * Pre-processor Definitions + / + +#define QEMU_PCIE_MAX_BDF 0x1 + +/ + * Private Functions Definitions + / + +static int qemu_pci_enumerate(FAR struct pcie_bus_s *bus, + FAR struct pcie_dev_type_s **types); + +static int qemu_pci_cfg_write(FAR struct pcie_dev_s *dev, uintptr_t addr, + FAR const void *buffer, unsigned int size); + +static int qemu_pci_cfg_read(FAR struct pcie_dev_s *dev, uintptr_t addr, + FAR void *buffer, unsigned int size); + +static int qemu_pci_map_bar(FAR struct pcie_dev_s *dev, uint32_t addr, +unsigned long length); + +static int qemu_pci_map_bar64(FAR struct pcie_dev_s *dev, uint64_t addr, + unsigned long length); + +static int qemu_pci_msix_register(FAR struct pcie_dev_s *dev, + uint32_t vector, uint32_t index); + +static int qemu_pci_msi_register(FAR struct pcie_dev_s *dev, + uint16_t vector); + +/ + * Public Data + / + +struct pcie_bus_ops_s qemu_pcie_bus_ops = +{ +.pcie_enumerate= qemu_pci_enumerate, +.pci_cfg_write = qemu_pci_cfg_write, +.
[GitHub] [incubator-nuttx] sonicyang commented on pull request #979: PCI-E support with x86_64/qemu example
sonicyang commented on pull request #979: URL: https://github.com/apache/incubator-nuttx/pull/979#issuecomment-624588711 I need suggestion on this, should we use pci or pcie as the function prefix? I am kind of mixing these 2 at the moment, but I want to unify it. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] baoxiaowei-xiaomi commented on a change in pull request #979: PCI-E support with x86_64/qemu example
baoxiaowei-xiaomi commented on a change in pull request #979: URL: https://github.com/apache/incubator-nuttx/pull/979#discussion_r420716597 ## File path: drivers/pcie/pcie_root.c ## @@ -0,0 +1,358 @@ +/ + * nuttx/drivers/pcie/pcie_root.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + / + +/ + * Included Files + / + +#include + +#include +#include +#include + +#include +#include + +/ + * Pre-processor Definitions + / + +/ + * Public Data + / + +struct pcie_dev_type_s *pci_device_types[] = +{ +#ifdef CONFIG_VIRT_QEMU_PCI_TEST + &pcie_type_qemu_pci_test, +#endif /* CONFIG_VIRT_QEMU_PCI_TEST */ + NULL, +}; + +/ + * Public Functions + / + +/ + * Name: pcie_initialize + * + * Description: + * Initialize the PCI-E bus and enumerate the devices with give devices + * type array + * + * Input Parameters: + * bus- An PCIE bus + * types - A array of PCIE device types + * num- Number of device types + * + * Returned Value: + * OK if the driver was successfully register; A negated errno value is + * returned on any failure. + * + / + +int pcie_initialize(FAR struct pcie_bus_s *bus) +{ + return bus->ops->pcie_enumerate(bus, pci_device_types); +} + +/ + * Name: pci_enable_device + * + * Description: + * Enable device with flags + * + * Input Parameters: + * bdf - device BDF + * flags - device ability to be enabled + * + * Return value: + * -EINVAL: error + * OK: OK + * + / + +int pci_enable_device(FAR struct pcie_dev_s *dev, uint32_t flags) +{ + uint16_t old_cmd; + uint16_t cmd; + + dev->bus->ops->pci_cfg_read(dev, PCI_CFG_COMMAND, &old_cmd, 2); + + cmd = old_cmd | flags; + + dev->bus->ops->pci_cfg_write(dev, PCI_CFG_COMMAND, &cmd, 2); + + pciinfo("%02x:%02x.%x, CMD: %x -> %x\n", + dev->bdf >> 8, (dev->bdf >> 3) & 0x1f, dev->bdf & 0x3, + old_cmd, cmd); + + return OK; +} + +/ + * Name: pci_find_cap + * + * Description: + * Search through the PCI-e device capability list to find given capability. + * + * Input Parameters: + * dev - Device + * cap - Bitmask of capability + * + * Returned Value: + * -1: Capability not supported + * other: the offset in PCI configuration space to the capability structure + * + / + +int pci_find_cap(FAR struct pcie_dev_s *dev, uint16_t cap) +{ + uint8_t pos = PCI_CFG_CAP_PTR - 1; + uint16_t status; + uint8_t rcap; + + dev->bus->ops->pci_cfg_read(dev, PCI_CFG_STATUS, &status, 2); + + if (!(status & PCI_STS_CAPS)) + return -EINVAL; + + while (1) +{ + dev->bus->ops->pci_cfg_read(dev, pos + 1, &pos, 1); + if (pos == 0) + return -EINVAL; + + dev->bus->ops->pci_cfg_read(dev, pos, &rcap, 1); + + if (rcap == cap) + return pos; +} +} + +/ + * Name: pci_get_bar + * + * Description: + * Get a 32 bits bar + * + * Input Parameters: + * dev- Device private data + * bar- Bar number + * ret- Bar Content + * + * Returned
[GitHub] [incubator-nuttx] baoxiaowei-xiaomi commented on a change in pull request #979: PCI-E support with x86_64/qemu example
baoxiaowei-xiaomi commented on a change in pull request #979: URL: https://github.com/apache/incubator-nuttx/pull/979#discussion_r420743727 ## File path: drivers/pcie/pcie_root.c ## @@ -0,0 +1,446 @@ +/ + * nuttx/drivers/pcie/pcie_root.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + / + +/ + * Included Files + / + +#include + +#include +#include +#include + +#include +#include + +/ + * Pre-processor Definitions + / + +/ + * Public Data + / + +struct pcie_dev_type_s *pci_device_types[] = +{ +#ifdef CONFIG_VIRT_QEMU_PCI_TEST + &pcie_type_qemu_pci_test, +#endif /* CONFIG_VIRT_QEMU_PCI_TEST */ + NULL, +}; + +/ + * Public Functions + / + +/ + * Name: pci_enumerate + * + * Description: + * Scan the PCI bus and enumerate the devices. + * Initialize any recognized devices, given in types. + * + * Input Parameters: + * bus- PCI-E bus structure + * type - List of pointers to devices types recognized, NULL terminated + * + * Returned Value: + * 0: success, <0: A negated errno + * + / + +int pci_enumerate(FAR struct pcie_bus_s *bus, + FAR struct pcie_dev_type_s **types) +{ + unsigned int bdf; + uint16_t vid; + uint16_t id; + uint16_t rev; + struct pcie_dev_s tmp_dev; + struct pcie_dev_type_s tmp_type = +{ + .name = "Unknown", + .vendor = PCI_ID_ANY, + .device = PCI_ID_ANY, + .class_rev = PCI_ID_ANY, + .probe = NULL, +}; + + if (!bus) + return -EINVAL; + if (!types) + return -EINVAL; + + for (bdf = 0; bdf < CONFIG_PCIE_MAX_BDF; bdf++) +{ + tmp_dev.bus = bus; + tmp_dev.type = &tmp_type; + tmp_dev.bdf = bdf; + + bus->ops->pci_cfg_read(&tmp_dev, PCI_CFG_VENDOR_ID, &vid, 2); + bus->ops->pci_cfg_read(&tmp_dev, PCI_CFG_DEVICE_ID, &id, 2); + bus->ops->pci_cfg_read(&tmp_dev, PCI_CFG_REVERSION, &rev, 2); + + if (vid == PCI_ID_ANY) +continue; + + pciinfo("[%02x:%02x.%x] Found %04x:%04x, class/reversion %08x\n", + bdf >> 8, (bdf >> 3) & 0x1f, bdf & 0x3, + vid, id, rev); + + for (int i = 0; types[i] != NULL; i++) +{ + if (types[i]->vendor == PCI_ID_ANY || + types[i]->vendor == vid) +{ + if (types[i]->device == PCI_ID_ANY || + types[i]->device == id) +{ + if (types[i]->class_rev == PCI_ID_ANY || + types[i]->class_rev == rev) +{ + if (types[i]->probe) +{ + pciinfo("[%02x:%02x.%x] %s\n", + bdf >> 8, (bdf >> 3) & 0x1f, bdf & 0x3, + types[i]->name); + types[i]->probe(bus, types[i], bdf); +} + else +{ + pcierr("[%02x:%02x.%x] Error: Invalid \ + device probe function\n", + bdf >> 8, (bdf >> 3) & 0x1f, bdf & 0x3); +} + break; +} +} +} +} +} + + return OK; +} + +/
[GitHub] [incubator-nuttx-apps] xiaoxiang781216 opened a new pull request #234: Move usrsock_rpmsg from system to netutils folder
xiaoxiang781216 opened a new pull request #234: URL: https://github.com/apache/incubator-nuttx-apps/pull/234 This is a more suitable location Signed-off-by: Xiang Xiao ## Summary ## Impact ## Testing This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] xiaoxiang781216 opened a new pull request #983: board/sim: Change CONFIG_SYSTEM_USRSOCK_RPMSG to CONFIG_NETUTILS_USRS…
xiaoxiang781216 opened a new pull request #983: URL: https://github.com/apache/incubator-nuttx/pull/983 …OCK_RPMSG follow up the apps side change Signed-off-by: Xiang Xiao ## Summary Need work with https://github.com/apache/incubator-nuttx-apps/pull/234 ## Impact ## Testing This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] patacongo commented on pull request #980: Improve proxy/stub parameter passing for variadic OS interfaces.
patacongo commented on pull request #980: URL: https://github.com/apache/incubator-nuttx/pull/980#issuecomment-624651919 > I found several issues, will provide PR later. I have plenty of free time today. If you want to give me the list of issues, I will do the PR. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] patacongo edited a comment on pull request #980: Improve proxy/stub parameter passing for variadic OS interfaces.
patacongo edited a comment on pull request #980: URL: https://github.com/apache/incubator-nuttx/pull/980#issuecomment-624651919 > I found several issues, will provide PR later. @xiaoxiang781216 I have plenty of free time today. If you want to give me the list of issues, I will do the PR. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] patacongo opened a new pull request #984: syscall/syscall.csv: Corect type for ioctl parameter
patacongo opened a new pull request #984: URL: https://github.com/apache/incubator-nuttx/pull/984 ## Summary Variable argument should be of type unsigned long, not unsigned int. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] xiaoxiang781216 commented on pull request #980: Improve proxy/stub parameter passing for variadic OS interfaces.
xiaoxiang781216 commented on pull request #980: URL: https://github.com/apache/incubator-nuttx/pull/980#issuecomment-624671493 I am preparing the patch, will submit soon. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] patacongo commented on pull request #983: board/sim: Change CONFIG_SYSTEM_USRSOCK_RPMSG to CONFIG_NETUTILS_USRS…
patacongo commented on pull request #983: URL: https://github.com/apache/incubator-nuttx/pull/983#issuecomment-624678272 @xiaoxiang781216 This probably won't build without https://github.com/apache/incubator-nuttx-apps/pull/234 and that 234 probably depends on this change too. How do you propose to get past the PR checks? This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] xiaoxiang781216 commented on pull request #983: board/sim: Change CONFIG_SYSTEM_USRSOCK_RPMSG to CONFIG_NETUTILS_USRS…
xiaoxiang781216 commented on pull request #983: URL: https://github.com/apache/incubator-nuttx/pull/983#issuecomment-624694407 > @xiaoxiang781216 This probably won't build without [apache/incubator-nuttx-apps#234](https://github.com/apache/incubator-nuttx-apps/pull/234) and that 234 probably depends on this change too. How do you propose to get past the PR checks? Since @btashton action improvement isn't ready yet, we have to review the change carefully and merge the patch and monitor what happen:(. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] xiaoxiang781216 edited a comment on pull request #983: board/sim: Change CONFIG_SYSTEM_USRSOCK_RPMSG to CONFIG_NETUTILS_USRS…
xiaoxiang781216 edited a comment on pull request #983: URL: https://github.com/apache/incubator-nuttx/pull/983#issuecomment-624694407 > @xiaoxiang781216 This probably won't build without [apache/incubator-nuttx-apps#234](https://github.com/apache/incubator-nuttx-apps/pull/234) and that 234 probably depends on this change too. How do you propose to get past the PR checks? Since @btashton action improvement isn't ready yet, we have to review the change carefully and merge the patch and monitor what happen:(. And since the kernel side change is very minor, it's better to merge this PR first and rerun the check on apps side. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] xiaoxiang781216 edited a comment on pull request #983: board/sim: Change CONFIG_SYSTEM_USRSOCK_RPMSG to CONFIG_NETUTILS_USRS…
xiaoxiang781216 edited a comment on pull request #983: URL: https://github.com/apache/incubator-nuttx/pull/983#issuecomment-624694407 > @xiaoxiang781216 This probably won't build without [apache/incubator-nuttx-apps#234](https://github.com/apache/incubator-nuttx-apps/pull/234) and that 234 probably depends on this change too. How do you propose to get past the PR checks? Since @btashton action improvement isn't ready yet, we have to review the change carefully and merge the patch and monitor what happen:(. And since the kernel side change is very minor, it's better to merge this PR and rerun the check on apps side. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx-apps] patacongo commented on pull request #234: Move usrsock_rpmsg from system to netutils folder
patacongo commented on pull request #234: URL: https://github.com/apache/incubator-nuttx-apps/pull/234#issuecomment-624701167 @xiaoxiang781216 Merging because needed by matching nuttx/ PR. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] patacongo commented on pull request #983: board/sim: Change CONFIG_SYSTEM_USRSOCK_RPMSG to CONFIG_NETUTILS_USRS…
patacongo commented on pull request #983: URL: https://github.com/apache/incubator-nuttx/pull/983#issuecomment-624701358 @xiaoxiang781216 Okay.. I will do the merge and we can. If there is breakage after the merge, then we just need to repair as soon as possible. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] sonicyang commented on a change in pull request #979: PCI-E support with x86_64/qemu example
sonicyang commented on a change in pull request #979: URL: https://github.com/apache/incubator-nuttx/pull/979#discussion_r420867067 ## File path: drivers/pcie/pcie_root.c ## @@ -0,0 +1,446 @@ +/ + * nuttx/drivers/pcie/pcie_root.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + / + +/ + * Included Files + / + +#include + +#include +#include +#include + +#include +#include + +/ + * Pre-processor Definitions + / + +/ + * Public Data + / + +struct pcie_dev_type_s *pci_device_types[] = +{ +#ifdef CONFIG_VIRT_QEMU_PCI_TEST + &pcie_type_qemu_pci_test, +#endif /* CONFIG_VIRT_QEMU_PCI_TEST */ + NULL, +}; + +/ + * Public Functions + / + +/ + * Name: pci_enumerate + * + * Description: + * Scan the PCI bus and enumerate the devices. + * Initialize any recognized devices, given in types. + * + * Input Parameters: + * bus- PCI-E bus structure + * type - List of pointers to devices types recognized, NULL terminated + * + * Returned Value: + * 0: success, <0: A negated errno + * + / + +int pci_enumerate(FAR struct pcie_bus_s *bus, + FAR struct pcie_dev_type_s **types) +{ + unsigned int bdf; + uint16_t vid; + uint16_t id; + uint16_t rev; + struct pcie_dev_s tmp_dev; + struct pcie_dev_type_s tmp_type = +{ + .name = "Unknown", + .vendor = PCI_ID_ANY, + .device = PCI_ID_ANY, + .class_rev = PCI_ID_ANY, + .probe = NULL, +}; + + if (!bus) + return -EINVAL; + if (!types) + return -EINVAL; + + for (bdf = 0; bdf < CONFIG_PCIE_MAX_BDF; bdf++) +{ + tmp_dev.bus = bus; + tmp_dev.type = &tmp_type; + tmp_dev.bdf = bdf; + + bus->ops->pci_cfg_read(&tmp_dev, PCI_CFG_VENDOR_ID, &vid, 2); + bus->ops->pci_cfg_read(&tmp_dev, PCI_CFG_DEVICE_ID, &id, 2); + bus->ops->pci_cfg_read(&tmp_dev, PCI_CFG_REVERSION, &rev, 2); + + if (vid == PCI_ID_ANY) +continue; + + pciinfo("[%02x:%02x.%x] Found %04x:%04x, class/reversion %08x\n", + bdf >> 8, (bdf >> 3) & 0x1f, bdf & 0x3, + vid, id, rev); + + for (int i = 0; types[i] != NULL; i++) +{ + if (types[i]->vendor == PCI_ID_ANY || + types[i]->vendor == vid) +{ + if (types[i]->device == PCI_ID_ANY || + types[i]->device == id) +{ + if (types[i]->class_rev == PCI_ID_ANY || + types[i]->class_rev == rev) +{ + if (types[i]->probe) +{ + pciinfo("[%02x:%02x.%x] %s\n", + bdf >> 8, (bdf >> 3) & 0x1f, bdf & 0x3, + types[i]->name); + types[i]->probe(bus, types[i], bdf); +} + else +{ + pcierr("[%02x:%02x.%x] Error: Invalid \ + device probe function\n", + bdf >> 8, (bdf >> 3) & 0x1f, bdf & 0x3); +} + break; +} +} +} +} +} + + return OK; +} + +/ + *
[GitHub] [incubator-nuttx] sonicyang commented on a change in pull request #979: PCI-E support with x86_64/qemu example
sonicyang commented on a change in pull request #979: URL: https://github.com/apache/incubator-nuttx/pull/979#discussion_r420867515 ## File path: boards/x86_64/intel64/qemu-intel64/src/qemu_pcie.c ## @@ -0,0 +1,467 @@ +/ + * boards/x86_64/intel64/qemu-intel64/src/qemu_pcie.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + / + +/* The MSI and MSI-X vector setup function are taken from Jailhouse inmate + * library + * + * Jailhouse, a Linux-based partitioning hypervisor + * + * Copyright (c) Siemens AG, 2014 + * + * Authors: + * Jan Kiszka + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + * Alternatively, you can use or redistribute this file under the following + * BSD license: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/ + * Included Files + / + +#include + +#include + +#include + +#include "qemu_pcie_readwrite.h" + +/ + * Pre-processor Definitions + / + +#define QEMU_PCIE_MAX_BDF 0x1 + +/ + * Private Functions Definitions + / + +static int qemu_pci_enumerate(FAR struct pcie_bus_s *bus, + FAR struct pcie_dev_type_s **types); + +static int qemu_pci_cfg_write(FAR struct pcie_dev_s *dev, uintptr_t addr, + FAR const void *buffer, unsigned int size); + +static int qemu_pci_cfg_read(FAR struct pcie_dev_s *dev, uintptr_t addr, + FAR void *buffer, unsigned int size); + +static int qemu_pci_map_bar(FAR struct pcie_dev_s *dev, uint32_t addr, +unsigned long length); + +static int qemu_pci_map_bar64(FAR struct pcie_dev_s *dev, uint64_t addr, + unsigned long length); + +static int qemu_pci_msix_register(FAR struct pcie_dev_s *dev, + uint32_t vector, uint32_t index); + +static int qemu_pci_msi_register(FAR struct pcie_dev_s *dev, + uint16_t vector); + +/ + * Public Data + / + +struct pcie_bus_ops_s qemu_pcie_bus_ops = +{ +.pcie_enumerate= qemu_pci_enumerate, +.pci_cfg_write = qemu_pci_cfg_write, +.pci_cfg_
[GitHub] [incubator-nuttx] xiaoxiang781216 opened a new pull request #985: syslog: Code outside libc shouldn't call nx_vsyslog directly
xiaoxiang781216 opened a new pull request #985: URL: https://github.com/apache/incubator-nuttx/pull/985 ## Summary since nx_vsyslog is the implementation detail ## Impact ## Testing This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] patacongo opened a new issue #986: Userspace errno
patacongo opened a new issue #986: URL: https://github.com/apache/incubator-nuttx/issues/986 ## Background The user errno value is currently kept in the TCB and can be accesses via an OS system call called `__errno()`. # define errno *__errno() The errno valud is kept in the thread's TCB in the `pterrno` field. The _`_errno() `function finds the TCB associated with the thread and returns a pointer to the errno storage location. This works in the FLAT build mode in because it dereferences the address of the errno in TCB as both an RVALUE: errcode == errno; And as an LVALUE: errno = errode; That works, however, it is rather inefficient. However, that will not work at all in the PROTECTED or KERNEL build modes because the memory holding the TCB is protected and cannot be directly accessed from the user mode application. Instead, it is accessed through accessor functions: void set_errno(int errcode); int get_errno(void); Accessing the errno via these functions in PROTECTED or KERNEL mode is a huge performance hit, because the calles must go system call which is implemented as a software interrupt. And in this case, the errno is defined to be: # define errno get_errno() This works fine as an RVALUE: errcode == errno; But will cause a compilation error if used as an LVALUE: errno = errode; ## TLS The proposed solution is to move the errno storage location out of the proctected TCB memory and into the unprotected application thread stack memory. Then it can be access with the appropriate TLS (Thread Local Storage) interfaces. NOTE: The errno value must still be retained in the TCB because it is also used for other purpose, such as informing sem_wait() that it was awakened by a a signal. ## What has been done? Historically, TLS works by aligning the stack base address then simplying AND'ing the current stack pointer to obtain the base address of the stack where the TLS data can be found (as struct tls_info_s). This works well in the KERNEL build mode where is the resides at highly aligned virtual address, but does not work well in FLAT and PROTECTED modes: 1. The alignment must be large. That is because it also determine the maximum size of the thread's stack. If the size of the thread's stack exceeds that maximum value then the AND operation will result in the wrong address. 2. If all of the addresses are highly aligned then (1) you need to have much more memory available for stack allocation. This is because (2) the large alignment cause bad memory fragmentation and degraded use of memory. An alternative way to get the stack base address address is to call into the OS to get the unaligned stack base address. This involves a system call, but is more usable that other alernatives in the FLAT and PROTECTED modes. We have implemented a new configuration: CONFIG_TLS_ALIGNED that selects the legacy aligned stack. If this is not defined, then the new unaligned stack TLS logic is used. We have also implemented aligned and unaligned TLS support for every architecture. ## What else do we have to do? The next steps are: 1. Move the errno storage location out of the TCB and in TLS (into the struct tls_info_s). 2. Modify the errno access definitions and logic in sched/errno to use the TLS logic in user space. This probably belongs in libs/libc/tls or perhaps libs/libc/errno. 3. Enable TLS be default. 4. Remove the errno-related system calls. ## pthread-specific data pthread-specific data is another mechanism for accessing thread-specific data. It consists of these POSIX standard interfaces: int pthread_key_create(FAR pthread_key_t *key, CODE void (*destructor)(FAR void *)); int pthread_setspecific(pthread_key_t key, FAR const void *value); FAR void *pthread_getspecific(pthread_key_t key); int pthread_key_delete(pthread_key_t key); This is a natural extension of the TLS logic would be natural to move into the TLS data as well. This would amount to: 1. Moving the pthread-specific storage out of the TCB and into the TLS data. 2. Moving the pthread-specific data accessors out of sched/pthread and into libs/libc/pthread 3. Remove the pthread-specific data system calls. ## TLS interfaces TLS is a non-standard, but more general interface. It differs from pthread-specific data only in that is semantics are general; the semantics of the pthread-specific data interfaces are focused on pthreads. But they really should shared the same common underly logic. Currently, there are two TLS interfaces: uintptr_t tls_get_element(int elem); void tls_set_element(int elem, uintptr_t value); I propose th
[GitHub] [incubator-nuttx] patacongo commented on pull request #985: syslog: Code outside libc shouldn't call nx_vsyslog directly
patacongo commented on pull request #985: URL: https://github.com/apache/incubator-nuttx/pull/985#issuecomment-624767858 Did the checks not start? This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] patacongo commented on pull request #985: syslog: Code outside libc shouldn't call nx_vsyslog directly
patacongo commented on pull request #985: URL: https://github.com/apache/incubator-nuttx/pull/985#issuecomment-624783442 For others, a rebase and forced push has been sufficient to get the checks started. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] patacongo commented on pull request #985: syslog: Code outside libc shouldn't call nx_vsyslog directly
patacongo commented on pull request #985: URL: https://github.com/apache/incubator-nuttx/pull/985#issuecomment-624850369 Seems to always fail on Build / Linux (sim) (pull_request) , but I don't see why. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] btashton commented on pull request #985: syslog: Code outside libc shouldn't call nx_vsyslog directly
btashton commented on pull request #985: URL: https://github.com/apache/incubator-nuttx/pull/985#issuecomment-624851403 ``` Building NuttX... make[3]: *** /github/workspace/sources/apps/system/usrsock_rpmsg: No such file or directory. Stop. make[2]: *** [Makefile:66: /github/workspace/sources/apps/system/usrsock_rpmsg_context] Error 2 make[2]: *** Waiting for unfinished jobs make[1]: *** [Makefile:128: context_serialize] Error 2 make: *** [tools/Makefile.unix:368: context] Error 2 Normalize sim/rpserver ``` This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] patacongo commented on pull request #985: syslog: Code outside libc shouldn't call nx_vsyslog directly
patacongo commented on pull request #985: URL: https://github.com/apache/incubator-nuttx/pull/985#issuecomment-624857273 > Building NuttX... Thanks. So this is a problem in the PR that needs fixin' This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] patacongo edited a comment on pull request #985: syslog: Code outside libc shouldn't call nx_vsyslog directly
patacongo edited a comment on pull request #985: URL: https://github.com/apache/incubator-nuttx/pull/985#issuecomment-624857273 > Building NuttX... Thanks. So this is a problem in the PR that needs fixin' I would guess that **https://github.com/apache/incubator-nuttx-apps/pull/234** is might be the culprit. If that is true (hope it is not), then all PR checks are broken. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] patacongo edited a comment on pull request #985: syslog: Code outside libc shouldn't call nx_vsyslog directly
patacongo edited a comment on pull request #985: URL: https://github.com/apache/incubator-nuttx/pull/985#issuecomment-624857273 > Building NuttX... Thanks. So this is a problem in the PR that needs fixin' I would guess that **https://github.com/apache/incubator-nuttx-apps/pull/234** is might be the culprit This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] btashton commented on pull request #985: syslog: Code outside libc shouldn't call nx_vsyslog directly
btashton commented on pull request #985: URL: https://github.com/apache/incubator-nuttx/pull/985#issuecomment-624872015 Yes I noticed that the build on master is broken right now. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] patacongo edited a comment on pull request #985: syslog: Code outside libc shouldn't call nx_vsyslog directly
patacongo edited a comment on pull request #985: URL: https://github.com/apache/incubator-nuttx/pull/985#issuecomment-624857273 > Building NuttX... Thanks. So this is a problem in the PR that needs fixin' I would guess that **https://github.com/apache/incubator-nuttx-apps/pull/234** along with #983 is might be the culprit. If that is true (hope it is not), then all PR checks are broken. There is discussion in the comments there that this could break the build but it would be monitored a fixed right way. I guess that did not happen. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] patacongo commented on pull request #985: syslog: Code outside libc shouldn't call nx_vsyslog directly
patacongo commented on pull request #985: URL: https://github.com/apache/incubator-nuttx/pull/985#issuecomment-624877179 > Yes I noticed that the build on master is broken right now. There is a problem with PRs not in apps/ or nuttx/ that depend on a PR in the other repository. Right now, we are just merging them and hoping for the best. We have been lucky in the past but this time it broke the build. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] btashton commented on pull request #985: syslog: Code outside libc shouldn't call nx_vsyslog directly
btashton commented on pull request #985: URL: https://github.com/apache/incubator-nuttx/pull/985#issuecomment-624879591 Yeah, I'm reworking that some more hopefully this week. Certainly a pain point. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] Ouss4 opened a new pull request #987: Implement the up_tls_info for the rest of the architectures
Ouss4 opened a new pull request #987: URL: https://github.com/apache/incubator-nuttx/pull/987 ## Summary This PR implements the up_tls_info for the rest of the architectures. Only sim and arm used to have an implementation. A small organization was needed for architectures that don't share the same way to retrieve the SP. z16 and z80 are still a WIP since I don't know how to get the stack pointer there. ## Impact TLS is still conditioned so for now no impact in any architecture. ## Testing Testing was performed with the sim ostest (with TLS enabled). This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] patacongo commented on a change in pull request #987: Implement the up_tls_info for the rest of the architectures
patacongo commented on a change in pull request #987: URL: https://github.com/apache/incubator-nuttx/pull/987#discussion_r421152756 ## File path: arch/arm/include/tls.h ## @@ -37,12 +37,12 @@ / / - * Name: up_getsp + * Name: arm_getsp Review comment: Actually, in this case, up_getsp() is the correct name since it is a common interface that is exported outside of the ARM architecture. Same is true of other locations. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] patacongo commented on a change in pull request #987: Implement the up_tls_info for the rest of the architectures
patacongo commented on a change in pull request #987: URL: https://github.com/apache/incubator-nuttx/pull/987#discussion_r421153489 ## File path: arch/avr/src/avr/up_createstack.c ## @@ -118,9 +137,42 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) { /* Allocate the stack. If DEBUG is enabled (but not stack debug), * then create a zeroed stack to make stack dumps easier to trace. + * If TLS is enabled, then we must allocate aligned stacks. */ +#ifdef CONFIG_TLS_ALIGNED Review comment: Is there a blank line missing here? This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] patacongo commented on a change in pull request #987: Implement the up_tls_info for the rest of the architectures
patacongo commented on a change in pull request #987: URL: https://github.com/apache/incubator-nuttx/pull/987#discussion_r421154061 ## File path: arch/avr/include/avr32/arch.h ## @@ -0,0 +1,84 @@ +/ + * arch/avr/include/avr32/arch.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + / + +/* This file should never be included directly but, rather, + * only indirectly through nuttx/arch.h + */ + +#ifndef __ARCH_AVR_INCLUDE_AVR32_ARCH_H +#define __ARCH_AVR_INCLUDE_AVR32_ARCH_H + +/ + * Included Files + / + +/ + * Pre-processor Definitions + / + +/ + * Public Types + / + +#ifndef __ASSEMBLY__ + +/ + * Inline functions + / + +/ + * Name: avr_getsp + / + +static inline uint32_t avr_getsp(void) +{ + uint32_t retval; + __asm__ __volatile__ +( + "mov\t%0,sp\n\t" + : "=r" (retval) + : +); + return retval; Review comment: Missing blank line. Is a 32-bit value always used to represent the stack pointer? This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] patacongo commented on a change in pull request #987: Implement the up_tls_info for the rest of the architectures
patacongo commented on a change in pull request #987: URL: https://github.com/apache/incubator-nuttx/pull/987#discussion_r421154488 ## File path: arch/avr/include/avr/arch.h ## @@ -0,0 +1,87 @@ +/ + * arch/avr/include/avr/arch.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + / + +/* This file should never be included directly but, rather, + * only indirectly through nuttx/arch.h + */ + +#ifndef __ARCH_AVR_INCLUDE_AVR_ARCH_H +#define __ARCH_AVR_INCLUDE_AVR_ARCH_H + +/ + * Included Files + / + +/ + * Pre-processor Definitions + / + +/ + * Public Types + / + +#ifndef __ASSEMBLY__ + +/ + * Inline functions + / + +/ + * Name: avr_getsp + / + +static inline uint16_t avr_getsp(void) +{ + uint8_t spl; + uint8_t sph; + + __asm__ __volatile__ + ( +"in %0, __SP_L__\n\t" +"in %1, __SP_H__\n" +: "=r" (spl), "=r" (sph) +: + ); + return (uint16_t)sph << 8 | spl; Review comment: Misssing blank line. I assume that uint16_t is correct for an 8-bit AVR? Sounds righr. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] patacongo commented on a change in pull request #987: Implement the up_tls_info for the rest of the architectures
patacongo commented on a change in pull request #987: URL: https://github.com/apache/incubator-nuttx/pull/987#discussion_r421154061 ## File path: arch/avr/include/avr32/arch.h ## @@ -0,0 +1,84 @@ +/ + * arch/avr/include/avr32/arch.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + / + +/* This file should never be included directly but, rather, + * only indirectly through nuttx/arch.h + */ + +#ifndef __ARCH_AVR_INCLUDE_AVR32_ARCH_H +#define __ARCH_AVR_INCLUDE_AVR32_ARCH_H + +/ + * Included Files + / + +/ + * Pre-processor Definitions + / + +/ + * Public Types + / + +#ifndef __ASSEMBLY__ + +/ + * Inline functions + / + +/ + * Name: avr_getsp + / + +static inline uint32_t avr_getsp(void) +{ + uint32_t retval; + __asm__ __volatile__ +( + "mov\t%0,sp\n\t" + : "=r" (retval) + : +); + return retval; Review comment: Missing blank line. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] patacongo commented on a change in pull request #987: Implement the up_tls_info for the rest of the architectures
patacongo commented on a change in pull request #987: URL: https://github.com/apache/incubator-nuttx/pull/987#discussion_r421154971 ## File path: arch/avr/include/tls.h ## @@ -0,0 +1,78 @@ +/ + * arch/avr/include/tls.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + / + +#ifndef __ARCH_AVR_INCLUDE_TLS_H +#define __ARCH_AVR_INCLUDE_TLS_H + +/ + * Included Files + / + +#include +#include +#include +#include + +#ifdef CONFIG_TLS + +/ + * Inline Functions + / + +/ + * Name: up_tls_info + * + * Description: + * Return the TLS information structure for the currently executing thread. + * When TLS is enabled, up_createstack() will align allocated stacks to + * the TLS_STACK_ALIGN value. An instance of the following structure will + * be implicitly positioned at the "lower" end of the stack. Assuming a + * "push down" stack, this is at the "far" end of the stack (and can be + * clobbered if the stack overflows). + * + * If an MCU has a "push up" then that TLS structure will lie at the top + * of the stack and stack allocation and initialization logic must take + * care to preserve this structure content. + * + * The stack memory is fully accessible to user mode threads. + * + * Input Parameters: + * None + * + * Returned Value: + * A pointer to TLS info structure at the beginning of the STACK memory + * allocation. This is essentially an application of the TLS_INFO(sp) + * macro and has a platform dependency only in the manner in which the + * stack pointer (sp) is obtained and interpreted. + * + / + +#ifdef CONFIG_TLS_ALIGNED +static inline FAR struct tls_info_s *up_tls_info(void) +{ + DEBUGASSERT(!up_interrupt_context()); + return TLS_INFO((uintptr_t)avr_getsp()); +} Review comment: For avr you get a uint16_t but for avr32 you get a uint32_t. I don't know the size of uintptr_t in each architecture but I suppose this works out okay in TLS_INFO? This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] patacongo commented on a change in pull request #987: Implement the up_tls_info for the rest of the architectures
patacongo commented on a change in pull request #987: URL: https://github.com/apache/incubator-nuttx/pull/987#discussion_r421154971 ## File path: arch/avr/include/tls.h ## @@ -0,0 +1,78 @@ +/ + * arch/avr/include/tls.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + / + +#ifndef __ARCH_AVR_INCLUDE_TLS_H +#define __ARCH_AVR_INCLUDE_TLS_H + +/ + * Included Files + / + +#include +#include +#include +#include + +#ifdef CONFIG_TLS + +/ + * Inline Functions + / + +/ + * Name: up_tls_info + * + * Description: + * Return the TLS information structure for the currently executing thread. + * When TLS is enabled, up_createstack() will align allocated stacks to + * the TLS_STACK_ALIGN value. An instance of the following structure will + * be implicitly positioned at the "lower" end of the stack. Assuming a + * "push down" stack, this is at the "far" end of the stack (and can be + * clobbered if the stack overflows). + * + * If an MCU has a "push up" then that TLS structure will lie at the top + * of the stack and stack allocation and initialization logic must take + * care to preserve this structure content. + * + * The stack memory is fully accessible to user mode threads. + * + * Input Parameters: + * None + * + * Returned Value: + * A pointer to TLS info structure at the beginning of the STACK memory + * allocation. This is essentially an application of the TLS_INFO(sp) + * macro and has a platform dependency only in the manner in which the + * stack pointer (sp) is obtained and interpreted. + * + / + +#ifdef CONFIG_TLS_ALIGNED +static inline FAR struct tls_info_s *up_tls_info(void) +{ + DEBUGASSERT(!up_interrupt_context()); + return TLS_INFO((uintptr_t)avr_getsp()); +} Review comment: For avr you get a uint16_t but for avr32 you get a uint32_t. I don't know the size of uintptr_t in each architecture but I suppose this works out okay in TLS_INFO? Ignore me? I am just thinking out loud. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] Ouss4 commented on a change in pull request #987: Implement the up_tls_info for the rest of the architectures
Ouss4 commented on a change in pull request #987: URL: https://github.com/apache/incubator-nuttx/pull/987#discussion_r421156496 ## File path: arch/arm/include/tls.h ## @@ -37,12 +37,12 @@ / / - * Name: up_getsp + * Name: arm_getsp Review comment: The function is in a header file that's exported but I don't think it will be used outside the ARM directory. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] Ouss4 commented on a change in pull request #987: Implement the up_tls_info for the rest of the architectures
Ouss4 commented on a change in pull request #987: URL: https://github.com/apache/incubator-nuttx/pull/987#discussion_r421157741 ## File path: arch/avr/src/avr/up_createstack.c ## @@ -118,9 +137,42 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) { /* Allocate the stack. If DEBUG is enabled (but not stack debug), * then create a zeroed stack to make stack dumps easier to trace. + * If TLS is enabled, then we must allocate aligned stacks. */ +#ifdef CONFIG_TLS_ALIGNED Review comment: There is another #ifdef just after, so no blank line needed. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] patacongo commented on a change in pull request #987: Implement the up_tls_info for the rest of the architectures
patacongo commented on a change in pull request #987: URL: https://github.com/apache/incubator-nuttx/pull/987#discussion_r421158100 ## File path: arch/arm/include/tls.h ## @@ -37,12 +37,12 @@ / / - * Name: up_getsp + * Name: arm_getsp Review comment: It is an internal private function and not part of the well-defined interface, so it really is not important. It is exported outside of ARM, however, if any code includes: #include This it will get this code. That could be from anywhere in the OS or even in applications. But since it is not a part of the standard interface and since its prototype differs for each architecture, I don't think that the up_ naming is required. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] Ouss4 commented on a change in pull request #987: Implement the up_tls_info for the rest of the architectures
Ouss4 commented on a change in pull request #987: URL: https://github.com/apache/incubator-nuttx/pull/987#discussion_r421159895 ## File path: arch/arm/include/tls.h ## @@ -37,12 +37,12 @@ / / - * Name: up_getsp + * Name: arm_getsp Review comment: Maybe I can do something similar as RISC-V for instance and take the arm_getsp to the arch.h file. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] patacongo commented on pull request #987: Implement the up_tls_info for the rest of the architectures
patacongo commented on pull request #987: URL: https://github.com/apache/incubator-nuttx/pull/987#issuecomment-624953041 Otherwise, it all looks good to me. That was a very big effort. Thanks for the nice contribution. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] patacongo commented on pull request #987: Implement the up_tls_info for the rest of the architectures
patacongo commented on pull request #987: URL: https://github.com/apache/incubator-nuttx/pull/987#issuecomment-624952836 As you mentioned, the implementation is incomplete for z16 and z80 because you are missing assembly language functions to get the SP in most of those cases. I do not think this is a problem for those architectures. The stack pointer is only needed in the ALIGNED TLS case and the ALIGNED TLS case is not appropriate for the z80 and z180 architectures. z16f and ez80 are possibilities but not likely. We do needed the unaligned TLS case implemented. My recommendation for now is to add logic like: #ifdef CONFIG_TLS_ALIGNED # errno Aligned TLS not supported #else # define up_tls_info() tls_get_info() #endf That provided everything that is needed from now and if some crazy person wants to implement aligned TLS on these tiny chips in the future, then they will have to provide the missing logic. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] patacongo commented on a change in pull request #987: Implement the up_tls_info for the rest of the architectures
patacongo commented on a change in pull request #987: URL: https://github.com/apache/incubator-nuttx/pull/987#discussion_r421162160 ## File path: arch/arm/include/tls.h ## @@ -37,12 +37,12 @@ / / - * Name: up_getsp + * Name: arm_getsp Review comment: > Maybe I can do something similar as RISC-V for instance and take the arm_getsp to the arch.h file. Don't bother. It would still be exported to all files and should still have the up_ prefix. There is no way to avoid avoid that. TLS requires that that function be used outside of the ARM code. Same is true for all of the other architectures. I don't recommend changing the name, but not for that reason. I don't recommend changing the because it is not a documented, controlled interface. If is private for use within the tls.h header file. it does not have a consist protoype, it is not prototyped in include/nuttx/arch.h so it doesn't matter what you call it. up_ would be more arhicturually correct probably, but it is not important. All MCU names used outide of the architecutre-/board-specific logic should be called up_ This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] patacongo commented on a change in pull request #987: Implement the up_tls_info for the rest of the architectures
patacongo commented on a change in pull request #987: URL: https://github.com/apache/incubator-nuttx/pull/987#discussion_r421162160 ## File path: arch/arm/include/tls.h ## @@ -37,12 +37,12 @@ / / - * Name: up_getsp + * Name: arm_getsp Review comment: > Maybe I can do something similar as RISC-V for instance and take the arm_getsp to the arch.h file. Don't bother. It would still be exported to all files and should still require the up_ prefix. There is no way to avoid avoid that. TLS requires that that function be used outside of the ARM code. Same is true for all of the other architectures. I don't recommend changing the name, but not for that reason. I don't recommend changing the because it is not a documented, controlled interface. If is private for use within the tls.h header file. it does not have a consist protoype, it is not prototyped in include/nuttx/arch.h so it doesn't matter what you call it. up_ would be more architecturually correct probably, but it is not important. All MCU names used outide of the architecutre-/board-specific logic should be called up_ This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] patacongo commented on pull request #987: Implement the up_tls_info for the rest of the architectures
patacongo commented on pull request #987: URL: https://github.com/apache/incubator-nuttx/pull/987#issuecomment-624955829 Don't expect everything to build. The build system is broken right now. See discussion in #985 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] Ouss4 commented on pull request #987: Implement the up_tls_info for the rest of the architectures
Ouss4 commented on pull request #987: URL: https://github.com/apache/incubator-nuttx/pull/987#issuecomment-624957493 ``` #ifdef CONFIG_TLS_ALIGNED # error Aligned TLS not supported #else # define up_tls_info() tls_get_info() #endf ``` Okay, I did that. > Don't expect everything to build. The build system is broken right now. See discussion in #985 Let's keep it open until all the checks pass, I'm concerned about the architectures that I don't use. I might have introduced an error somewhere. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-nuttx] Ouss4 commented on pull request #987: Implement the up_tls_info for the rest of the architectures
Ouss4 commented on pull request #987: URL: https://github.com/apache/incubator-nuttx/pull/987#issuecomment-624960891 PS.: Don't worry about the horrible commits. I'll provide a better history when everything passes. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org