Building Linux Kernel fast
Posted in Kernel, Linux » 0 comments »
Relocating users to a new version of FreeBSD
/etc/master.passwd /etc/passwd /etc/group
Run the following command.
/usr/sbin/pwd_mkdb -p /etc/master.passwd
Copy all the home directories and email directory to the new system.
Source: http://www.myptsmail.com/blog/?p=72 Read More...
Posted in FreeBSD » 0 comments »
How do I allocate physically contiguous memory in Solaris?
Solaris provides several DDI/DKI routines prefaced with ddi_dma_ which abstract the characteristics of DMA, such that a single driver can be written to work across all Solaris supported platforms.
Specifically, ddi_dma_mem_alloc(9F) is the preferred routine to allocate driver memory suitable for DMA. The ddi_dma_attr(9S) structure controls the allocation of memory. Note that setting the dma_attr_sgllen to a length of 1 informs the DDI framework that physically contiguous memory is required. On Solaris Intel, each ddi_dma_cookie(9S) structure returned when the allocated memory is bound with the various ddi_dma*_bind(9F) contains the physical address of the memory, suitable for use in constructing scatter-gather lists. See the example isp(7D) device driver source, available for download for examples of using various ddi_dma_ prefixed routines.
NOTE: some versions of the DDI framework may not handle all rounding and size issues. In general, it's better to allocate the minimal number of contiguous pages required, in sizes falling on page boundaries.
Other allocators: on the Solaris OS on x86 Platforms, ddi_iopb_alloc(9F) by default allocates from a a very restricted pool of pages allocated at boot time. It's best not to use this allocator unless necessary (note that most modern adapters can perform DMA into the entire 32- and/or 64-bit address range). Also note that the kernel virtual memory allocated by kmem_alloc(9F) can be bound using ddi_dma_addr_bind_handle(9F), but this memory is not physically contiguous, and may appear above 32-bits on 64-bit or PAE enabled systems.
ddi_dma_mem_alloc(9F) is a recommended interface to use.
TIP: allocating very large blocks of physically contiguous memory:
The Solaris kernel memory model does not support large blocks of physically contiguous memory: as virtual/paged memory usage fragments the physical memory, there is no management performed to defragment physical memory. Also, various kernel data structures are sized dynamically at boot time, to match the system's memory size.
(One method to allocate a large physically contiguous memory block is to perform the allocation very early (when the driver is first attached), as memory resources are relatively unfragmented at this time. Note that kmem_alloc(9F) will typically also return memory which is physically contiguous early in system boot).
Source: http://developers.sun.com/solaris/developer/support/driver/faqs.html#NQ5.1
Read More...Posted in Kernel, Solaris » 0 comments »
Watchdog Timeouts
error_mode signal. This signal is logically wired back to the watchdog_reset_in pin. Source: http://developers.sun.com/solaris/developer/support/driver/faqs.html#QA3.11 Read More...Note: Some chips don't have externalerror_modesignal, nor externalwatchdog_reset_inpins and this process all occurs inside the chip.
Posted in Kernel, Solaris » 0 comments »
Forcing a Virtual Adapter to use Promiscuous Mode
In some circumstances, you may need to use the virtual Ethernet adapters in promiscuous mode. To enable this use, you must set the PromiscuousAllowed configuration variable to yes. To do so, follow these steps.
- Check the Edit Configuration page of the VMware Management Interface to determine what network the virtual Ethernet adapter is using. For this example, assume that the Networking section of the page shows the adapter is using vmnic0.
- Log in to the server's service console and enter the following command:
echo "PromiscuousAllowed yes" > /proc/vmware/net/vmnic0/config
This allows the guest operating systems in all virtual machines using vmnic0 to enable promiscuous mode.
If the adapter is using a different network, such as vmnet_0, make the appropriate substitution in the command.
- Take the appropriate steps in the guest operating system to enable promiscuous mode on the virtual network adapter.
You may want to allow only some adapters on a particular network to use promiscuous mode. In that case, you can selectively disable promiscuous mode based on the MAC address of the virtual machine's Ethernet adapter. To do so, follow these steps.
- Connect to the virtual machine with the remote console and use the appropriate guest operating system tools to determine the MAC address of the virtual Ethernet adapter.
- Log in to the service console and enter the following command:
echo "PromiscuousAllowed no" > /proc/vmware/net/vmnic0/
In place of
, substitute the virtual Ethernet adapter's MAC address in the standard format 00:05:69:XX:YY:ZZ. If the adapter is using a different network, such as vmnet_0, make the appropriate substitution in the command.
Posted in Network, Virtualization, VMWare » 0 comments »
Copying data from Kernel memory space to User memory space
ddi_copyout(9F), which enables us to copy some data in the kernel memory space to our application program. For example, when we want to obtain the configuration data within the device driver, ddi_copyout(9F) is useful.
The sample program is shown below. This is the extention of the skelton driver for Character Driver Skelton Program (skelton.c).
1) The user application program opens the device and call ioctl(2).
#include#include #include #include "skelton.h" main() { int fd; struct my_skelton_info skelton_info_copy; fd = open ("/devices/pseudo/skelton@0:0", O_RDONLY); if (fd == -1) { perror ("open"); exit (errno); } if (ioctl(fd,SKELTON_DUMMY,NULL) == -1) { perror("ioctl"); exit(errno); } if (ioctl(fd,SKELTON_GETINFO,&skelton_info_copy) == -1) { perror("ioctl"); exit(errno); } printf("my_skelton_info venid = %d\n",skelton_info_copy.venid); printf("my_skelton_info devid = %d\n",skelton_info_copy.devid); printf("my_skelton_info revid = %d\n",skelton_info_copy.revid); }
2) The following sample driver will respond to the application.
o header file (skelton.h)
#ifndef SKELTON_H
#define SKELTON_H
#define SKELTON_DUMMY _IO('m',1)
#define SKELTON_GETINFO _IO('m',2)
struct my_skelton_info {
int venid; /* Let's suppose this is the vendor id. */
int devid; /* Let's suppose this is the device id. */
short revid; /* Let's suppose this is the revision id. */
};
#endif SKELTON_H
o extended skelton driver (skelton.c)
:
:
#include "skelton.h"
:
:
struct skel_state {
int instance; /* instance number */
dev_info_t *dip; /* dev_info structure */
struct my_skelton_info info; /* additional info */
};
:
:
static int
skel_attach(dev_info_t *dip, ddi_attach_cmd_t cmd)
{
int instance;
struct skel_state *bs;
int flags;
switch(cmd) {
case DDI_ATTACH:
:
:
bs = ddi_get_soft_state(statep, instance);
:
:
/* SET VALUE IN THE KERNEL SPACE */
bs->info.venid = 1234; /* Let's suppose this is the vendor id value. */
bs->info.devid = 5678; /* Let's suppose this is the device id value. */
bs->info.revid = 99; /* Let's suppose this is the revision id value. */
return DDI_SUCCESS;
default:
return DDI_FAILURE;
}
:
:
}
static int
skel_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *credp, int *rvalp)
{
int instance;
struct skel_state *rs;
instance = getminor(dev);
rs = ddi_get_soft_state(statep, instance);
if(rs == NULL) {
return ENXIO;
};
switch (cmd) {
case SKELTON_GETINFO:
/* COPY DATA FROM KERNEL SPACE TO USER SPACE */
if(ddi_copyout((void *)&rs->info, (void *)arg, sizeof(struct my_skelton_info), mode) != 0) {
return EFAULT;
}
return 0;
case SKELTON_DUMMY:
cmn_err(CE_NOTE, "_ioctl called (SKELTON_TEST)\n");
return 0;
default:
return ENOTTY;
}
}
3) The result will be as follows.
# ./skelApp
my_skelton_info venid = 1234
my_skelton_info devid = 5678
my_skelton_info revid = 99
Source: http://developers.sun.com/solaris/developer/support/driver/faqs.html
Read More...Posted in Kernel, Solaris » 0 comments »