xiaoxiang781216 commented on code in PR #11583: URL: https://github.com/apache/nuttx/pull/11583#discussion_r1463663539
########## arch/x86_64/src/intel64/intel64_createstack.c: ########## @@ -161,7 +161,8 @@ int up_create_stack(struct tcb_s *tcb, size_t stack_size, uint8_t ttype) if (!tcb->stack_alloc_ptr) { - serr("ERROR: Failed to allocate stack, size %d\n", stack_size); + serr("ERROR: Failed to allocate stack, size %" PRIu64 "\n", Review Comment: %zu ########## drivers/virt/Make.defs: ########## @@ -0,0 +1,43 @@ +############################################################################ +# drivers/pci/Make.defs Review Comment: pci->virt ########## arch/x86_64/src/intel64/intel64_lowsetup.c: ########## @@ -52,10 +53,60 @@ volatile uint64_t *pt; volatile struct ist_s *ist64; volatile struct gdt_entry_s *gdt64; +/* This holds information passed by the multiboot2 bootloader */ + +uint32_t mb_magic __attribute__((section(".loader.bss"))); +uint32_t mb_info_struct __attribute__((section(".loader.bss"))); + /**************************************************************************** * Private Functions ****************************************************************************/ +#ifdef CONFIG_ARCH_MULTIBOOT2 +/**************************************************************************** + * Name: x86_64_mb2_config + * + * Description: + * Parse multiboot2 info. + * + ****************************************************************************/ + +static void x86_64_mb2_config(void) +{ + struct multiboot_tag *tag; + + /* Check that we were actually booted by a mulitboot2 bootloader */ + + if (mb_magic != MULTIBOOT2_BOOTLOADER_MAGIC) + return; + + for (tag = (struct multiboot_tag *)(uintptr_t)(mb_info_struct + 8); + tag->type != MULTIBOOT_TAG_TYPE_END; + tag = (struct multiboot_tag *)((uint8_t *)tag + ((tag->size + 7) & ~7))) Review Comment: align with line 83 ########## drivers/pci/Make.defs: ########## @@ -0,0 +1,32 @@ +############################################################################ +# drivers/pci/Make.defs Review Comment: need remark ########## arch/x86_64/src/intel64/intel64_lowsetup.c: ########## @@ -52,10 +53,60 @@ volatile uint64_t *pt; volatile struct ist_s *ist64; volatile struct gdt_entry_s *gdt64; +/* This holds information passed by the multiboot2 bootloader */ + +uint32_t mb_magic __attribute__((section(".loader.bss"))); +uint32_t mb_info_struct __attribute__((section(".loader.bss"))); + /**************************************************************************** * Private Functions ****************************************************************************/ +#ifdef CONFIG_ARCH_MULTIBOOT2 +/**************************************************************************** + * Name: x86_64_mb2_config + * + * Description: + * Parse multiboot2 info. + * + ****************************************************************************/ + +static void x86_64_mb2_config(void) +{ + struct multiboot_tag *tag; + + /* Check that we were actually booted by a mulitboot2 bootloader */ + + if (mb_magic != MULTIBOOT2_BOOTLOADER_MAGIC) + return; Review Comment: add {} ########## drivers/virt/Make.defs: ########## @@ -0,0 +1,43 @@ +############################################################################ +# drivers/pci/Make.defs +# +# 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. +# +############################################################################ + +# Don't build anything if there is no CAN support Review Comment: remove ########## drivers/pci/Make.defs: ########## @@ -0,0 +1,32 @@ +############################################################################ +# drivers/pci/Make.defs +# +# 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. +# +############################################################################ + +# Don't build anything if there is no CAN support + +ifeq ($(CONFIG_PCI),y) + +CSRCS += pci.c + +# Include PCI device driver build support + +DEPPATH += --dep-path pci +VPATH += :pci +CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)$(DELIM)drivers$(DELIM)pci} Review Comment: ```${INCDIR_PREFIX}$(TOPDIR)$(DELIM)drivers$(DELIM)pci``` ########## include/nuttx/pci/pci.h: ########## @@ -0,0 +1,472 @@ +/**************************************************************************** + * include/nuttx/pci/pci.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 __INCLUDE_NUTTX_PCI_PCI_H +#define __INCLUDE_NUTTX_PCI_PCI_H + +#ifdef CONFIG_PCI + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#include <sys/types.h> +#include <stdint.h> + +#include <nuttx/fs/ioctl.h> + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* PCI config common registers */ + +#define PCI_CONFIG_VENDOR 0x00 +#define PCI_CONFIG_DEVICE 0x02 +#define PCI_CONFIG_COMMAND 0x04 +#define PCI_CONFIG_REV_ID 0x08 +#define PCI_CONFIG_PROG_IF 0x09 +#define PCI_CONFIG_SUBCLASS 0x0A Review Comment: align withc each other ########## drivers/virt/qemu_edu.c: ########## @@ -0,0 +1,462 @@ +/***************************************************************************** + * drivers/virt/qemu_edu.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 <nuttx/config.h> +#include <nuttx/arch.h> +#include <nuttx/irq.h> +#include <nuttx/kmalloc.h> + +#include <debug.h> +#include <stdio.h> +#include <stdint.h> +#include <string.h> +#include <math.h> +#include <unistd.h> +#include <errno.h> +#include <sched.h> + +#include <nuttx/pci/pci.h> +#include <nuttx/virt/qemu_pci.h> + +/***************************************************************************** + * Pre-processor Definitions + *****************************************************************************/ + +/* Registers defined for device. Size 4 for < 0x80. Size 8 for >= 0x80. */ + +#define EDU_REG_ID 0x00 /* Identification */ +#define EDU_REG_LIVE 0x04 /* Liveness Check */ +#define EDU_REG_FAC 0x08 /* Factorial Computation */ +#define EDU_REG_STATUS 0x20 /* Status */ +#define EDU_REG_INT_STATUS 0x24 /* Interupt Status */ +#define EDU_REG_INT_RAISE 0x60 /* Raise an interrupt */ +#define EDU_REG_INT_ACK 0x64 /* Acknowledge interrupt */ +#define EDU_REG_DMA_SOURCE 0x80 /* Source address for DMA transfer */ +#define EDU_REG_DMA_DEST 0x88 /* Destination address for DMA transfer */ +#define EDU_REG_DMA_COUNT 0x90 /* Size of area to transfer with DMA */ +#define EDU_REG_DMA_CMD 0x98 /* Control DMA tranfer */ + +#define EDU_CONTROL_BAR_ID 0 +#define EDU_CONTROL_BAR_OFFSET PCI_HEADER_NORM_BAR0 + +/***************************************************************************** + * Private Types + *****************************************************************************/ + +struct qemu_edu_priv_s +{ + uintptr_t base_addr; + sem_t isr_done; + uint32_t test_result; +}; + +/***************************************************************************** + * Private Functions Definitions + *****************************************************************************/ + +static void qemu_edu_write_reg32(uintptr_t addr, uint32_t val); + +static uint32_t qemu_edu_read_reg32(uintptr_t addr); + +static void qemu_edu_write_reg64(uintptr_t addr, uint64_t val); + +static void qemu_edu_test_poll(FAR struct pci_dev_s *dev, + uintptr_t base_addr); + +static void qemu_edu_test_intx(FAR struct pci_dev_s *dev, + struct qemu_edu_priv_s *drv_priv); + +static int qemu_edu_interrupt(int irq, void *context, FAR void *arg); + +static int qemu_edu_probe(FAR struct pci_bus_s *bus, + FAR struct pci_dev_type_s *type, uint16_t bdf); + +/***************************************************************************** + * Public Data + *****************************************************************************/ + +struct pci_dev_type_s g_pci_type_qemu_edu = Review Comment: add const -- 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. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org