'fedora-2_6_6-1_406'.
+++ /dev/null
-
-PowerNow! and Cool'n'Quiet are AMD names for frequency
-management capabilities in AMD processors. As the hardware
-implementation changes in new generations of the processors,
-there is a different cpu-freq driver for each generation.
-
-Note that the driver's will not load on the "wrong" hardware,
-so it is safe to try each driver in turn when in doubt as to
-which is the correct driver.
-
-Note that the functionality to change frequency (and voltage)
-is not available in all processors. The drivers will refuse
-to load on processors without this capability. The capability
-is detected with the cpuid instruction.
-
-The drivers use BIOS supplied tables to obtain frequency and
-voltage information appropriate for a particular platform.
-Frequency transitions will be unavailable if the BIOS does
-not supply these tables.
-
-6th Generation: powernow-k6
-
-7th Generation: powernow-k7: Athlon, Duron, Geode.
-
-8th Generation: powernow-k8: Athlon, Athlon 64, Opteron, Sempron.
-Documentation on this functionality in 8th generation processors
-is available in the "BIOS and Kernel Developer's Guide", publication
-26094, in chapter 9, available for download from www.amd.com.
-
-BIOS supplied data, for powernow-k7 and for powernow-k8, may be
-from either the PSB table or from ACPI objects. The ACPI support
-is only available if the kernel config sets CONFIG_ACPI_PROCESSOR.
-The powernow-k8 driver will attempt to use ACPI if so configured,
-and fall back to PST if that fails.
-The powernow-k7 driver will try to use the PSB support first, and
-fall back to ACPI if the PSB support fails. A module parameter,
-acpi_force, is provided to force ACPI support to be used instead
-of PSB support.
+++ /dev/null
-
-relayfs - a high-speed data relay filesystem
-============================================
-
-relayfs is a filesystem designed to provide an efficient mechanism for
-tools and facilities to relay large amounts of data from kernel space
-to user space.
-
-The main idea behind relayfs is that every data flow is put into a
-separate "channel" and each channel is a file. In practice, each
-channel is a separate memory buffer allocated from within kernel space
-upon channel instantiation. Software needing to relay data to user
-space would open a channel or a number of channels, depending on its
-needs, and would log data to that channel. All the buffering and
-locking mechanics are taken care of by relayfs. The actual format and
-protocol used for each channel is up to relayfs' clients.
-
-relayfs makes no provisions for copying the same data to more than a
-single channel. This is for the clients of the relay to take care of,
-and so is any form of data filtering. The purpose is to keep relayfs
-as simple as possible.
-
-
-Usage
-=====
-
-In addition to the relayfs kernel API described below, relayfs
-implements basic file operations. Here are the file operations that
-are available and some comments regarding their behavior:
-
-open() enables user to open an _existing_ channel. A channel can be
- opened in blocking or non-blocking mode, and can be opened
- for reading as well as for writing. Readers will by default
- be auto-consuming.
-
-mmap() results in channel's memory buffer being mmapped into the
- caller's memory space.
-
-read() since we are dealing with circular buffers, the user is only
- allowed to read forward. Some apps may want to loop around
- read() waiting for incoming data - if there is no data
- available, read will put the reader on a wait queue until
- data is available (blocking mode). Non-blocking reads return
- -EAGAIN if data is not available.
-
-
-write() writing from user space operates exactly as relay_write() does
- (described below).
-
-poll() POLLIN/POLLRDNORM/POLLOUT/POLLWRNORM/POLLERR supported.
-
-close() decrements the channel's refcount. When the refcount reaches
- 0 i.e. when no process or kernel client has the file open
- (see relay_close() below), the channel buffer is freed.
-
-
-In order for a user application to make use of relayfs files, the
-relayfs filesystem must be mounted. For example,
-
- mount -t relayfs relayfs /mountpoint
-
-
-The relayfs kernel API
-======================
-
-relayfs channels are implemented as circular buffers subdivided into
-'sub-buffers'. kernel clients write data into the channel using
-relay_write(), and are notified via a set of callbacks when
-significant events occur within the channel. 'Significant events'
-include:
-
-- a sub-buffer has been filled i.e. the current write won't fit into the
- current sub-buffer, and a 'buffer-switch' is triggered, after which
- the data is written into the next buffer (if the next buffer is
- empty). The client is notified of this condition via two callbacks,
- one providing an opportunity to perform start-of-buffer tasks, the
- other end-of-buffer tasks.
-
-- data is ready for the client to process. The client can choose to
- be notified either on a per-sub-buffer basis (bulk delivery) or
- per-write basis (packet delivery).
-
-- data has been written to the channel from user space. The client can
- use this notification to accept and process 'commands' sent to the
- channel via write(2).
-
-- the channel has been opened/closed/mapped/unmapped from user space.
- The client can use this notification to trigger actions within the
- kernel application, such as enabling/disabling logging to the
- channel. It can also return result codes from the callback,
- indicating that the operation should fail e.g. in order to restrict
- more than one user space open or mmap.
-
-- the channel needs resizing, or needs to update its
- state based on the results of the resize. Resizing the channel is
- up to the kernel client to actually perform. If the channel is
- configured for resizing, the client is notified when the unread data
- in the channel passes a preset threshold, giving it the opportunity
- to allocate a new channel buffer and replace the old one.
-
-Reader objects
---------------
-
-Channel readers use an opaque rchan_reader object to read from
-channels. For VFS readers (those using read(2) to read from a
-channel), these objects are automatically created and used internally;
-only kernel clients that need to directly read from channels, or whose
-userspace applications use mmap to access channel data, need to know
-anything about rchan_readers - others may skip this section.
-
-A relay channel can have any number of readers, each represented by an
-rchan_reader instance, which is used to encapsulate reader settings
-and state. rchan_reader objects should be treated as opaque by kernel
-clients. To create a reader object for directly accessing a channel
-from kernel space, call the add_rchan_reader() kernel API function:
-
-rchan_reader *add_rchan_reader(rchan_id, auto_consume)
-
-This function returns an rchan_reader instance if successful, which
-should then be passed to relay_read() when the kernel client is
-interested in reading from the channel.
-
-The auto_consume parameter indicates whether a read done by this
-reader will automatically 'consume' that portion of the unread channel
-buffer when relay_read() is called (see below for more details).
-
-To close the reader, call
-
-remove_rchan_reader(reader)
-
-which will remove the reader from the list of current readers.
-
-
-To create a reader object representing a userspace mmap reader in the
-kernel application, call the add_map_reader() kernel API function:
-
-rchan_reader *add_map_reader(rchan_id)
-
-This function returns an rchan_reader instance if successful, whose
-main purpose is as an argument to be passed into
-relay_buffers_consumed() when the kernel client becomes aware that
-data has been read by a user application using mmap to read from the
-channel buffer. There is no auto_consume option in this case, since
-only the kernel client/user application knows when data has been read.
-
-To close the map reader, call
-
-remove_map_reader(reader)
-
-which will remove the reader from the list of current readers.
-
-Consumed count
---------------
-
-A relayfs channel is a circular buffer, which means that if there is
-no reader reading from it or a reader reading too slowly, at some
-point the channel writer will 'lap' the reader and data will be lost.
-In normal use, readers will always be able to keep up with writers and
-the buffer is thus never in danger of becoming full. In many
-applications, it's sufficient to ensure that this is practically
-speaking always the case, by making the buffers large enough. These
-types of applications can basically open the channel as
-RELAY_MODE_CONTINOUS (the default anyway) and not worry about the
-meaning of 'consume' and skip the rest of this section.
-
-If it's important for the application that a kernel client never allow
-writers to overwrite unread data, the channel should be opened using
-RELAY_MODE_NO_OVERWRITE and must be kept apprised of the count of
-bytes actually read by the (typically) user-space channel readers.
-This count is referred to as the 'consumed count'. read(2) channel
-readers automatically update the channel's 'consumed count' as they
-read. If the usage mode is to have only read(2) readers, which is
-typically the case, the kernel client doesn't need to worry about any
-of the relayfs functions having to do with 'bytes consumed' and can
-skip the rest of this section. (Note that it is possible to have
-multiple read(2) or auto-consuming readers, but like having multiple
-readers on a pipe, these readers will race with each other i.e. it's
-supported, but doesn't make much sense).
-
-If the kernel client cannot rely on an auto-consuming reader to keep
-the 'consumed count' up-to-date, then it must do so manually, by
-making the appropriate calls to relay_buffers_consumed() or
-relay_bytes_consumed(). In most cases, this should only be necessary
-for bulk mmap clients - almost all packet clients should be covered by
-having auto-consuming read(2) readers. For mmapped bulk clients, for
-instance, there are no auto-consuming VFS readers, so the kernel
-client needs to make the call to relay_buffers_consumed() after
-sub-buffers are read.
-
-Kernel API
-----------
-
-Here's a summary of the API relayfs provides to in-kernel clients:
-
-int relay_open(channel_path, bufsize, nbufs, channel_flags,
- channel_callbacks, start_reserve, end_reserve,
- rchan_start_reserve, resize_min, resize_max, mode,
- init_buf, init_buf_size)
-int relay_write(channel_id, *data_ptr, count, time_delta_offset, **wrote)
-rchan_reader *add_rchan_reader(channel_id, auto_consume)
-int remove_rchan_reader(rchan_reader *reader)
-rchan_reader *add_map_reader(channel_id)
-int remove_map_reader(rchan_reader *reader)
-int relay_read(reader, buf, count, wait, *actual_read_offset)
-void relay_buffers_consumed(reader, buffers_consumed)
-void relay_bytes_consumed(reader, bytes_consumed, read_offset)
-int relay_bytes_avail(reader)
-int rchan_full(reader)
-int rchan_empty(reader)
-int relay_info(channel_id, *channel_info)
-int relay_close(channel_id)
-int relay_realloc_buffer(channel_id, nbufs, async)
-int relay_replace_buffer(channel_id)
-int relay_reset(int rchan_id)
-
-----------
-int relay_open(channel_path, bufsize, nbufs,
- channel_flags, channel_callbacks, start_reserve,
- end_reserve, rchan_start_reserve, resize_min, resize_max, mode)
-
-relay_open() is used to create a new entry in relayfs. This new entry
-is created according to channel_path. channel_path contains the
-absolute path to the channel file on relayfs. If, for example, the
-caller sets channel_path to "/xlog/9", a "xlog/9" entry will appear
-within relayfs automatically and the "xlog" directory will be created
-in the filesystem's root. relayfs does not implement any policy on
-its content, except to disallow the opening of two channels using the
-same file. There are, nevertheless a set of guidelines for using
-relayfs. Basically, each facility using relayfs should use a top-level
-directory identifying it. The entry created above, for example,
-presumably belongs to the "xlog" software.
-
-The remaining parameters for relay_open() are as follows:
-
-- channel_flags - an ORed combination of attribute values controlling
- common channel characteristics:
-
- - logging scheme - relayfs use 2 mutually exclusive schemes
- for logging data to a channel. The 'lockless scheme'
- reserves and writes data to a channel without the need of
- any type of locking on the channel. This is the preferred
- scheme, but may not be available on a given architecture (it
- relies on the presence of a cmpxchg instruction). It's
- specified by the RELAY_SCHEME_LOCKLESS flag. The 'locking
- scheme' either obtains a lock on the channel for writing or
- disables interrupts, depending on whether the channel was
- opened for SMP or global usage (see below). It's specified
- by the RELAY_SCHEME_LOCKING flag. While a client may want
- to explicitly specify a particular scheme to use, it's more
- convenient to specify RELAY_SCHEME_ANY for this flag, which
- will allow relayfs to choose the best available scheme i.e.
- lockless if supported.
-
- - overwrite mode (default is RELAY_MODE_CONTINUOUS) -
- If RELAY_MODE_CONTINUOUS is specified, writes to the channel
- will succeed regardless of whether there are up-to-date
- consumers or not. If RELAY_MODE_NO_OVERWRITE is specified,
- the channel becomes 'full' when the total amount of buffer
- space unconsumed by readers equals or exceeds the total
- buffer size. With the buffer in this state, writes to the
- buffer will fail - clients need to check the return code from
- relay_write() to determine if this is the case and act
- accordingly - 0 or a negative value indicate the write failed.
-
- - SMP usage - this applies only when the locking scheme is in
- use. If RELAY_USAGE_SMP is specified, it's assumed that the
- channel will be used in a per-CPU fashion and consequently,
- the only locking that will be done for writes is to disable
- local irqs. If RELAY_USAGE_GLOBAL is specified, it's assumed
- that writes to the buffer can occur within any CPU context,
- and spinlock_irq_save will be used to lock the buffer.
-
- - delivery mode - if RELAY_DELIVERY_BULK is specified, the
- client will be notified via its deliver() callback whenever a
- sub-buffer has been filled. Alternatively,
- RELAY_DELIVERY_PACKET will cause delivery to occur after the
- completion of each write. See the description of the channel
- callbacks below for more details.
-
- - timestamping - if RELAY_TIMESTAMP_TSC is specified and the
- architecture supports it, efficient TSC 'timestamps' can be
- associated with each write, otherwise more expensive
- gettimeofday() timestamping is used. At the beginning of
- each sub-buffer, a gettimeofday() timestamp and the current
- TSC, if supported, are read, and are passed on to the client
- via the buffer_start() callback. This allows correlation of
- the current time with the current TSC for subsequent writes.
- Each subsequent write is associated with a 'time delta',
- which is either the current TSC, if the channel is using
- TSCs, or the difference between the buffer_start gettimeofday
- timestamp and the gettimeofday time read for the current
- write. Note that relayfs never writes either a timestamp or
- time delta into the buffer unless explicitly asked to (see
- the description of relay_write() for details).
-
-- bufsize - the size of the 'sub-buffers' making up the circular channel
- buffer. For the lockless scheme, this must be a power of 2.
-
-- nbufs - the number of 'sub-buffers' making up the circular
- channel buffer. This must be a power of 2.
-
- The total size of the channel buffer is bufsize * nbufs rounded up
- to the next kernel page size. If the lockless scheme is used, both
- bufsize and nbufs must be a power of 2. If the locking scheme is
- used, the bufsize can be anything and nbufs must be a power of 2. If
- RELAY_SCHEME_ANY is used, the bufsize and nbufs should be a power of 2.
-
- NOTE: if nbufs is 1, relayfs will bypass the normal size
- checks and will allocate an rvmalloced buffer of size bufsize.
- This buffer will be freed when relay_close() is called, if the channel
- isn't still being referenced.
-
-- callbacks - a table of callback functions called when events occur
- within the data relay that clients need to know about:
-
- - int buffer_start(channel_id, current_write_pos, buffer_id,
- start_time, start_tsc, using_tsc) -
-
- called at the beginning of a new sub-buffer, the
- buffer_start() callback gives the client an opportunity to
- write data into space reserved at the beginning of a
- sub-buffer. The client should only write into the buffer
- if it specified a value for start_reserve and/or
- channel_start_reserve (see below) when the channel was
- opened. In the latter case, the client can determine
- whether to write its one-time rchan_start_reserve data by
- examining the value of buffer_id, which will be 0 for the
- first sub-buffer. The address that the client can write
- to is contained in current_write_pos (the client by
- definition knows how much it can write i.e. the value it
- passed to relay_open() for start_reserve/
- channel_start_reserve). start_time contains the
- gettimeofday() value for the start of the buffer and start
- TSC contains the TSC read at the same time. The using_tsc
- param indicates whether or not start_tsc is valid (it
- wouldn't be if TSC timestamping isn't being used).
-
- The client should return the number of bytes it wrote to
- the channel, 0 if none.
-
- - int buffer_end(channel_id, current_write_pos, end_of_buffer,
- end_time, end_tsc, using_tsc)
-
- called at the end of a sub-buffer, the buffer_end()
- callback gives the client an opportunity to perform
- end-of-buffer processing. Note that the current_write_pos
- is the position where the next write would occur, but
- since the current write wouldn't fit (which is the trigger
- for the buffer_end event), the buffer is considered full
- even though there may be unused space at the end. The
- end_of_buffer param pointer value can be used to determine
- exactly the size of the unused space. The client should
- only write into the buffer if it specified a value for
- end_reserve when the channel was opened. If the client
- doesn't write anything i.e. returns 0, the unused space at
- the end of the sub-buffer is available via relay_info() -
- this data may be needed by the client later if it needs to
- process raw sub-buffers (an alternative would be to save
- the unused bytes count value in end_reserve space at the
- end of each sub-buffer during buffer_end processing and
- read it when needed at a later time. The other
- alternative would be to use read(2), which makes the
- unused count invisible to the caller). end_time contains
- the gettimeofday() value for the end of the buffer and end
- TSC contains the TSC read at the same time. The using_tsc
- param indicates whether or not end_tsc is valid (it
- wouldn't be if TSC timestamping isn't being used).
-
- The client should return the number of bytes it wrote to
- the channel, 0 if none.
-
- - void deliver(channel_id, from, len)
-
- called when data is ready for the client. This callback
- is used to notify a client when a sub-buffer is complete
- (in the case of bulk delivery) or a single write is
- complete (packet delivery). A bulk delivery client might
- wish to then signal a daemon that a sub-buffer is ready.
- A packet delivery client might wish to process the packet
- or send it elsewhere. The from param is a pointer to the
- delivered data and len specifies how many bytes are ready.
-
- - void user_deliver(channel_id, from, len)
-
- called when data has been written to the channel from user
- space. This callback is used to notify a client when a
- successful write from userspace has occurred, independent
- of whether bulk or packet delivery is in use. This can be
- used to allow userspace programs to communicate with the
- kernel client through the channel via out-of-band write(2)
- 'commands' instead of via ioctls, for instance. The from
- param is a pointer to the delivered data and len specifies
- how many bytes are ready. Note that this callback occurs
- after the bytes have been successfully written into the
- channel, which means that channel readers must be able to
- deal with the 'command' data which will appear in the
- channel data stream just as any other userspace or
- non-userspace write would.
-
- - int needs_resize(channel_id, resize_type,
- suggested_buf_size, suggested_n_bufs)
-
- called when a channel's buffers are in danger of becoming
- full i.e. the number of unread bytes in the channel passes
- a preset threshold, or when the current capacity of a
- channel's buffer is no longer needed. Also called to
- notify the client when a channel's buffer has been
- replaced. If resize_type is RELAY_RESIZE_EXPAND or
- RELAY_RESIZE_SHRINK, the kernel client should arrange to
- call relay_realloc_buffer() with the suggested buffer size
- and buffer count, which will allocate (but will not
- replace the old one) a new buffer of the recommended size
- for the channel. When the allocation has completed,
- needs_resize() is again called, this time with a
- resize_type of RELAY_RESIZE_REPLACE. The kernel client
- should then arrange to call relay_replace_buffer() to
- actually replace the old channel buffer with the newly
- allocated buffer. Finally, once the buffer replacement
- has completed, needs_resize() is again called, this time
- with a resize_type of RELAY_RESIZE_REPLACED, to inform the
- client that the replacement is complete and additionally
- confirming the current sub-buffer size and number of
- sub-buffers. Note that a resize can be canceled if
- relay_realloc_buffer() is called with the async param
- non-zero and the resize conditions no longer hold. In
- this case, the RELAY_RESIZE_REPLACED suggested number of
- sub-buffers will be the same as the number of sub-buffers
- that existed before the RELAY_RESIZE_SHRINK or EXPAND i.e.
- values indicating that the resize didn't actually occur.
-
- - int fileop_notify(channel_id, struct file *filp, enum relay_fileop)
-
- called when a userspace file operation has occurred or
- will occur on a relayfs channel file. These notifications
- can be used by the kernel client to trigger actions within
- the kernel client when the corresponding event occurs,
- such as enabling logging only when a userspace application
- opens or mmaps a relayfs file and disabling it again when
- the file is closed or unmapped. The kernel client can
- also return its own return value, which can affect the
- outcome of file operation - returning 0 indicates that the
- operation should succeed, and returning a negative value
- indicates that the operation should be failed, and that
- the returned value should be returned to the ultimate
- caller e.g. returning -EPERM from the open fileop will
- cause the open to fail with -EPERM. Among other things,
- the return value can be used to restrict a relayfs file
- from being opened or mmap'ed more than once. The currently
- implemented fileops are:
-
- RELAY_FILE_OPEN - a relayfs file is being opened. Return
- 0 to allow it to succeed, negative to
- have it fail. A negative return value will
- be passed on unmodified to the open fileop.
- RELAY_FILE_CLOSE- a relayfs file is being closed. The return
- value is ignored.
- RELAY_FILE_MAP - a relayfs file is being mmap'ed. Return 0
- to allow it to succeed, negative to have
- it fail. A negative return value will be
- passed on unmodified to the mmap fileop.
- RELAY_FILE_UNMAP- a relayfs file is being unmapped. The return
- value is ignored.
-
- - void ioctl(rchan_id, cmd, arg)
-
- called when an ioctl call is made using a relayfs file
- descriptor. The cmd and arg are passed along to this
- callback unmodified for it to do as it wishes with. The
- return value from this callback is used as the return value
- of the ioctl call.
-
- If the callbacks param passed to relay_open() is NULL, a set of
- default do-nothing callbacks will be defined for the channel.
- Likewise, any NULL rchan_callback function contained in a non-NULL
- callbacks struct will be filled in with a default callback function
- that does nothing.
-
-- start_reserve - the number of bytes to be reserved at the start of
- each sub-buffer. The client can do what it wants with this number
- of bytes when the buffer_start() callback is invoked. Typically
- clients would use this to write per-sub-buffer header data.
-
-- end_reserve - the number of bytes to be reserved at the end of each
- sub-buffer. The client can do what it wants with this number of
- bytes when the buffer_end() callback is invoked. Typically clients
- would use this to write per-sub-buffer footer data.
-
-- channel_start_reserve - the number of bytes to be reserved, in
- addition to start_reserve, at the beginning of the first sub-buffer
- in the channel. The client can do what it wants with this number of
- bytes when the buffer_start() callback is invoked. Typically
- clients would use this to write per-channel header data.
-
-- resize_min - if set, this signifies that the channel is
- auto-resizeable. The value specifies the size that the channel will
- try to maintain as a normal working size, and that it won't go
- below. The client makes use of the resizing callbacks and
- relay_realloc_buffer() and relay_replace_buffer() to actually effect
- the resize.
-
-- resize_max - if set, this signifies that the channel is
- auto-resizeable. The value specifies the maximum size the channel
- can have as a result of resizing.
-
-- mode - if non-zero, specifies the file permissions that will be given
- to the channel file. If 0, the default rw user perms will be used.
-
-- init_buf - if non-NULL, rather than allocating the channel buffer,
- this buffer will be used as the initial channel buffer. The kernel
- API function relay_discard_init_buf() can later be used to have
- relayfs allocate a normal mmappable channel buffer and switch over
- to using it after copying the init_buf contents into it. Currently,
- the size of init_buf must be exactly buf_size * n_bufs. The caller
- is responsible for managing the init_buf memory. This feature is
- typically used for init-time channel use and should normally be
- specified as NULL.
-
-- init_buf_size - the total size of init_buf, if init_buf is specified
- as non-NULL. Currently, the size of init_buf must be exactly
- buf_size * n_bufs.
-
-Upon successful completion, relay_open() returns a channel id
-to be used for all other operations with the relay. All buffers
-managed by the relay are allocated using rvmalloc/rvfree to allow
-for easy mmapping to user-space.
-
-----------
-int relay_write(channel_id, *data_ptr, count, time_delta_offset, **wrote_pos)
-
-relay_write() reserves space in the channel and writes count bytes of
-data pointed to by data_ptr to it. Automatically performs any
-necessary locking, depending on the scheme and SMP usage in effect (no
-locking is done for the lockless scheme regardless of usage). It
-returns the number of bytes written, or 0/negative on failure. If
-time_delta_offset is >= 0, the internal time delta, the internal time
-delta calculated when the slot was reserved will be written at that
-offset. This is the TSC or gettimeofday() delta between the current
-write and the beginning of the buffer, whichever method is being used
-by the channel. Trying to write a count larger than the bufsize
-specified to relay_open() (taking into account the reserved
-start-of-buffer and end-of-buffer space as well) will fail. If
-wrote_pos is non-NULL, it will receive the location the data was
-written to, which may be needed for some applications but is not
-normally interesting. Most applications should pass in NULL for this
-param.
-
-----------
-struct rchan_reader *add_rchan_reader(int rchan_id, int auto_consume)
-
-add_rchan_reader creates and initializes a reader object for a
-channel. An opaque rchan_reader object is returned on success, and is
-passed to relay_read() when reading the channel. If the boolean
-auto_consume parameter is 1, the reader is defined to be
-auto-consuming. auto-consuming reader objects are automatically
-created and used for VFS read(2) readers.
-
-----------
-void remove_rchan_reader(struct rchan_reader *reader)
-
-remove_rchan_reader finds and removes the given reader from the
-channel. This function is used only by non-VFS read(2) readers. VFS
-read(2) readers are automatically removed when the corresponding file
-object is closed.
-
-----------
-reader add_map_reader(int rchan_id)
-
-Creates and initializes an rchan_reader object for channel map
-readers, and is needed for updating relay_bytes/buffers_consumed()
-when kernel clients become aware of the need to do so by their mmap
-user clients.
-
-----------
-int remove_map_reader(reader)
-
-Finds and removes the given map reader from the channel. This function
-is useful only for map readers.
-
-----------
-int relay_read(reader, buf, count, wait, *actual_read_offset)
-
-Reads count bytes from the channel, or as much as is available within
-the sub-buffer currently being read. The read offset that will be
-read from is the position contained within the reader object. If the
-wait flag is set, buf is non-NULL, and there is nothing available, it
-will wait until there is. If the wait flag is 0 and there is nothing
-available, -EAGAIN is returned. If buf is NULL, the value returned is
-the number of bytes that would have been read. actual_read_offset is
-the value that should be passed as the read offset to
-relay_bytes_consumed, needed only if the reader is not auto-consuming
-and the channel is MODE_NO_OVERWRITE, but in any case, it must not be
-NULL.
-
-----------
-
-int relay_bytes_avail(reader)
-
-Returns the number of bytes available relative to the reader's current
-read position within the corresponding sub-buffer, 0 if there is
-nothing available. Note that this doesn't return the total bytes
-available in the channel buffer - this is enough though to know if
-anything is available, however, or how many bytes might be returned
-from the next read.
-
-----------
-void relay_buffers_consumed(reader, buffers_consumed)
-
-Adds to the channel's consumed buffer count. buffers_consumed should
-be the number of buffers newly consumed, not the total number
-consumed. NOTE: kernel clients don't need to call this function if
-the reader is auto-consuming or the channel is MODE_CONTINUOUS.
-
-In order for the relay to detect the 'buffers full' condition for a
-channel, it must be kept up-to-date with respect to the number of
-buffers consumed by the client. If the addition of the value of the
-bufs_consumed param to the current bufs_consumed count for the channel
-would exceed the bufs_produced count for the channel, the channel's
-bufs_consumed count will be set to the bufs_produced count for the
-channel. This allows clients to 'catch up' if necessary.
-
-----------
-void relay_bytes_consumed(reader, bytes_consumed, read_offset)
-
-Adds to the channel's consumed count. bytes_consumed should be the
-number of bytes actually read e.g. return value of relay_read() and
-the read_offset should be the actual offset the bytes were read from
-e.g. the actual_read_offset set by relay_read(). NOTE: kernel clients
-don't need to call this function if the reader is auto-consuming or
-the channel is MODE_CONTINUOUS.
-
-In order for the relay to detect the 'buffers full' condition for a
-channel, it must be kept up-to-date with respect to the number of
-bytes consumed by the client. For packet clients, it makes more sense
-to update after each read rather than after each complete sub-buffer
-read. The bytes_consumed count updates bufs_consumed when a buffer
-has been consumed so this count remains consistent.
-
-----------
-int relay_info(channel_id, *channel_info)
-
-relay_info() fills in an rchan_info struct with channel status and
-attribute information such as usage modes, sub-buffer size and count,
-the allocated size of the entire buffer, buffers produced and
-consumed, current buffer id, count of writes lost due to buffers full
-condition.
-
-The virtual address of the channel buffer is also available here, for
-those clients that need it.
-
-Clients may need to know how many 'unused' bytes there are at the end
-of a given sub-buffer. This would only be the case if the client 1)
-didn't either write this count to the end of the sub-buffer or
-otherwise note it (it's available as the difference between the buffer
-end and current write pos params in the buffer_end callback) (if the
-client returned 0 from the buffer_end callback, it's assumed that this
-is indeed the case) 2) isn't using the read() system call to read the
-buffer. In other words, if the client isn't annotating the stream and
-is reading the buffer by mmaping it, this information would be needed
-in order for the client to 'skip over' the unused bytes at the ends of
-sub-buffers.
-
-Additionally, for the lockless scheme, clients may need to know
-whether a particular sub-buffer is actually complete. An array of
-boolean values, one per sub-buffer, contains non-zero if the buffer is
-complete, non-zero otherwise.
-
-----------
-int relay_close(channel_id)
-
-relay_close() is used to close the channel. It finalizes the last
-sub-buffer (the one currently being written to) and marks the channel
-as finalized. The channel buffer and channel data structure are then
-freed automatically when the last reference to the channel is given
-up.
-
-----------
-int relay_realloc_buffer(channel_id, nbufs, async)
-
-Allocates a new channel buffer using the specified sub-buffer count
-(note that resizing can't change sub-buffer sizes). If async is
-non-zero, the allocation is done in the background using a work queue.
-When the allocation has completed, the needs_resize() callback is
-called with a resize_type of RELAY_RESIZE_REPLACE. This function
-doesn't replace the old buffer with the new - see
-relay_replace_buffer().
-
-This function is called by kernel clients in response to a
-needs_resize() callback call with a resize type of RELAY_RESIZE_EXPAND
-or RELAY_RESIZE_SHRINK. That callback also includes a suggested
-new_bufsize and new_nbufs which should be used when calling this
-function.
-
-Returns 0 on success, or errcode if the channel is busy or if
-the allocation couldn't happen for some reason.
-
-NOTE: if async is not set, this function should not be called with a
-lock held, as it may sleep.
-
-----------
-int relay_replace_buffer(channel_id)
-
-Replaces the current channel buffer with the new buffer allocated by
-relay_realloc_buffer and contained in the channel struct. When the
-replacement is complete, the needs_resize() callback is called with
-RELAY_RESIZE_REPLACED. This function is called by kernel clients in
-response to a needs_resize() callback having a resize type of
-RELAY_RESIZE_REPLACE.
-
-Returns 0 on success, or errcode if the channel is busy or if the
-replacement or previous allocation didn't happen for some reason.
-
-NOTE: This function will not sleep, so can called in any context and
-with locks held. The client should, however, ensure that the channel
-isn't actively being read from or written to.
-
-----------
-int relay_reset(rchan_id)
-
-relay_reset() has the effect of erasing all data from the buffer and
-restarting the channel in its initial state. The buffer itself is not
-freed, so any mappings are still in effect. NOTE: Care should be
-taken that the channnel isn't actually being used by anything when
-this call is made.
-
-----------
-int rchan_full(reader)
-
-returns 1 if the channel is full with respect to the reader, 0 if not.
-
-----------
-int rchan_empty(reader)
-
-returns 1 if the channel is empty with respect to the reader, 0 if not.
-
-----------
-int relay_discard_init_buf(rchan_id)
-
-allocates an mmappable channel buffer, copies the contents of init_buf
-into it, and sets the current channel buffer to the newly allocated
-buffer. This function is used only in conjunction with the init_buf
-and init_buf_size params to relay_open(), and is typically used when
-the ability to write into the channel at init-time is needed. The
-basic usage is to specify an init_buf and init_buf_size to relay_open,
-then call this function when it's safe to switch over to a normally
-allocated channel buffer. 'Safe' means that the caller is in a
-context that can sleep and that nothing is actively writing to the
-channel. Returns 0 if successful, negative otherwise.
-
-
-Writing directly into the channel
-=================================
-
-Using the relay_write() API function as described above is the
-preferred means of writing into a channel. In some cases, however,
-in-kernel clients might want to write directly into a relay channel
-rather than have relay_write() copy it into the buffer on the client's
-behalf. Clients wishing to do this should follow the model used to
-implement relay_write itself. The general sequence is:
-
-- get a pointer to the channel via rchan_get(). This increments the
- channel's reference count.
-- call relay_lock_channel(). This will perform the proper locking for
- the channel given the scheme in use and the SMP usage.
-- reserve a slot in the channel via relay_reserve()
-- write directly to the reserved address
-- call relay_commit() to commit the write
-- call relay_unlock_channel()
-- call rchan_put() to release the channel reference
-
-In particular, clients should make sure they call rchan_get() and
-rchan_put() and not hold on to references to the channel pointer.
-Also, forgetting to use relay_lock_channel()/relay_unlock_channel()
-has no effect if the lockless scheme is being used, but could result
-in corrupted buffer contents if the locking scheme is used.
-
-
-Limitations
-===========
-
-Writes made via the write() system call are currently limited to 2
-pages worth of data. There is no such limit on the in-kernel API
-function relay_write().
-
-User applications can currently only mmap the complete buffer (it
-doesn't really make sense to mmap only part of it, given its purpose).
-
-
-Latest version
-==============
-
-The latest version can be found at:
-
-http://www.opersys.com/relayfs
-
-Example relayfs clients, such as dynamic printk and the Linux Trace
-Toolkit, can also be found there.
-
-
-Credits
-=======
-
-The ideas and specs for relayfs came about as a result of discussions
-on tracing involving the following:
-
-Michel Dagenais <michel.dagenais@polymtl.ca>
-Richard Moore <richardj_moore@uk.ibm.com>
-Bob Wisniewski <bob@watson.ibm.com>
-Karim Yaghmour <karim@opersys.com>
-Tom Zanussi <zanussi@us.ibm.com>
-
-Also thanks to Hubertus Franke for a lot of useful suggestions and bug
-reports, and for contributing the klog code.
+++ /dev/null
-/* $Id: ide.c,v 1.1 2004/01/22 08:22:58 starvik Exp $
- *
- * Etrax specific IDE functions, like init and PIO-mode setting etc.
- * Almost the entire ide.c is used for the rest of the Etrax ATA driver.
- * Copyright (c) 2000-2004 Axis Communications AB
- *
- * Authors: Bjorn Wesen (initial version)
- * Mikael Starvik (pio setup stuff, Linux 2.6 port)
- */
-
-/* Regarding DMA:
- *
- * There are two forms of DMA - "DMA handshaking" between the interface and the drive,
- * and DMA between the memory and the interface. We can ALWAYS use the latter, since it's
- * something built-in in the Etrax. However only some drives support the DMA-mode handshaking
- * on the ATA-bus. The normal PC driver and Triton interface disables memory-if DMA when the
- * device can't do DMA handshaking for some stupid reason. We don't need to do that.
- */
-
-#undef REALLY_SLOW_IO /* most systems can safely undef this */
-
-#include <linux/config.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/timer.h>
-#include <linux/mm.h>
-#include <linux/interrupt.h>
-#include <linux/delay.h>
-#include <linux/blkdev.h>
-#include <linux/hdreg.h>
-#include <linux/ide.h>
-#include <linux/init.h>
-
-#include <asm/io.h>
-#include <asm/arch/svinto.h>
-#include <asm/dma.h>
-
-/* number of Etrax DMA descriptors */
-#define MAX_DMA_DESCRS 64
-
-/* number of times to retry busy-flags when reading/writing IDE-registers
- * this can't be too high because a hung harddisk might cause the watchdog
- * to trigger (sometimes INB and OUTB are called with irq's disabled)
- */
-
-#define IDE_REGISTER_TIMEOUT 300
-
-#ifdef CONFIG_ETRAX_IDE_CSE1_16_RESET
-/* address where the memory-mapped IDE reset bit lives, if used */
-static volatile unsigned long *reset_addr;
-#endif
-
-static int e100_read_command = 0;
-
-#define LOWDB(x)
-#define D(x)
-
-void
-etrax100_ide_outw(unsigned short data, ide_ioreg_t reg) {
- int timeleft;
- LOWDB(printk("ow: data 0x%x, reg 0x%x\n", data, reg));
-
- /* note the lack of handling any timeouts. we stop waiting, but we don't
- * really notify anybody.
- */
-
- timeleft = IDE_REGISTER_TIMEOUT;
- /* wait for busy flag */
- while(timeleft && (*R_ATA_STATUS_DATA & IO_MASK(R_ATA_STATUS_DATA, busy)))
- timeleft--;
-
- /*
- * Fall through at a timeout, so the ongoing command will be
- * aborted by the write below, which is expected to be a dummy
- * command to the command register. This happens when a faulty
- * drive times out on a command. See comment on timeout in
- * INB.
- */
- if(!timeleft)
- printk("ATA timeout reg 0x%lx := 0x%x\n", reg, data);
-
- *R_ATA_CTRL_DATA = reg | data; /* write data to the drive's register */
-
- timeleft = IDE_REGISTER_TIMEOUT;
- /* wait for transmitter ready */
- while(timeleft && !(*R_ATA_STATUS_DATA &
- IO_MASK(R_ATA_STATUS_DATA, tr_rdy)))
- timeleft--;
-}
-
-void
-etrax100_ide_outb(unsigned char data, ide_ioreg_t reg)
-{
- etrax100_ide_outw(data, reg);
-}
-
-void
-etrax100_ide_outbsync(ide_drive_t *drive, u8 addr, unsigned long port)
-{
- etrax100_ide_outw(addr, port);
-}
-
-unsigned short
-etrax100_ide_inw(ide_ioreg_t reg) {
- int status;
- int timeleft;
-
- timeleft = IDE_REGISTER_TIMEOUT;
- /* wait for busy flag */
- while(timeleft && (*R_ATA_STATUS_DATA & IO_MASK(R_ATA_STATUS_DATA, busy)))
- timeleft--;
-
- if(!timeleft) {
- /*
- * If we're asked to read the status register, like for
- * example when a command does not complete for an
- * extended time, but the ATA interface is stuck in a
- * busy state at the *ETRAX* ATA interface level (as has
- * happened repeatedly with at least one bad disk), then
- * the best thing to do is to pretend that we read
- * "busy" in the status register, so the IDE driver will
- * time-out, abort the ongoing command and perform a
- * reset sequence. Note that the subsequent OUT_BYTE
- * call will also timeout on busy, but as long as the
- * write is still performed, everything will be fine.
- */
- if ((reg & IO_MASK (R_ATA_CTRL_DATA, addr))
- == IO_FIELD (R_ATA_CTRL_DATA, addr, IDE_STATUS_OFFSET))
- return BUSY_STAT;
- else
- /* For other rare cases we assume 0 is good enough. */
- return 0;
- }
-
- *R_ATA_CTRL_DATA = reg | IO_STATE(R_ATA_CTRL_DATA, rw, read); /* read data */
-
- timeleft = IDE_REGISTER_TIMEOUT;
- /* wait for available */
- while(timeleft && !((status = *R_ATA_STATUS_DATA) &
- IO_MASK(R_ATA_STATUS_DATA, dav)))
- timeleft--;
-
- if(!timeleft)
- return 0;
-
- LOWDB(printk("inb: 0x%x from reg 0x%x\n", status & 0xff, reg));
-
- return (unsigned short)status;
-}
-
-unsigned char
-etrax100_ide_inb(ide_ioreg_t reg)
-{
- return (unsigned char)etrax100_ide_inw(reg);
-}
-
-/* PIO timing (in R_ATA_CONFIG)
- *
- * _____________________________
- * ADDRESS : ________/
- *
- * _______________
- * DIOR : ____________/ \__________
- *
- * _______________
- * DATA : XXXXXXXXXXXXXXXX_______________XXXXXXXX
- *
- *
- * DIOR is unbuffered while address and data is buffered.
- * This creates two problems:
- * 1. The DIOR pulse is to early (because it is unbuffered)
- * 2. The rise time of DIOR is long
- *
- * There are at least three different plausible solutions
- * 1. Use a pad capable of larger currents in Etrax
- * 2. Use an external buffer
- * 3. Make the strobe pulse longer
- *
- * Some of the strobe timings below are modified to compensate
- * for this. This implies a slight performance decrease.
- *
- * THIS SHOULD NEVER BE CHANGED!
- *
- * TODO: Is this true for the latest LX boards still ?
- */
-
-#define ATA_DMA2_STROBE 4
-#define ATA_DMA2_HOLD 0
-#define ATA_DMA1_STROBE 4
-#define ATA_DMA1_HOLD 1
-#define ATA_DMA0_STROBE 12
-#define ATA_DMA0_HOLD 9
-#define ATA_PIO4_SETUP 1
-#define ATA_PIO4_STROBE 5
-#define ATA_PIO4_HOLD 0
-#define ATA_PIO3_SETUP 1
-#define ATA_PIO3_STROBE 5
-#define ATA_PIO3_HOLD 1
-#define ATA_PIO2_SETUP 1
-#define ATA_PIO2_STROBE 6
-#define ATA_PIO2_HOLD 2
-#define ATA_PIO1_SETUP 2
-#define ATA_PIO1_STROBE 11
-#define ATA_PIO1_HOLD 4
-#define ATA_PIO0_SETUP 4
-#define ATA_PIO0_STROBE 19
-#define ATA_PIO0_HOLD 4
-
-static int e100_dma_check (ide_drive_t *drive);
-static int e100_dma_begin (ide_drive_t *drive);
-static int e100_dma_end (ide_drive_t *drive);
-static int e100_dma_read (ide_drive_t *drive);
-static int e100_dma_write (ide_drive_t *drive);
-static void e100_ide_input_data (ide_drive_t *drive, void *, unsigned int);
-static void e100_ide_output_data (ide_drive_t *drive, void *, unsigned int);
-static void e100_atapi_input_bytes(ide_drive_t *drive, void *, unsigned int);
-static void e100_atapi_output_bytes(ide_drive_t *drive, void *, unsigned int);
-static int e100_dma_off (ide_drive_t *drive);
-static int e100_dma_verbose (ide_drive_t *drive);
-
-
-/*
- * good_dma_drives() lists the model names (from "hdparm -i")
- * of drives which do not support mword2 DMA but which are
- * known to work fine with this interface under Linux.
- */
-
-const char *good_dma_drives[] = {"Micropolis 2112A",
- "CONNER CTMA 4000",
- "CONNER CTT8000-A",
- NULL};
-
-static void tune_e100_ide(ide_drive_t *drive, byte pio)
-{
- pio = 4;
- /* pio = ide_get_best_pio_mode(drive, pio, 4, NULL); */
-
- /* set pio mode! */
-
- switch(pio) {
- case 0:
- *R_ATA_CONFIG = ( IO_FIELD( R_ATA_CONFIG, enable, 1 ) |
- IO_FIELD( R_ATA_CONFIG, dma_strobe, ATA_DMA2_STROBE ) |
- IO_FIELD( R_ATA_CONFIG, dma_hold, ATA_DMA2_HOLD ) |
- IO_FIELD( R_ATA_CONFIG, pio_setup, ATA_PIO0_SETUP ) |
- IO_FIELD( R_ATA_CONFIG, pio_strobe, ATA_PIO0_STROBE ) |
- IO_FIELD( R_ATA_CONFIG, pio_hold, ATA_PIO0_HOLD ) );
- break;
- case 1:
- *R_ATA_CONFIG = ( IO_FIELD( R_ATA_CONFIG, enable, 1 ) |
- IO_FIELD( R_ATA_CONFIG, dma_strobe, ATA_DMA2_STROBE ) |
- IO_FIELD( R_ATA_CONFIG, dma_hold, ATA_DMA2_HOLD ) |
- IO_FIELD( R_ATA_CONFIG, pio_setup, ATA_PIO1_SETUP ) |
- IO_FIELD( R_ATA_CONFIG, pio_strobe, ATA_PIO1_STROBE ) |
- IO_FIELD( R_ATA_CONFIG, pio_hold, ATA_PIO1_HOLD ) );
- break;
- case 2:
- *R_ATA_CONFIG = ( IO_FIELD( R_ATA_CONFIG, enable, 1 ) |
- IO_FIELD( R_ATA_CONFIG, dma_strobe, ATA_DMA2_STROBE ) |
- IO_FIELD( R_ATA_CONFIG, dma_hold, ATA_DMA2_HOLD ) |
- IO_FIELD( R_ATA_CONFIG, pio_setup, ATA_PIO2_SETUP ) |
- IO_FIELD( R_ATA_CONFIG, pio_strobe, ATA_PIO2_STROBE ) |
- IO_FIELD( R_ATA_CONFIG, pio_hold, ATA_PIO2_HOLD ) );
- break;
- case 3:
- *R_ATA_CONFIG = ( IO_FIELD( R_ATA_CONFIG, enable, 1 ) |
- IO_FIELD( R_ATA_CONFIG, dma_strobe, ATA_DMA2_STROBE ) |
- IO_FIELD( R_ATA_CONFIG, dma_hold, ATA_DMA2_HOLD ) |
- IO_FIELD( R_ATA_CONFIG, pio_setup, ATA_PIO3_SETUP ) |
- IO_FIELD( R_ATA_CONFIG, pio_strobe, ATA_PIO3_STROBE ) |
- IO_FIELD( R_ATA_CONFIG, pio_hold, ATA_PIO3_HOLD ) );
- break;
- case 4:
- *R_ATA_CONFIG = ( IO_FIELD( R_ATA_CONFIG, enable, 1 ) |
- IO_FIELD( R_ATA_CONFIG, dma_strobe, ATA_DMA2_STROBE ) |
- IO_FIELD( R_ATA_CONFIG, dma_hold, ATA_DMA2_HOLD ) |
- IO_FIELD( R_ATA_CONFIG, pio_setup, ATA_PIO4_SETUP ) |
- IO_FIELD( R_ATA_CONFIG, pio_strobe, ATA_PIO4_STROBE ) |
- IO_FIELD( R_ATA_CONFIG, pio_hold, ATA_PIO4_HOLD ) );
- break;
- }
-}
-
-void __init
-init_e100_ide (void)
-{
- volatile unsigned int dummy;
- int h;
-
- printk("ide: ETRAX 100LX built-in ATA DMA controller\n");
-
- /* first fill in some stuff in the ide_hwifs fields */
-
- for(h = 0; h < MAX_HWIFS; h++) {
- ide_hwif_t *hwif = &ide_hwifs[h];
- hwif->mmio = 2;
- hwif->chipset = ide_etrax100;
- hwif->tuneproc = &tune_e100_ide;
- hwif->ata_input_data = &e100_ide_input_data;
- hwif->ata_output_data = &e100_ide_output_data;
- hwif->atapi_input_bytes = &e100_atapi_input_bytes;
- hwif->atapi_output_bytes = &e100_atapi_output_bytes;
- hwif->ide_dma_check = &e100_dma_check;
- hwif->ide_dma_end = &e100_dma_end;
- hwif->ide_dma_write = &e100_dma_write;
- hwif->ide_dma_read = &e100_dma_read;
- hwif->ide_dma_begin = &e100_dma_begin;
- hwif->OUTB = &etrax100_ide_outb;
- hwif->OUTW = &etrax100_ide_outw;
- hwif->OUTBSYNC = &etrax100_ide_outbsync;
- hwif->INB = &etrax100_ide_inb;
- hwif->INW = &etrax100_ide_inw;
- hwif->ide_dma_off_quietly = &e100_dma_off;
- hwif->ide_dma_verbose = &e100_dma_verbose;
- hwif->sg_table =
- kmalloc(sizeof(struct scatterlist) * PRD_ENTRIES, GFP_KERNEL);
- }
-
- /* actually reset and configure the etrax100 ide/ata interface */
-
- *R_ATA_CTRL_DATA = 0;
- *R_ATA_TRANSFER_CNT = 0;
- *R_ATA_CONFIG = 0;
-
- genconfig_shadow = (genconfig_shadow &
- ~IO_MASK(R_GEN_CONFIG, dma2) &
- ~IO_MASK(R_GEN_CONFIG, dma3) &
- ~IO_MASK(R_GEN_CONFIG, ata)) |
- ( IO_STATE( R_GEN_CONFIG, dma3, ata ) |
- IO_STATE( R_GEN_CONFIG, dma2, ata ) |
- IO_STATE( R_GEN_CONFIG, ata, select ) );
-
- *R_GEN_CONFIG = genconfig_shadow;
-
- /* pull the chosen /reset-line low */
-
-#ifdef CONFIG_ETRAX_IDE_G27_RESET
- REG_SHADOW_SET(R_PORT_G_DATA, port_g_data_shadow, 27, 0);
-#endif
-#ifdef CONFIG_ETRAX_IDE_CSE1_16_RESET
- REG_SHADOW_SET(port_cse1_addr, port_cse1_shadow, 16, 0);
-#endif
-#ifdef CONFIG_ETRAX_IDE_CSP0_8_RESET
- REG_SHADOW_SET(port_csp0_addr, port_csp0_shadow, 8, 0);
-#endif
-#ifdef CONFIG_ETRAX_IDE_PB7_RESET
- port_pb_dir_shadow = port_pb_dir_shadow |
- IO_STATE(R_PORT_PB_DIR, dir7, output);
- *R_PORT_PB_DIR = port_pb_dir_shadow;
- REG_SHADOW_SET(R_PORT_PB_DATA, port_pb_data_shadow, 7, 1);
-#endif
-
- /* wait some */
-
- udelay(25);
-
- /* de-assert bus-reset */
-
-#ifdef CONFIG_ETRAX_IDE_CSE1_16_RESET
- REG_SHADOW_SET(port_cse1_addr, port_cse1_shadow, 16, 1);
-#endif
-#ifdef CONFIG_ETRAX_IDE_CSP0_8_RESET
- REG_SHADOW_SET(port_csp0_addr, port_csp0_shadow, 8, 1);
-#endif
-#ifdef CONFIG_ETRAX_IDE_G27_RESET
- REG_SHADOW_SET(R_PORT_G_DATA, port_g_data_shadow, 27, 1);
-#endif
-
- /* make a dummy read to set the ata controller in a proper state */
- dummy = *R_ATA_STATUS_DATA;
-
- *R_ATA_CONFIG = ( IO_FIELD( R_ATA_CONFIG, enable, 1 ) |
- IO_FIELD( R_ATA_CONFIG, dma_strobe, ATA_DMA2_STROBE ) |
- IO_FIELD( R_ATA_CONFIG, dma_hold, ATA_DMA2_HOLD ) |
- IO_FIELD( R_ATA_CONFIG, pio_setup, ATA_PIO4_SETUP ) |
- IO_FIELD( R_ATA_CONFIG, pio_strobe, ATA_PIO4_STROBE ) |
- IO_FIELD( R_ATA_CONFIG, pio_hold, ATA_PIO4_HOLD ) );
-
- *R_ATA_CTRL_DATA = ( IO_STATE( R_ATA_CTRL_DATA, rw, read) |
- IO_FIELD( R_ATA_CTRL_DATA, addr, 1 ) );
-
- while(*R_ATA_STATUS_DATA & IO_MASK(R_ATA_STATUS_DATA, busy)); /* wait for busy flag*/
-
- *R_IRQ_MASK0_SET = ( IO_STATE( R_IRQ_MASK0_SET, ata_irq0, set ) |
- IO_STATE( R_IRQ_MASK0_SET, ata_irq1, set ) |
- IO_STATE( R_IRQ_MASK0_SET, ata_irq2, set ) |
- IO_STATE( R_IRQ_MASK0_SET, ata_irq3, set ) );
-
- printk("ide: waiting %d seconds for drives to regain consciousness\n",
- CONFIG_ETRAX_IDE_DELAY);
-
- h = jiffies + (CONFIG_ETRAX_IDE_DELAY * HZ);
- while(time_before(jiffies, h)) /* nothing */ ;
-
- /* reset the dma channels we will use */
-
- RESET_DMA(ATA_TX_DMA_NBR);
- RESET_DMA(ATA_RX_DMA_NBR);
- WAIT_DMA(ATA_TX_DMA_NBR);
- WAIT_DMA(ATA_RX_DMA_NBR);
-
-}
-
-static int e100_dma_off (ide_drive_t *drive)
-{
- return 0;
-}
-
-static int e100_dma_verbose (ide_drive_t *drive)
-{
- printk(", DMA(mode 2)");
- return 0;
-}
-
-static etrax_dma_descr mydescr;
-
-/*
- * The following routines are mainly used by the ATAPI drivers.
- *
- * These routines will round up any request for an odd number of bytes,
- * so if an odd bytecount is specified, be sure that there's at least one
- * extra byte allocated for the buffer.
- */
-static void
-e100_atapi_input_bytes (ide_drive_t *drive, void *buffer, unsigned int bytecount)
-{
- ide_ioreg_t data_reg = IDE_DATA_REG;
-
- D(printk("atapi_input_bytes, dreg 0x%x, buffer 0x%x, count %d\n",
- data_reg, buffer, bytecount));
-
- if(bytecount & 1) {
- printk("warning, odd bytecount in cdrom_in_bytes = %d.\n", bytecount);
- bytecount++; /* to round off */
- }
-
- /* make sure the DMA channel is available */
- RESET_DMA(ATA_RX_DMA_NBR);
- WAIT_DMA(ATA_RX_DMA_NBR);
-
- /* setup DMA descriptor */
-
- mydescr.sw_len = bytecount;
- mydescr.ctrl = d_eol;
- mydescr.buf = virt_to_phys(buffer);
-
- /* start the dma channel */
-
- *R_DMA_CH3_FIRST = virt_to_phys(&mydescr);
- *R_DMA_CH3_CMD = IO_STATE(R_DMA_CH3_CMD, cmd, start);
-
- /* initiate a multi word dma read using PIO handshaking */
-
- *R_ATA_TRANSFER_CNT = IO_FIELD(R_ATA_TRANSFER_CNT, count, bytecount >> 1);
-
- *R_ATA_CTRL_DATA = data_reg |
- IO_STATE(R_ATA_CTRL_DATA, rw, read) |
- IO_STATE(R_ATA_CTRL_DATA, src_dst, dma) |
- IO_STATE(R_ATA_CTRL_DATA, handsh, pio) |
- IO_STATE(R_ATA_CTRL_DATA, multi, on) |
- IO_STATE(R_ATA_CTRL_DATA, dma_size, word);
-
- /* wait for completion */
-
- LED_DISK_READ(1);
- WAIT_DMA(ATA_RX_DMA_NBR);
- LED_DISK_READ(0);
-
-#if 0
- /* old polled transfer code
- * this should be moved into a new function that can do polled
- * transfers if DMA is not available
- */
-
- /* initiate a multi word read */
-
- *R_ATA_TRANSFER_CNT = wcount << 1;
-
- *R_ATA_CTRL_DATA = data_reg |
- IO_STATE(R_ATA_CTRL_DATA, rw, read) |
- IO_STATE(R_ATA_CTRL_DATA, src_dst, register) |
- IO_STATE(R_ATA_CTRL_DATA, handsh, pio) |
- IO_STATE(R_ATA_CTRL_DATA, multi, on) |
- IO_STATE(R_ATA_CTRL_DATA, dma_size, word);
-
- /* svinto has a latency until the busy bit actually is set */
-
- nop(); nop();
- nop(); nop();
- nop(); nop();
- nop(); nop();
- nop(); nop();
-
- /* unit should be busy during multi transfer */
- while((status = *R_ATA_STATUS_DATA) & IO_MASK(R_ATA_STATUS_DATA, busy)) {
- while(!(status & IO_MASK(R_ATA_STATUS_DATA, dav)))
- status = *R_ATA_STATUS_DATA;
- *ptr++ = (unsigned short)(status & 0xffff);
- }
-#endif
-}
-
-static void
-e100_atapi_output_bytes (ide_drive_t *drive, void *buffer, unsigned int bytecount)
-{
- ide_ioreg_t data_reg = IDE_DATA_REG;
-
- D(printk("atapi_output_bytes, dreg 0x%x, buffer 0x%x, count %d\n",
- data_reg, buffer, bytecount));
-
- if(bytecount & 1) {
- printk("odd bytecount %d in atapi_out_bytes!\n", bytecount);
- bytecount++;
- }
-
- /* make sure the DMA channel is available */
- RESET_DMA(ATA_TX_DMA_NBR);
- WAIT_DMA(ATA_TX_DMA_NBR);
-
- /* setup DMA descriptor */
-
- mydescr.sw_len = bytecount;
- mydescr.ctrl = d_eol;
- mydescr.buf = virt_to_phys(buffer);
-
- /* start the dma channel */
-
- *R_DMA_CH2_FIRST = virt_to_phys(&mydescr);
- *R_DMA_CH2_CMD = IO_STATE(R_DMA_CH2_CMD, cmd, start);
-
- /* initiate a multi word dma write using PIO handshaking */
-
- *R_ATA_TRANSFER_CNT = IO_FIELD(R_ATA_TRANSFER_CNT, count, bytecount >> 1);
-
- *R_ATA_CTRL_DATA = data_reg |
- IO_STATE(R_ATA_CTRL_DATA, rw, write) |
- IO_STATE(R_ATA_CTRL_DATA, src_dst, dma) |
- IO_STATE(R_ATA_CTRL_DATA, handsh, pio) |
- IO_STATE(R_ATA_CTRL_DATA, multi, on) |
- IO_STATE(R_ATA_CTRL_DATA, dma_size, word);
-
- /* wait for completion */
-
- LED_DISK_WRITE(1);
- WAIT_DMA(ATA_TX_DMA_NBR);
- LED_DISK_WRITE(0);
-
-#if 0
- /* old polled write code - see comment in input_bytes */
-
- /* wait for busy flag */
- while(*R_ATA_STATUS_DATA & IO_MASK(R_ATA_STATUS_DATA, busy));
-
- /* initiate a multi word write */
-
- *R_ATA_TRANSFER_CNT = bytecount >> 1;
-
- ctrl = data_reg |
- IO_STATE(R_ATA_CTRL_DATA, rw, write) |
- IO_STATE(R_ATA_CTRL_DATA, src_dst, register) |
- IO_STATE(R_ATA_CTRL_DATA, handsh, pio) |
- IO_STATE(R_ATA_CTRL_DATA, multi, on) |
- IO_STATE(R_ATA_CTRL_DATA, dma_size, word);
-
- LED_DISK_WRITE(1);
-
- /* Etrax will set busy = 1 until the multi pio transfer has finished
- * and tr_rdy = 1 after each successful word transfer.
- * When the last byte has been transferred Etrax will first set tr_tdy = 1
- * and then busy = 0 (not in the same cycle). If we read busy before it
- * has been set to 0 we will think that we should transfer more bytes
- * and then tr_rdy would be 0 forever. This is solved by checking busy
- * in the inner loop.
- */
-
- do {
- *R_ATA_CTRL_DATA = ctrl | *ptr++;
- while(!(*R_ATA_STATUS_DATA & IO_MASK(R_ATA_STATUS_DATA, tr_rdy)) &&
- (*R_ATA_STATUS_DATA & IO_MASK(R_ATA_STATUS_DATA, busy)));
- } while(*R_ATA_STATUS_DATA & IO_MASK(R_ATA_STATUS_DATA, busy));
-
- LED_DISK_WRITE(0);
-#endif
-
-}
-
-/*
- * This is used for most PIO data transfers *from* the IDE interface
- */
-static void
-e100_ide_input_data (ide_drive_t *drive, void *buffer, unsigned int wcount)
-{
- e100_atapi_input_bytes(drive, buffer, wcount << 2);
-}
-
-/*
- * This is used for most PIO data transfers *to* the IDE interface
- */
-static void
-e100_ide_output_data (ide_drive_t *drive, void *buffer, unsigned int wcount)
-{
- e100_atapi_output_bytes(drive, buffer, wcount << 2);
-}
-
-/* we only have one DMA channel on the chip for ATA, so we can keep these statically */
-static etrax_dma_descr ata_descrs[MAX_DMA_DESCRS];
-static unsigned int ata_tot_size;
-
-/*
- * e100_ide_build_dmatable() prepares a dma request.
- * Returns 0 if all went okay, returns 1 otherwise.
- */
-static int e100_ide_build_dmatable (ide_drive_t *drive)
-{
- ide_hwif_t *hwif = HWIF(drive);
- struct scatterlist* sg;
- struct request *rq = HWGROUP(drive)->rq;
- unsigned long size, addr;
- unsigned int count = 0;
- int i = 0;
-
- sg = hwif->sg_table;
-
- ata_tot_size = 0;
-
- if (HWGROUP(drive)->rq->flags & REQ_DRIVE_TASKFILE) {
- u8 *virt_addr = rq->buffer;
- int sector_count = rq->nr_sectors;
- memset(&sg[0], 0, sizeof(*sg));
- sg[0].page = virt_to_page(virt_addr);
- sg[0].offset = offset_in_page(virt_addr);
- sg[0].length = sector_count * SECTOR_SIZE;
- hwif->sg_nents = i = 1;
- }
- else
- {
- hwif->sg_nents = i = blk_rq_map_sg(drive->queue, rq, hwif->sg_table);
- }
-
-
- while(i) {
- /*
- * Determine addr and size of next buffer area. We assume that
- * individual virtual buffers are always composed linearly in
- * physical memory. For example, we assume that any 8kB buffer
- * is always composed of two adjacent physical 4kB pages rather
- * than two possibly non-adjacent physical 4kB pages.
- */
- /* group sequential buffers into one large buffer */
- addr = page_to_phys(sg->page) + sg->offset;
- size = sg_dma_len(sg);
- while (sg++, --i) {
- if ((addr + size) != page_to_phys(sg->page) + sg->offset)
- break;
- size += sg_dma_len(sg);
- }
-
- /* did we run out of descriptors? */
-
- if(count >= MAX_DMA_DESCRS) {
- printk("%s: too few DMA descriptors\n", drive->name);
- return 1;
- }
-
- /* however, this case is more difficult - R_ATA_TRANSFER_CNT cannot be more
- than 65536 words per transfer, so in that case we need to either
- 1) use a DMA interrupt to re-trigger R_ATA_TRANSFER_CNT and continue with
- the descriptors, or
- 2) simply do the request here, and get dma_intr to only ide_end_request on
- those blocks that were actually set-up for transfer.
- */
-
- if(ata_tot_size + size > 131072) {
- printk("too large total ATA DMA request, %d + %d!\n", ata_tot_size, (int)size);
- return 1;
- }
-
- /* If size > 65536 it has to be splitted into new descriptors. Since we don't handle
- size > 131072 only one split is necessary */
-
- if(size > 65536) {
- /* ok we want to do IO at addr, size bytes. set up a new descriptor entry */
- ata_descrs[count].sw_len = 0; /* 0 means 65536, this is a 16-bit field */
- ata_descrs[count].ctrl = 0;
- ata_descrs[count].buf = addr;
- ata_descrs[count].next = virt_to_phys(&ata_descrs[count + 1]);
- count++;
- ata_tot_size += 65536;
- /* size and addr should refere to not handled data */
- size -= 65536;
- addr += 65536;
- }
- /* ok we want to do IO at addr, size bytes. set up a new descriptor entry */
- if(size == 65536) {
- ata_descrs[count].sw_len = 0; /* 0 means 65536, this is a 16-bit field */
- } else {
- ata_descrs[count].sw_len = size;
- }
- ata_descrs[count].ctrl = 0;
- ata_descrs[count].buf = addr;
- ata_descrs[count].next = virt_to_phys(&ata_descrs[count + 1]);
- count++;
- ata_tot_size += size;
- }
-
- if (count) {
- /* set the end-of-list flag on the last descriptor */
- ata_descrs[count - 1].ctrl |= d_eol;
- /* return and say all is ok */
- return 0;
- }
-
- printk("%s: empty DMA table?\n", drive->name);
- return 1; /* let the PIO routines handle this weirdness */
-}
-
-static int config_drive_for_dma (ide_drive_t *drive)
-{
- const char **list;
- struct hd_driveid *id = drive->id;
-
- if (id && (id->capability & 1)) {
- /* Enable DMA on any drive that supports mword2 DMA */
- if ((id->field_valid & 2) && (id->dma_mword & 0x404) == 0x404) {
- drive->using_dma = 1;
- return 0; /* DMA enabled */
- }
-
- /* Consult the list of known "good" drives */
- list = good_dma_drives;
- while (*list) {
- if (!strcmp(*list++,id->model)) {
- drive->using_dma = 1;
- return 0; /* DMA enabled */
- }
- }
- }
- return 1; /* DMA not enabled */
-}
-
-/*
- * etrax_dma_intr() is the handler for disk read/write DMA interrupts
- */
-static ide_startstop_t etrax_dma_intr (ide_drive_t *drive)
-{
- int i, dma_stat;
- byte stat;
-
- LED_DISK_READ(0);
- LED_DISK_WRITE(0);
-
- dma_stat = HWIF(drive)->ide_dma_end(drive);
- stat = HWIF(drive)->INB(IDE_STATUS_REG); /* get drive status */
- if (OK_STAT(stat,DRIVE_READY,drive->bad_wstat|DRQ_STAT)) {
- if (!dma_stat) {
- struct request *rq;
- rq = HWGROUP(drive)->rq;
- for (i = rq->nr_sectors; i > 0;) {
- i -= rq->current_nr_sectors;
- DRIVER(drive)->end_request(drive, 1, rq->nr_sectors);
- }
- return ide_stopped;
- }
- printk("%s: bad DMA status\n", drive->name);
- }
- return DRIVER(drive)->error(drive, "dma_intr", stat);
-}
-
-/*
- * Functions below initiates/aborts DMA read/write operations on a drive.
- *
- * The caller is assumed to have selected the drive and programmed the drive's
- * sector address using CHS or LBA. All that remains is to prepare for DMA
- * and then issue the actual read/write DMA/PIO command to the drive.
- *
- * For ATAPI devices, we just prepare for DMA and return. The caller should
- * then issue the packet command to the drive and call us again with
- * ide_dma_begin afterwards.
- *
- * Returns 0 if all went well.
- * Returns 1 if DMA read/write could not be started, in which case
- * the caller should revert to PIO for the current request.
- */
-
-static int e100_dma_check(ide_drive_t *drive)
-{
- return config_drive_for_dma (drive);
-}
-
-static int e100_dma_end(ide_drive_t *drive)
-{
- /* TODO: check if something went wrong with the DMA */
- return 0;
-}
-
-static int e100_start_dma(ide_drive_t *drive, int atapi, int reading)
-{
- if(reading) {
-
- RESET_DMA(ATA_RX_DMA_NBR); /* sometimes the DMA channel get stuck so we need to do this */
- WAIT_DMA(ATA_RX_DMA_NBR);
-
- /* set up the Etrax DMA descriptors */
-
- if(e100_ide_build_dmatable (drive))
- return 1;
-
- if(!atapi) {
- /* set the irq handler which will finish the request when DMA is done */
-
- ide_set_handler(drive, &etrax_dma_intr, WAIT_CMD, NULL);
-
- /* issue cmd to drive */
- if ((HWGROUP(drive)->rq->cmd == IDE_DRIVE_TASKFILE) &&
- (drive->addressing == 1)) {
- ide_task_t *args = HWGROUP(drive)->rq->special;
- etrax100_ide_outb(args->tfRegister[IDE_COMMAND_OFFSET], IDE_COMMAND_REG);
- } else if (drive->addressing) {
- etrax100_ide_outb(WIN_READDMA_EXT, IDE_COMMAND_REG);
- } else {
- etrax100_ide_outb(WIN_READDMA, IDE_COMMAND_REG);
- }
- }
-
- /* begin DMA */
-
- /* need to do this before RX DMA due to a chip bug
- * it is enough to just flush the part of the cache that
- * corresponds to the buffers we start, but since HD transfers
- * usually are more than 8 kB, it is easier to optimize for the
- * normal case and just flush the entire cache. its the only
- * way to be sure! (OB movie quote)
- */
- flush_etrax_cache();
- *R_DMA_CH3_FIRST = virt_to_phys(ata_descrs);
- *R_DMA_CH3_CMD = IO_STATE(R_DMA_CH3_CMD, cmd, start);
-
- /* initiate a multi word dma read using DMA handshaking */
-
- *R_ATA_TRANSFER_CNT =
- IO_FIELD(R_ATA_TRANSFER_CNT, count, ata_tot_size >> 1);
-
- *R_ATA_CTRL_DATA =
- IO_FIELD(R_ATA_CTRL_DATA, data, IDE_DATA_REG) |
- IO_STATE(R_ATA_CTRL_DATA, rw, read) |
- IO_STATE(R_ATA_CTRL_DATA, src_dst, dma) |
- IO_STATE(R_ATA_CTRL_DATA, handsh, dma) |
- IO_STATE(R_ATA_CTRL_DATA, multi, on) |
- IO_STATE(R_ATA_CTRL_DATA, dma_size, word);
-
- LED_DISK_READ(1);
-
- D(printk("dma read of %d bytes.\n", ata_tot_size));
-
- } else {
- /* writing */
-
- RESET_DMA(ATA_TX_DMA_NBR); /* sometimes the DMA channel get stuck so we need to do this */
- WAIT_DMA(ATA_TX_DMA_NBR);
-
- /* set up the Etrax DMA descriptors */
-
- if(e100_ide_build_dmatable (drive))
- return 1;
-
- if(!atapi) {
- /* set the irq handler which will finish the request when DMA is done */
-
- ide_set_handler(drive, &etrax_dma_intr, WAIT_CMD, NULL);
-
- /* issue cmd to drive */
- if ((HWGROUP(drive)->rq->cmd == IDE_DRIVE_TASKFILE) &&
- (drive->addressing == 1)) {
- ide_task_t *args = HWGROUP(drive)->rq->special;
- etrax100_ide_outb(args->tfRegister[IDE_COMMAND_OFFSET], IDE_COMMAND_REG);
- } else if (drive->addressing) {
- etrax100_ide_outb(WIN_WRITEDMA_EXT, IDE_COMMAND_REG);
- } else {
- etrax100_ide_outb(WIN_WRITEDMA, IDE_COMMAND_REG);
- }
- }
-
- /* begin DMA */
-
- *R_DMA_CH2_FIRST = virt_to_phys(ata_descrs);
- *R_DMA_CH2_CMD = IO_STATE(R_DMA_CH2_CMD, cmd, start);
-
- /* initiate a multi word dma write using DMA handshaking */
-
- *R_ATA_TRANSFER_CNT =
- IO_FIELD(R_ATA_TRANSFER_CNT, count, ata_tot_size >> 1);
-
- *R_ATA_CTRL_DATA =
- IO_FIELD(R_ATA_CTRL_DATA, data, IDE_DATA_REG) |
- IO_STATE(R_ATA_CTRL_DATA, rw, write) |
- IO_STATE(R_ATA_CTRL_DATA, src_dst, dma) |
- IO_STATE(R_ATA_CTRL_DATA, handsh, dma) |
- IO_STATE(R_ATA_CTRL_DATA, multi, on) |
- IO_STATE(R_ATA_CTRL_DATA, dma_size, word);
-
- LED_DISK_WRITE(1);
-
- D(printk("dma write of %d bytes.\n", ata_tot_size));
- }
- return 0;
-}
-
-static int e100_dma_write(ide_drive_t *drive)
-{
- e100_read_command = 0;
- /* ATAPI-devices (not disks) first call ide_dma_read/write to set the direction
- * then they call ide_dma_begin after they have issued the appropriate drive command
- * themselves to actually start the chipset DMA. so we just return here if we're
- * not a diskdrive.
- */
- if (drive->media != ide_disk)
- return 0;
- return e100_start_dma(drive, 0, 0);
-}
-
-static int e100_dma_read(ide_drive_t *drive)
-{
- e100_read_command = 1;
- /* ATAPI-devices (not disks) first call ide_dma_read/write to set the direction
- * then they call ide_dma_begin after they have issued the appropriate drive command
- * themselves to actually start the chipset DMA. so we just return here if we're
- * not a diskdrive.
- */
- if (drive->media != ide_disk)
- return 0;
- return e100_start_dma(drive, 0, 1);
-}
-
-static int e100_dma_begin(ide_drive_t *drive)
-{
- /* begin DMA, used by ATAPI devices which want to issue the
- * appropriate IDE command themselves.
- *
- * they have already called ide_dma_read/write to set the
- * static reading flag, now they call ide_dma_begin to do
- * the real stuff. we tell our code below not to issue
- * any IDE commands itself and jump into it.
- */
- return e100_start_dma(drive, 1, e100_read_command);
-}
+++ /dev/null
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/user.h>
-#include <linux/elfcore.h>
-#include <linux/sched.h>
-#include <linux/in6.h>
-#include <linux/interrupt.h>
-#include <linux/smp_lock.h>
-#include <linux/pm.h>
-#include <linux/kernel.h>
-#include <linux/string.h>
-#include <linux/tty.h>
-
-#include <asm/semaphore.h>
-#include <asm/processor.h>
-#include <asm/uaccess.h>
-#include <asm/checksum.h>
-#include <asm/io.h>
-#include <asm/hardirq.h>
-#include <asm/delay.h>
-#include <asm/irq.h>
-#include <asm/pgtable.h>
-#include <asm/fasttimer.h>
-
-extern void dump_thread(struct pt_regs *, struct user *);
-extern unsigned long get_cmos_time(void);
-extern void __Udiv(void);
-extern void __Umod(void);
-extern void __Div(void);
-extern void __Mod(void);
-extern void __ashrdi3(void);
-extern void iounmap(void *addr);
-
-/* Platform dependent support */
-EXPORT_SYMBOL(dump_thread);
-EXPORT_SYMBOL(enable_irq);
-EXPORT_SYMBOL(disable_irq);
-EXPORT_SYMBOL(kernel_thread);
-EXPORT_SYMBOL(get_cmos_time);
-EXPORT_SYMBOL(loops_per_usec);
-
-/* String functions */
-EXPORT_SYMBOL(memcmp);
-EXPORT_SYMBOL(memmove);
-EXPORT_SYMBOL(strpbrk);
-EXPORT_SYMBOL(strstr);
-EXPORT_SYMBOL(strcpy);
-EXPORT_SYMBOL(strchr);
-EXPORT_SYMBOL(strcmp);
-EXPORT_SYMBOL(strlen);
-EXPORT_SYMBOL(strcat);
-EXPORT_SYMBOL(strncat);
-EXPORT_SYMBOL(strncmp);
-EXPORT_SYMBOL(strncpy);
-
-/* Math functions */
-EXPORT_SYMBOL(__Udiv);
-EXPORT_SYMBOL(__Umod);
-EXPORT_SYMBOL(__Div);
-EXPORT_SYMBOL(__Mod);
-EXPORT_SYMBOL(__ashrdi3);
-
-/* Memory functions */
-EXPORT_SYMBOL(__ioremap);
-EXPORT_SYMBOL(iounmap);
-
-/* Semaphore functions */
-EXPORT_SYMBOL(__up);
-EXPORT_SYMBOL(__down);
-EXPORT_SYMBOL(__down_interruptible);
-EXPORT_SYMBOL(__down_trylock);
-
-/* Export shadow registers for the CPU I/O pins */
-EXPORT_SYMBOL(genconfig_shadow);
-EXPORT_SYMBOL(port_pa_data_shadow);
-EXPORT_SYMBOL(port_pa_dir_shadow);
-EXPORT_SYMBOL(port_pb_data_shadow);
-EXPORT_SYMBOL(port_pb_dir_shadow);
-EXPORT_SYMBOL(port_pb_config_shadow);
-EXPORT_SYMBOL(port_g_data_shadow);
-
-/* Userspace access functions */
-EXPORT_SYMBOL(__copy_user_zeroing);
-EXPORT_SYMBOL(__copy_user);
-
-/* Cache flush functions */
-EXPORT_SYMBOL(flush_etrax_cache);
-EXPORT_SYMBOL(prepare_rx_descriptor);
-
-#undef memcpy
-#undef memset
-extern void * memset(void *, int, __kernel_size_t);
-extern void * memcpy(void *, const void *, __kernel_size_t);
-EXPORT_SYMBOL_NOVERS(memcpy);
-EXPORT_SYMBOL_NOVERS(memset);
-
-#ifdef CONFIG_ETRAX_FAST_TIMER
-/* Fast timer functions */
-EXPORT_SYMBOL(fast_timer_list);
-EXPORT_SYMBOL(start_one_shot_timer);
-EXPORT_SYMBOL(del_fast_timer);
-EXPORT_SYMBOL(schedule_usleep);
-#endif
-
+++ /dev/null
-#
-# Automatically generated make config: don't edit
-#
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-# CONFIG_CLEAN_COMPILE is not set
-# CONFIG_STANDALONE is not set
-CONFIG_BROKEN=y
-CONFIG_BROKEN_ON_SMP=y
-
-#
-# General setup
-#
-CONFIG_SWAP=y
-CONFIG_SYSVIPC=y
-# CONFIG_POSIX_MQUEUE is not set
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-# CONFIG_AUDIT is not set
-CONFIG_LOG_BUF_SHIFT=16
-# CONFIG_HOTPLUG is not set
-CONFIG_IKCONFIG=y
-CONFIG_IKCONFIG_PROC=y
-# CONFIG_EMBEDDED is not set
-CONFIG_KALLSYMS=y
-# CONFIG_KALLSYMS_ALL is not set
-CONFIG_FUTEX=y
-CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
-# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-CONFIG_MODULE_UNLOAD=y
-CONFIG_MODULE_FORCE_UNLOAD=y
-CONFIG_OBSOLETE_MODPARM=y
-CONFIG_MODVERSIONS=y
-CONFIG_KMOD=y
-CONFIG_STOP_MACHINE=y
-
-#
-# Processor type and features
-#
-CONFIG_IA64=y
-CONFIG_64BIT=y
-CONFIG_MMU=y
-CONFIG_RWSEM_XCHGADD_ALGORITHM=y
-CONFIG_TIME_INTERPOLATION=y
-CONFIG_EFI=y
-# CONFIG_IA64_GENERIC is not set
-# CONFIG_IA64_DIG is not set
-# CONFIG_IA64_HP_ZX1 is not set
-# CONFIG_IA64_SGI_SN2 is not set
-CONFIG_IA64_HP_SIM=y
-# CONFIG_ITANIUM is not set
-CONFIG_MCKINLEY=y
-# CONFIG_IA64_PAGE_SIZE_4KB is not set
-# CONFIG_IA64_PAGE_SIZE_8KB is not set
-# CONFIG_IA64_PAGE_SIZE_16KB is not set
-CONFIG_IA64_PAGE_SIZE_64KB=y
-CONFIG_IA64_L1_CACHE_SHIFT=7
-# CONFIG_MCKINLEY_ASTEP_SPECIFIC is not set
-# CONFIG_VIRTUAL_MEM_MAP is not set
-# CONFIG_IA64_CYCLONE is not set
-CONFIG_FORCE_MAX_ZONEORDER=18
-CONFIG_SMP=y
-CONFIG_NR_CPUS=64
-CONFIG_PREEMPT=y
-CONFIG_HAVE_DEC_LOCK=y
-CONFIG_IA32_SUPPORT=y
-CONFIG_COMPAT=y
-# CONFIG_PERFMON is not set
-CONFIG_IA64_PALINFO=m
-
-#
-# Firmware Drivers
-#
-CONFIG_EFI_VARS=y
-# CONFIG_SMBIOS is not set
-CONFIG_BINFMT_ELF=y
-CONFIG_BINFMT_MISC=y
-
-#
-# Power management and ACPI
-#
-
-#
-# Device Drivers
-#
-
-#
-# Generic Driver Options
-#
-# CONFIG_DEBUG_DRIVER is not set
-
-#
-# Memory Technology Devices (MTD)
-#
-# CONFIG_MTD is not set
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Plug and Play support
-#
-
-#
-# Block devices
-#
-CONFIG_BLK_DEV_LOOP=y
-# CONFIG_BLK_DEV_CRYPTOLOOP is not set
-# CONFIG_BLK_DEV_NBD is not set
-CONFIG_BLK_DEV_RAM=y
-CONFIG_BLK_DEV_RAM_SIZE=4096
-# CONFIG_BLK_DEV_INITRD is not set
-
-#
-# ATA/ATAPI/MFM/RLL support
-#
-# CONFIG_IDE is not set
-
-#
-# SCSI device support
-#
-CONFIG_SCSI=y
-CONFIG_SCSI_PROC_FS=y
-
-#
-# SCSI support type (disk, tape, CD-ROM)
-#
-CONFIG_BLK_DEV_SD=y
-# CONFIG_CHR_DEV_ST is not set
-# CONFIG_CHR_DEV_OSST is not set
-# CONFIG_BLK_DEV_SR is not set
-# CONFIG_CHR_DEV_SG is not set
-
-#
-# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
-#
-CONFIG_SCSI_MULTI_LUN=y
-CONFIG_SCSI_CONSTANTS=y
-CONFIG_SCSI_LOGGING=y
-
-#
-# SCSI Transport Attributes
-#
-CONFIG_SCSI_SPI_ATTRS=y
-# CONFIG_SCSI_FC_ATTRS is not set
-
-#
-# SCSI low-level drivers
-#
-# CONFIG_SCSI_AIC7XXX_OLD is not set
-# CONFIG_SCSI_SATA is not set
-# CONFIG_SCSI_EATA_PIO is not set
-# CONFIG_SCSI_DEBUG is not set
-
-#
-# Multi-device support (RAID and LVM)
-#
-# CONFIG_MD is not set
-
-#
-# Fusion MPT device support
-#
-
-#
-# IEEE 1394 (FireWire) support
-#
-# CONFIG_IEEE1394 is not set
-
-#
-# I2O device support
-#
-
-#
-# Networking support
-#
-CONFIG_NET=y
-
-#
-# Networking options
-#
-CONFIG_PACKET=y
-# CONFIG_PACKET_MMAP is not set
-# CONFIG_NETLINK_DEV is not set
-# CONFIG_UNIX is not set
-# CONFIG_NET_KEY is not set
-CONFIG_INET=y
-CONFIG_IP_MULTICAST=y
-# CONFIG_IP_ADVANCED_ROUTER is not set
-# CONFIG_IP_PNP is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_IP_MROUTE is not set
-# CONFIG_ARPD is not set
-# CONFIG_SYN_COOKIES is not set
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-# CONFIG_IPV6 is not set
-# CONFIG_NETFILTER is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_DECNET is not set
-# CONFIG_LLC2 is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_FASTROUTE is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-
-#
-# Network testing
-#
-# CONFIG_NET_PKTGEN is not set
-# CONFIG_NETPOLL is not set
-# CONFIG_NET_POLL_CONTROLLER is not set
-# CONFIG_HAMRADIO is not set
-# CONFIG_IRDA is not set
-# CONFIG_BT is not set
-# CONFIG_NETDEVICES is not set
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN is not set
-
-#
-# Telephony Support
-#
-# CONFIG_PHONE is not set
-
-#
-# Input device support
-#
-CONFIG_INPUT=y
-
-#
-# Userland interfaces
-#
-CONFIG_INPUT_MOUSEDEV=y
-CONFIG_INPUT_MOUSEDEV_PSAUX=y
-CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
-CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
-# CONFIG_INPUT_JOYDEV is not set
-# CONFIG_INPUT_TSDEV is not set
-# CONFIG_INPUT_EVDEV is not set
-# CONFIG_INPUT_EVBUG is not set
-
-#
-# Input I/O drivers
-#
-# CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
-CONFIG_SERIO=y
-# CONFIG_SERIO_I8042 is not set
-CONFIG_SERIO_SERPORT=y
-# CONFIG_SERIO_CT82C710 is not set
-
-#
-# Input Device Drivers
-#
-# CONFIG_INPUT_KEYBOARD is not set
-# CONFIG_INPUT_MOUSE is not set
-# CONFIG_INPUT_JOYSTICK is not set
-# CONFIG_INPUT_TOUCHSCREEN is not set
-# CONFIG_INPUT_MISC is not set
-
-#
-# Character devices
-#
-CONFIG_VT=y
-CONFIG_VT_CONSOLE=y
-CONFIG_HW_CONSOLE=y
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
-# Serial drivers
-#
-# CONFIG_SERIAL_8250 is not set
-
-#
-# Non-8250 serial port support
-#
-CONFIG_UNIX98_PTYS=y
-# CONFIG_LEGACY_PTYS is not set
-# CONFIG_QIC02_TAPE is not set
-
-#
-# IPMI
-#
-# CONFIG_IPMI_HANDLER is not set
-
-#
-# Watchdog Cards
-#
-# CONFIG_WATCHDOG is not set
-CONFIG_EFI_RTC=y
-# CONFIG_DTLK is not set
-# CONFIG_R3964 is not set
-# CONFIG_APPLICOM is not set
-
-#
-# Ftape, the floppy tape device driver
-#
-# CONFIG_FTAPE is not set
-# CONFIG_AGP is not set
-# CONFIG_DRM is not set
-# CONFIG_RAW_DRIVER is not set
-
-#
-# I2C support
-#
-# CONFIG_I2C is not set
-
-#
-# Misc devices
-#
-
-#
-# Multimedia devices
-#
-# CONFIG_VIDEO_DEV is not set
-
-#
-# Digital Video Broadcasting Devices
-#
-# CONFIG_DVB is not set
-
-#
-# Graphics support
-#
-# CONFIG_FB is not set
-
-#
-# Console display driver support
-#
-# CONFIG_VGA_CONSOLE is not set
-# CONFIG_MDA_CONSOLE is not set
-CONFIG_DUMMY_CONSOLE=y
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# USB support
-#
-
-#
-# USB Gadget Support
-#
-# CONFIG_USB_GADGET is not set
-
-#
-# File systems
-#
-CONFIG_EXT2_FS=y
-# CONFIG_EXT2_FS_XATTR is not set
-CONFIG_EXT3_FS=y
-# CONFIG_EXT3_FS_XATTR is not set
-CONFIG_JBD=y
-# CONFIG_JBD_DEBUG is not set
-# CONFIG_REISERFS_FS is not set
-# CONFIG_JFS_FS is not set
-# CONFIG_XFS_FS is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_ROMFS_FS is not set
-# CONFIG_QUOTA is not set
-# CONFIG_AUTOFS_FS is not set
-# CONFIG_AUTOFS4_FS is not set
-
-#
-# CD-ROM/DVD Filesystems
-#
-# CONFIG_ISO9660_FS is not set
-# CONFIG_UDF_FS is not set
-
-#
-# DOS/FAT/NT Filesystems
-#
-# CONFIG_FAT_FS is not set
-# CONFIG_NTFS_FS is not set
-
-#
-# Pseudo filesystems
-#
-CONFIG_PROC_FS=y
-CONFIG_PROC_KCORE=y
-CONFIG_SYSFS=y
-# CONFIG_DEVFS_FS is not set
-# CONFIG_DEVPTS_FS_XATTR is not set
-# CONFIG_TMPFS is not set
-CONFIG_HUGETLBFS=y
-CONFIG_HUGETLB_PAGE=y
-CONFIG_RAMFS=y
-
-#
-# Miscellaneous filesystems
-#
-# CONFIG_ADFS_FS is not set
-# CONFIG_AFFS_FS is not set
-# CONFIG_HFS_FS is not set
-# CONFIG_HFSPLUS_FS is not set
-# CONFIG_BEFS_FS is not set
-# CONFIG_BFS_FS is not set
-# CONFIG_EFS_FS is not set
-# CONFIG_CRAMFS is not set
-# CONFIG_VXFS_FS is not set
-# CONFIG_HPFS_FS is not set
-# CONFIG_QNX4FS_FS is not set
-# CONFIG_SYSV_FS is not set
-# CONFIG_UFS_FS is not set
-
-#
-# Network File Systems
-#
-CONFIG_NFS_FS=y
-# CONFIG_NFS_V3 is not set
-# CONFIG_NFS_V4 is not set
-CONFIG_NFS_DIRECTIO=y
-CONFIG_NFSD=y
-CONFIG_NFSD_V3=y
-# CONFIG_NFSD_V4 is not set
-# CONFIG_NFSD_TCP is not set
-CONFIG_LOCKD=y
-CONFIG_LOCKD_V4=y
-CONFIG_EXPORTFS=y
-CONFIG_SUNRPC=y
-# CONFIG_RPCSEC_GSS_KRB5 is not set
-# CONFIG_SMB_FS is not set
-# CONFIG_CIFS is not set
-# CONFIG_NCP_FS is not set
-# CONFIG_CODA_FS is not set
-# CONFIG_AFS_FS is not set
-
-#
-# Partition Types
-#
-CONFIG_PARTITION_ADVANCED=y
-# CONFIG_ACORN_PARTITION is not set
-# CONFIG_OSF_PARTITION is not set
-# CONFIG_AMIGA_PARTITION is not set
-# CONFIG_ATARI_PARTITION is not set
-# CONFIG_MAC_PARTITION is not set
-CONFIG_MSDOS_PARTITION=y
-# CONFIG_BSD_DISKLABEL is not set
-# CONFIG_MINIX_SUBPARTITION is not set
-# CONFIG_SOLARIS_X86_PARTITION is not set
-# CONFIG_UNIXWARE_DISKLABEL is not set
-# CONFIG_LDM_PARTITION is not set
-# CONFIG_NEC98_PARTITION is not set
-# CONFIG_SGI_PARTITION is not set
-# CONFIG_ULTRIX_PARTITION is not set
-# CONFIG_SUN_PARTITION is not set
-CONFIG_EFI_PARTITION=y
-
-#
-# Native Language Support
-#
-# CONFIG_NLS is not set
-
-#
-# Library routines
-#
-CONFIG_CRC32=y
-# CONFIG_LIBCRC32C is not set
-
-#
-# HP Simulator drivers
-#
-CONFIG_HP_SIMETH=y
-CONFIG_HP_SIMSERIAL=y
-CONFIG_HP_SIMSERIAL_CONSOLE=y
-CONFIG_HP_SIMSCSI=y
-
-#
-# Profiling support
-#
-# CONFIG_PROFILING is not set
-
-#
-# Kernel hacking
-#
-# CONFIG_IA64_GRANULE_16MB is not set
-CONFIG_IA64_GRANULE_64MB=y
-CONFIG_DEBUG_KERNEL=y
-# CONFIG_IA64_PRINT_HAZARDS is not set
-# CONFIG_DISABLE_VHPT is not set
-# CONFIG_MAGIC_SYSRQ is not set
-# CONFIG_DEBUG_SLAB is not set
-# CONFIG_DEBUG_SPINLOCK is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
-# CONFIG_IA64_DEBUG_CMPXCHG is not set
-# CONFIG_IA64_DEBUG_IRQ is not set
-CONFIG_DEBUG_INFO=y
-CONFIG_SYSVIPC_COMPAT=y
-
-#
-# Security options
-#
-# CONFIG_SECURITY is not set
-
-#
-# Cryptographic options
-#
-# CONFIG_CRYPTO is not set
+++ /dev/null
-#include <linux/compiler.h>
-#include <linux/types.h>
-#include <asm/intrinsics.h>
-#include <linux/module.h>
-#include <asm/bitops.h>
-
-/*
- * Find next zero bit in a bitmap reasonably efficiently..
- */
-
-int __find_next_zero_bit (void *addr, unsigned long size, unsigned long offset)
-{
- unsigned long *p = ((unsigned long *) addr) + (offset >> 6);
- unsigned long result = offset & ~63UL;
- unsigned long tmp;
-
- if (offset >= size)
- return size;
- size -= result;
- offset &= 63UL;
- if (offset) {
- tmp = *(p++);
- tmp |= ~0UL >> (64-offset);
- if (size < 64)
- goto found_first;
- if (~tmp)
- goto found_middle;
- size -= 64;
- result += 64;
- }
- while (size & ~63UL) {
- if (~(tmp = *(p++)))
- goto found_middle;
- result += 64;
- size -= 64;
- }
- if (!size)
- return result;
- tmp = *p;
-found_first:
- tmp |= ~0UL << size;
- if (tmp == ~0UL) /* any bits zero? */
- return result + size; /* nope */
-found_middle:
- return result + ffz(tmp);
-}
-EXPORT_SYMBOL(__find_next_zero_bit);
-
-/*
- * Find next bit in a bitmap reasonably efficiently..
- */
-int __find_next_bit(const void *addr, unsigned long size, unsigned long offset)
-{
- unsigned long *p = ((unsigned long *) addr) + (offset >> 6);
- unsigned long result = offset & ~63UL;
- unsigned long tmp;
-
- if (offset >= size)
- return size;
- size -= result;
- offset &= 63UL;
- if (offset) {
- tmp = *(p++);
- tmp &= ~0UL << offset;
- if (size < 64)
- goto found_first;
- if (tmp)
- goto found_middle;
- size -= 64;
- result += 64;
- }
- while (size & ~63UL) {
- if ((tmp = *(p++)))
- goto found_middle;
- result += 64;
- size -= 64;
- }
- if (!size)
- return result;
- tmp = *p;
- found_first:
- tmp &= ~0UL >> (64-size);
- if (tmp == 0UL) /* Are any bits set? */
- return result + size; /* Nope. */
- found_middle:
- return result + __ffs(tmp);
-}
-EXPORT_SYMBOL(__find_next_bit);
+++ /dev/null
-/*
- * arch/ppc/platforms/sbc82xx.c
- *
- * SBC82XX platform support
- *
- * Author: Guy Streeter <streeter@redhat.com>
- *
- * Derived from: est8260_setup.c by Allen Curtis, ONZ
- *
- * Copyright 2004 Red Hat, Inc.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- */
-
-#include <linux/config.h>
-#include <linux/seq_file.h>
-#include <linux/stddef.h>
-
-#include <asm/mpc8260.h>
-#include <asm/machdep.h>
-#include <asm/io.h>
-#include <asm/todc.h>
-#include <asm/immap_8260.h>
-
-static void (*callback_setup_arch)(void);
-
-extern unsigned char __res[sizeof(bd_t)];
-
-extern void m8260_init(unsigned long r3, unsigned long r4,
- unsigned long r5, unsigned long r6, unsigned long r7);
-
-extern void (*late_time_init)(void);
-
-static int
-sbc82xx_show_cpuinfo(struct seq_file *m)
-{
- bd_t *binfo = (bd_t *)__res;
-
- seq_printf(m, "vendor\t\t: Wind River\n"
- "machine\t\t: SBC PowerQUICC II\n"
- "\n"
- "mem size\t\t: 0x%08lx\n"
- "console baud\t\t: %ld\n"
- "\n",
- binfo->bi_memsize,
- binfo->bi_baudrate);
- return 0;
-}
-
-static void __init
-sbc82xx_setup_arch(void)
-{
- printk("SBC PowerQUICC II Port\n");
- callback_setup_arch();
-}
-
-TODC_ALLOC();
-
-/*
- * Timer init happens before mem_init but after paging init, so we cannot
- * directly use ioremap() at that time.
- * late_time_init() is call after paging init.
- */
-#ifdef CONFIG_GEN_RTC
-static void sbc82xx_time_init(void)
-{
- volatile memctl8260_t *mc = &immr->im_memctl;
- TODC_INIT(TODC_TYPE_MK48T59, 0, 0, SBC82xx_TODC_NVRAM_ADDR, 0);
-
- /* Set up CS11 for RTC chip */
- mc->memc_br11=0;
- mc->memc_or11=0xffff0836;
- mc->memc_br11=0x80000801;
-
- todc_info->nvram_data =
- (unsigned int)ioremap(todc_info->nvram_data, 0x2000);
- BUG_ON(!todc_info->nvram_data);
- ppc_md.get_rtc_time = todc_get_rtc_time;
- ppc_md.set_rtc_time = todc_set_rtc_time;
- ppc_md.nvram_read_val = todc_direct_read_val;
- ppc_md.nvram_write_val = todc_direct_write_val;
- todc_time_init();
-}
-#endif /* CONFIG_GEN_RTC */
-
-void __init
-platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
- unsigned long r6, unsigned long r7)
-{
- /* Generic 8260 platform initialization */
- m8260_init(r3, r4, r5, r6, r7);
-
- /* u-boot may be using one of the FCC Ethernet devices.
- Use the MAC address to the SCC. */
- __res[offsetof(bd_t, bi_enetaddr[5])] &= ~3;
-
- /* Anything special for this platform */
- ppc_md.show_cpuinfo = sbc82xx_show_cpuinfo;
-
- callback_setup_arch = ppc_md.setup_arch;
- ppc_md.setup_arch = sbc82xx_setup_arch;
-#ifdef CONFIG_GEN_RTC
- ppc_md.time_init = NULL;
- ppc_md.get_rtc_time = NULL;
- ppc_md.set_rtc_time = NULL;
- ppc_md.nvram_read_val = NULL;
- ppc_md.nvram_write_val = NULL;
- late_time_init = sbc82xx_time_init;
-#endif /* CONFIG_GEN_RTC */
-}
+++ /dev/null
-/* Board information for the SBCPowerQUICCII, which should be generic for
- * all 8260 boards. The IMMR is now given to us so the hard define
- * will soon be removed. All of the clock values are computed from
- * the configuration SCMR and the Power-On-Reset word.
- */
-
-#ifndef __PPC_SBC82xx_H__
-#define __PPC_SBC82xx_H__
-
-#include <asm/ppcboot.h>
-
-#define IMAP_ADDR 0xf0000000
-#define CPM_MAP_ADDR 0xf0000000
-
-#define SBC82xx_TODC_NVRAM_ADDR 0x80000000
-
-#define SBC82xx_MACADDR_NVRAM_FCC1 0x220000c9 /* JP6B */
-#define SBC82xx_MACADDR_NVRAM_SCC1 0x220000cf /* JP6A */
-#define SBC82xx_MACADDR_NVRAM_FCC2 0x220000d5 /* JP7A */
-#define SBC82xx_MACADDR_NVRAM_FCC3 0x220000db /* JP7B */
-
-#define BOOTROM_RESTART_ADDR ((uint)0x40000104)
-
-#endif /* __PPC_SBC82xx_H__ */
+++ /dev/null
-/*
- * arch/ppc/syslib/dcr.S
- *
- * "Indirect" DCR access
- *
- * Copyright (c) 2004 Eugene Surovegin <ebs@ebshome.net>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- */
-
-#include <asm/ppc_asm.h>
-#include <asm/processor.h>
-
-#define DCR_ACCESS_PROLOG(table) \
- rlwinm r3,r3,4,18,27; \
- lis r5,table@h; \
- ori r5,r5,table@l; \
- add r3,r3,r5; \
- mtctr r3; \
- bctr
-
-_GLOBAL(__mfdcr)
- DCR_ACCESS_PROLOG(__mfdcr_table)
-
-_GLOBAL(__mtdcr)
- DCR_ACCESS_PROLOG(__mtdcr_table)
-
-__mfdcr_table:
- mfdcr r3,0; blr
-__mtdcr_table:
- mtdcr 0,r4; blr
-
-dcr = 1
- .rept 1023
- mfdcr r3,dcr; blr
- mtdcr dcr,r4; blr
- dcr = dcr + 1
- .endr
+++ /dev/null
-/*
- * arch/s390/lib/string.c
- * Optimized string functions
- *
- * S390 version
- * Copyright (C) 2004 IBM Deutschland Entwicklung GmbH, IBM Corporation
- * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
- */
-
-#define IN_ARCH_STRING_C 1
-
-#include <linux/types.h>
-#include <linux/module.h>
-
-/*
- * Helper functions to find the end of a string
- */
-static inline char *__strend(const char *s)
-{
- register unsigned long r0 asm("0") = 0;
-
- asm volatile ("0: srst %0,%1\n"
- " jo 0b"
- : "+d" (r0), "+a" (s) : : "cc" );
- return (char *) r0;
-}
-
-static inline char *__strnend(const char *s, size_t n)
-{
- register unsigned long r0 asm("0") = 0;
- const char *p = s + n;
-
- asm volatile ("0: srst %0,%1\n"
- " jo 0b"
- : "+d" (p), "+a" (s) : "d" (r0) : "cc" );
- return (char *) p;
-}
-
-/**
- * strlen - Find the length of a string
- * @s: The string to be sized
- *
- * returns the length of @s
- */
-size_t strlen(const char *s)
-{
- return __strend(s) - s;
-}
-EXPORT_SYMBOL_NOVERS(strlen);
-
-/**
- * strnlen - Find the length of a length-limited string
- * @s: The string to be sized
- * @n: The maximum number of bytes to search
- *
- * returns the minimum of the length of @s and @n
- */
-size_t strnlen(const char * s, size_t n)
-{
- return __strnend(s, n) - s;
-}
-EXPORT_SYMBOL_NOVERS(strnlen);
-
-/**
- * strcpy - Copy a %NUL terminated string
- * @dest: Where to copy the string to
- * @src: Where to copy the string from
- *
- * returns a pointer to @dest
- */
-char *strcpy(char *dest, const char *src)
-{
- register int r0 asm("0") = 0;
- char *ret = dest;
-
- asm volatile ("0: mvst %0,%1\n"
- " jo 0b"
- : "+&a" (dest), "+&a" (src) : "d" (r0)
- : "cc", "memory" );
- return ret;
-}
-EXPORT_SYMBOL_NOVERS(strcpy);
-
-/**
- * strlcpy - Copy a %NUL terminated string into a sized buffer
- * @dest: Where to copy the string to
- * @src: Where to copy the string from
- * @size: size of destination buffer
- *
- * Compatible with *BSD: the result is always a valid
- * NUL-terminated string that fits in the buffer (unless,
- * of course, the buffer size is zero). It does not pad
- * out the result like strncpy() does.
- */
-size_t strlcpy(char *dest, const char *src, size_t size)
-{
- size_t ret = __strend(src) - src;
-
- if (size) {
- size_t len = (ret >= size) ? size-1 : ret;
- dest[len] = '\0';
- __builtin_memcpy(dest, src, len);
- }
- return ret;
-}
-EXPORT_SYMBOL_NOVERS(strlcpy);
-
-/**
- * strncpy - Copy a length-limited, %NUL-terminated string
- * @dest: Where to copy the string to
- * @src: Where to copy the string from
- * @n: The maximum number of bytes to copy
- *
- * The result is not %NUL-terminated if the source exceeds
- * @n bytes.
- */
-char *strncpy(char *dest, const char *src, size_t n)
-{
- size_t len = __strnend(src, n) - src;
- __builtin_memset(dest + len, 0, n - len);
- __builtin_memcpy(dest, src, len);
- return dest;
-}
-EXPORT_SYMBOL_NOVERS(strncpy);
-
-/**
- * strcat - Append one %NUL-terminated string to another
- * @dest: The string to be appended to
- * @src: The string to append to it
- *
- * returns a pointer to @dest
- */
-char *strcat(char *dest, const char *src)
-{
- register int r0 asm("0") = 0;
- unsigned long dummy;
- char *ret = dest;
-
- asm volatile ("0: srst %0,%1\n"
- " jo 0b\n"
- "1: mvst %0,%2\n"
- " jo 1b"
- : "=&a" (dummy), "+a" (dest), "+a" (src)
- : "d" (r0), "0" (0UL) : "cc", "memory" );
- return ret;
-}
-EXPORT_SYMBOL_NOVERS(strcat);
-
-/**
- * strlcat - Append a length-limited, %NUL-terminated string to another
- * @dest: The string to be appended to
- * @src: The string to append to it
- * @n: The size of the destination buffer.
- */
-size_t strlcat(char *dest, const char *src, size_t n)
-{
- size_t dsize = __strend(dest) - dest;
- size_t len = __strend(src) - src;
- size_t res = dsize + len;
-
- if (dsize < n) {
- dest += dsize;
- n -= dsize;
- if (len >= n)
- len = n - 1;
- dest[len] = '\0';
- __builtin_memcpy(dest, src, len);
- }
- return res;
-}
-EXPORT_SYMBOL_NOVERS(strlcat);
-
-/**
- * strncat - Append a length-limited, %NUL-terminated string to another
- * @dest: The string to be appended to
- * @src: The string to append to it
- * @n: The maximum numbers of bytes to copy
- *
- * returns a pointer to @dest
- *
- * Note that in contrast to strncpy, strncat ensures the result is
- * terminated.
- */
-char *strncat(char *dest, const char *src, size_t n)
-{
- size_t len = __strnend(src, n) - src;
- char *p = __strend(dest);
-
- p[len] = '\0';
- __builtin_memcpy(p, src, len);
- return dest;
-}
-EXPORT_SYMBOL_NOVERS(strncat);
-
-/**
- * strcmp - Compare two strings
- * @cs: One string
- * @ct: Another string
- *
- * returns 0 if @cs and @ct are equal,
- * < 0 if @cs is less than @ct
- * > 0 if @cs is greater than @ct
- */
-int strcmp(const char *cs, const char *ct)
-{
- register int r0 asm("0") = 0;
- int ret = 0;
-
- asm volatile ("0: clst %2,%3\n"
- " jo 0b\n"
- " je 1f\n"
- " ic %0,0(%2)\n"
- " ic %1,0(%3)\n"
- " sr %0,%1\n"
- "1:"
- : "+d" (ret), "+d" (r0), "+a" (cs), "+a" (ct)
- : : "cc" );
- return ret;
-}
-EXPORT_SYMBOL_NOVERS(strcmp);
-
-/**
- * strrchr - Find the last occurrence of a character in a string
- * @s: The string to be searched
- * @c: The character to search for
- */
-char * strrchr(const char * s, int c)
-{
- size_t len = __strend(s) - s;
-
- if (len)
- do {
- if (s[len] == (char) c)
- return (char *) s + len;
- } while (--len > 0);
- return 0;
-}
-EXPORT_SYMBOL_NOVERS(strrchr);
-
-/**
- * strstr - Find the first substring in a %NUL terminated string
- * @s1: The string to be searched
- * @s2: The string to search for
- */
-char * strstr(const char * s1,const char * s2)
-{
- int l1, l2;
-
- l2 = __strend(s2) - s2;
- if (!l2)
- return (char *) s1;
- l1 = __strend(s1) - s1;
- while (l1-- >= l2) {
- register unsigned long r2 asm("2") = (unsigned long) s1;
- register unsigned long r3 asm("3") = (unsigned long) l2;
- register unsigned long r4 asm("4") = (unsigned long) s2;
- register unsigned long r5 asm("5") = (unsigned long) l2;
- int cc;
-
- asm volatile ("0: clcle %1,%3,0\n"
- " jo 0b\n"
- " ipm %0\n"
- " srl %0,28"
- : "=&d" (cc), "+a" (r2), "+a" (r3),
- "+a" (r4), "+a" (r5) : : "cc" );
- if (!cc)
- return (char *) s1;
- s1++;
- }
- return 0;
-}
-EXPORT_SYMBOL_NOVERS(strstr);
-
-/**
- * memchr - Find a character in an area of memory.
- * @s: The memory area
- * @c: The byte to search for
- * @n: The size of the area.
- *
- * returns the address of the first occurrence of @c, or %NULL
- * if @c is not found
- */
-void *memchr(const void *s, int c, size_t n)
-{
- register int r0 asm("0") = (char) c;
- const void *ret = s + n;
-
- asm volatile ("0: srst %0,%1\n"
- " jo 0b\n"
- " jl 1f\n"
- " la %0,0\n"
- "1:"
- : "+a" (ret), "+&a" (s) : "d" (r0) : "cc" );
- return (void *) ret;
-}
-EXPORT_SYMBOL_NOVERS(memchr);
-
-/**
- * memcmp - Compare two areas of memory
- * @cs: One area of memory
- * @ct: Another area of memory
- * @count: The size of the area.
- */
-int memcmp(const void *cs, const void *ct, size_t n)
-{
- register unsigned long r2 asm("2") = (unsigned long) cs;
- register unsigned long r3 asm("3") = (unsigned long) n;
- register unsigned long r4 asm("4") = (unsigned long) ct;
- register unsigned long r5 asm("5") = (unsigned long) n;
- int ret;
-
- asm volatile ("0: clcle %1,%3,0\n"
- " jo 0b\n"
- " ipm %0\n"
- " srl %0,28"
- : "=&d" (ret), "+a" (r2), "+a" (r3), "+a" (r4), "+a" (r5)
- : : "cc" );
- if (ret)
- ret = *(char *) r2 - *(char *) r4;
- return ret;
-}
-EXPORT_SYMBOL_NOVERS(memcmp);
-
-/**
- * memscan - Find a character in an area of memory.
- * @s: The memory area
- * @c: The byte to search for
- * @n: The size of the area.
- *
- * returns the address of the first occurrence of @c, or 1 byte past
- * the area if @c is not found
- */
-void *memscan(void *s, int c, size_t n)
-{
- register int r0 asm("0") = (char) c;
- const void *ret = s + n;
-
- asm volatile ("0: srst %0,%1\n"
- " jo 0b\n"
- : "+a" (ret), "+&a" (s) : "d" (r0) : "cc" );
- return (void *) ret;
-}
-EXPORT_SYMBOL_NOVERS(memscan);
-
-/**
- * memcpy - Copy one area of memory to another
- * @dest: Where to copy to
- * @src: Where to copy from
- * @n: The size of the area.
- *
- * returns a pointer to @dest
- */
-void *memcpy(void *dest, const void *src, size_t n)
-{
- return __builtin_memcpy(dest, src, n);
-}
-EXPORT_SYMBOL_NOVERS(memcpy);
-
-/**
- * bcopy - Copy one area of memory to another
- * @src: Where to copy from
- * @dest: Where to copy to
- * @n: The size of the area.
- *
- * Note that this is the same as memcpy(), with the arguments reversed.
- * memcpy() is the standard, bcopy() is a legacy BSD function.
- */
-void bcopy(const void *srcp, void *destp, size_t n)
-{
- __builtin_memcpy(destp, srcp, n);
-}
-EXPORT_SYMBOL_NOVERS(bcopy);
-
-/**
- * memset - Fill a region of memory with the given value
- * @s: Pointer to the start of the area.
- * @c: The byte to fill the area with
- * @n: The size of the area.
- *
- * returns a pointer to @s
- */
-void *memset(void *s, int c, size_t n)
-{
- char *xs;
-
- if (c == 0)
- return __builtin_memset(s, 0, n);
-
- xs = (char *) s;
- if (n > 0)
- do {
- *xs++ = c;
- } while (--n > 0);
- return s;
-}
-EXPORT_SYMBOL_NOVERS(memset);
-
-/*
- * missing exports for string functions defined in lib/string.c
- */
-EXPORT_SYMBOL_NOVERS(memmove);
-EXPORT_SYMBOL_NOVERS(strchr);
-EXPORT_SYMBOL_NOVERS(strnchr);
-EXPORT_SYMBOL_NOVERS(strncmp);
-EXPORT_SYMBOL_NOVERS(strpbrk);
+++ /dev/null
-#include <asm/bitops.h>
-
-/**
- * find_next_bit - find the next set bit in a memory region
- * @addr: The address to base the search on
- * @offset: The bitnumber to start searching at
- * @size: The maximum size to search
- */
-unsigned long find_next_bit(unsigned long *addr, unsigned long size, unsigned long offset)
-{
- unsigned long *p = addr + (offset >> 6);
- unsigned long result = offset & ~63UL;
- unsigned long tmp;
-
- if (offset >= size)
- return size;
- size -= result;
- offset &= 63UL;
- if (offset) {
- tmp = *(p++);
- tmp &= (~0UL << offset);
- if (size < 64)
- goto found_first;
- if (tmp)
- goto found_middle;
- size -= 64;
- result += 64;
- }
- while (size & ~63UL) {
- if ((tmp = *(p++)))
- goto found_middle;
- result += 64;
- size -= 64;
- }
- if (!size)
- return result;
- tmp = *p;
-
-found_first:
- tmp &= (~0UL >> (64 - size));
- if (tmp == 0UL) /* Are any bits set? */
- return result + size; /* Nope. */
-found_middle:
- return result + __ffs(tmp);
-}
-
-/* find_next_zero_bit() finds the first zero bit in a bit string of length
- * 'size' bits, starting the search at bit 'offset'. This is largely based
- * on Linus's ALPHA routines, which are pretty portable BTW.
- */
-
-unsigned long find_next_zero_bit(unsigned long *addr, unsigned long size, unsigned long offset)
-{
- unsigned long *p = addr + (offset >> 6);
- unsigned long result = offset & ~63UL;
- unsigned long tmp;
-
- if (offset >= size)
- return size;
- size -= result;
- offset &= 63UL;
- if (offset) {
- tmp = *(p++);
- tmp |= ~0UL >> (64-offset);
- if (size < 64)
- goto found_first;
- if (~tmp)
- goto found_middle;
- size -= 64;
- result += 64;
- }
- while (size & ~63UL) {
- if (~(tmp = *(p++)))
- goto found_middle;
- result += 64;
- size -= 64;
- }
- if (!size)
- return result;
- tmp = *p;
-
-found_first:
- tmp |= ~0UL << size;
- if (tmp == ~0UL) /* Are any bits zero? */
- return result + size; /* Nope. */
-found_middle:
- return result + ffz(tmp);
-}
-
-unsigned long find_next_zero_le_bit(unsigned long *addr, unsigned long size, unsigned long offset)
-{
- unsigned long *p = addr + (offset >> 6);
- unsigned long result = offset & ~63UL;
- unsigned long tmp;
-
- if (offset >= size)
- return size;
- size -= result;
- offset &= 63UL;
- if(offset) {
- tmp = __swab64p(p++);
- tmp |= (~0UL >> (64-offset));
- if(size < 64)
- goto found_first;
- if(~tmp)
- goto found_middle;
- size -= 64;
- result += 64;
- }
- while(size & ~63) {
- if(~(tmp = __swab64p(p++)))
- goto found_middle;
- result += 64;
- size -= 64;
- }
- if(!size)
- return result;
- tmp = __swab64p(p);
-found_first:
- tmp |= (~0UL << size);
- if (tmp == ~0UL) /* Are any bits zero? */
- return result + size; /* Nope. */
-found_middle:
- return result + ffz(tmp);
-}
+++ /dev/null
-#ifndef __COW_H__
-#define __COW_H__
-
-#include <asm/types.h>
-
-#if __BYTE_ORDER == __BIG_ENDIAN
-# define ntohll(x) (x)
-# define htonll(x) (x)
-#elif __BYTE_ORDER == __LITTLE_ENDIAN
-# define ntohll(x) bswap_64(x)
-# define htonll(x) bswap_64(x)
-#else
-#error "__BYTE_ORDER not defined"
-#endif
-
-extern int init_cow_file(int fd, char *cow_file, char *backing_file,
- int sectorsize, int alignment, int *bitmap_offset_out,
- unsigned long *bitmap_len_out, int *data_offset_out);
-
-extern int file_reader(__u64 offset, char *buf, int len, void *arg);
-extern int read_cow_header(int (*reader)(__u64, char *, int, void *),
- void *arg, __u32 *version_out,
- char **backing_file_out, time_t *mtime_out,
- __u64 *size_out, int *sectorsize_out,
- __u32 *align_out, int *bitmap_offset_out);
-
-extern int write_cow_header(char *cow_file, int fd, char *backing_file,
- int sectorsize, int alignment, long long *size);
-
-extern void cow_sizes(int version, __u64 size, int sectorsize, int align,
- int bitmap_offset, unsigned long *bitmap_len_out,
- int *data_offset_out);
-
-#endif
-
-/*
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
+++ /dev/null
-#include <stddef.h>
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-#include <byteswap.h>
-#include <sys/time.h>
-#include <sys/param.h>
-#include <sys/user.h>
-#include <netinet/in.h>
-
-#include "os.h"
-
-#include "cow.h"
-#include "cow_sys.h"
-
-#define PATH_LEN_V1 256
-
-struct cow_header_v1 {
- int magic;
- int version;
- char backing_file[PATH_LEN_V1];
- time_t mtime;
- __u64 size;
- int sectorsize;
-};
-
-#define PATH_LEN_V2 MAXPATHLEN
-
-struct cow_header_v2 {
- unsigned long magic;
- unsigned long version;
- char backing_file[PATH_LEN_V2];
- time_t mtime;
- __u64 size;
- int sectorsize;
-};
-
-/* Define PATH_LEN_V3 as the usual value of MAXPATHLEN, just hard-code it in
- * case other systems have different values for MAXPATHLEN
- */
-#define PATH_LEN_V3 4096
-
-/* Changes from V2 -
- * PATH_LEN_V3 as described above
- * Explicitly specify field bit lengths for systems with different
- * lengths for the usual C types. Not sure whether char or
- * time_t should be changed, this can be changed later without
- * breaking compatibility
- * Add alignment field so that different alignments can be used for the
- * bitmap and data
- * Add cow_format field to allow for the possibility of different ways
- * of specifying the COW blocks. For now, the only value is 0,
- * for the traditional COW bitmap.
- * Move the backing_file field to the end of the header. This allows
- * for the possibility of expanding it into the padding required
- * by the bitmap alignment.
- * The bitmap and data portions of the file will be aligned as specified
- * by the alignment field. This is to allow COW files to be
- * put on devices with restrictions on access alignments, such as
- * /dev/raw, with a 512 byte alignment restriction. This also
- * allows the data to be more aligned more strictly than on
- * sector boundaries. This is needed for ubd-mmap, which needs
- * the data to be page aligned.
- * Fixed (finally!) the rounding bug
- */
-
-struct cow_header_v3 {
- __u32 magic;
- __u32 version;
- time_t mtime;
- __u64 size;
- __u32 sectorsize;
- __u32 alignment;
- __u32 cow_format;
- char backing_file[PATH_LEN_V3];
-};
-
-/* COW format definitions - for now, we have only the usual COW bitmap */
-#define COW_BITMAP 0
-
-union cow_header {
- struct cow_header_v1 v1;
- struct cow_header_v2 v2;
- struct cow_header_v3 v3;
-};
-
-#define COW_MAGIC 0x4f4f4f4d /* MOOO */
-#define COW_VERSION 3
-
-#define DIV_ROUND(x, len) (((x) + (len) - 1) / (len))
-#define ROUND_UP(x, align) DIV_ROUND(x, align) * (align)
-
-void cow_sizes(int version, __u64 size, int sectorsize, int align,
- int bitmap_offset, unsigned long *bitmap_len_out,
- int *data_offset_out)
-{
- if(version < 3){
- *bitmap_len_out = (size + sectorsize - 1) / (8 * sectorsize);
-
- *data_offset_out = bitmap_offset + *bitmap_len_out;
- *data_offset_out = (*data_offset_out + sectorsize - 1) /
- sectorsize;
- *data_offset_out *= sectorsize;
- }
- else {
- *bitmap_len_out = DIV_ROUND(size, sectorsize);
- *bitmap_len_out = DIV_ROUND(*bitmap_len_out, 8);
-
- *data_offset_out = bitmap_offset + *bitmap_len_out;
- *data_offset_out = ROUND_UP(*data_offset_out, align);
- }
-}
-
-static int absolutize(char *to, int size, char *from)
-{
- char save_cwd[256], *slash;
- int remaining;
-
- if(getcwd(save_cwd, sizeof(save_cwd)) == NULL) {
- cow_printf("absolutize : unable to get cwd - errno = %d\n",
- errno);
- return(-1);
- }
- slash = strrchr(from, '/');
- if(slash != NULL){
- *slash = '\0';
- if(chdir(from)){
- *slash = '/';
- cow_printf("absolutize : Can't cd to '%s' - "
- "errno = %d\n", from, errno);
- return(-1);
- }
- *slash = '/';
- if(getcwd(to, size) == NULL){
- cow_printf("absolutize : unable to get cwd of '%s' - "
- "errno = %d\n", from, errno);
- return(-1);
- }
- remaining = size - strlen(to);
- if(strlen(slash) + 1 > remaining){
- cow_printf("absolutize : unable to fit '%s' into %d "
- "chars\n", from, size);
- return(-1);
- }
- strcat(to, slash);
- }
- else {
- if(strlen(save_cwd) + 1 + strlen(from) + 1 > size){
- cow_printf("absolutize : unable to fit '%s' into %d "
- "chars\n", from, size);
- return(-1);
- }
- strcpy(to, save_cwd);
- strcat(to, "/");
- strcat(to, from);
- }
- chdir(save_cwd);
- return(0);
-}
-
-int write_cow_header(char *cow_file, int fd, char *backing_file,
- int sectorsize, int alignment, long long *size)
-{
- struct cow_header_v3 *header;
- unsigned long modtime;
- int err;
-
- err = cow_seek_file(fd, 0);
- if(err < 0){
- cow_printf("write_cow_header - lseek failed, err = %d\n", -err);
- goto out;
- }
-
- err = -ENOMEM;
- header = cow_malloc(sizeof(*header));
- if(header == NULL){
- cow_printf("Failed to allocate COW V3 header\n");
- goto out;
- }
- header->magic = htonl(COW_MAGIC);
- header->version = htonl(COW_VERSION);
-
- err = -EINVAL;
- if(strlen(backing_file) > sizeof(header->backing_file) - 1){
- cow_printf("Backing file name \"%s\" is too long - names are "
- "limited to %d characters\n", backing_file,
- sizeof(header->backing_file) - 1);
- goto out_free;
- }
-
- if(absolutize(header->backing_file, sizeof(header->backing_file),
- backing_file))
- goto out_free;
-
- err = os_file_modtime(header->backing_file, &modtime);
- if(err < 0){
- cow_printf("Backing file '%s' mtime request failed, "
- "err = %d\n", header->backing_file, -err);
- goto out_free;
- }
-
- err = cow_file_size(header->backing_file, size);
- if(err < 0){
- cow_printf("Couldn't get size of backing file '%s', "
- "err = %d\n", header->backing_file, -err);
- goto out_free;
- }
-
- header->mtime = htonl(modtime);
- header->size = htonll(*size);
- header->sectorsize = htonl(sectorsize);
- header->alignment = htonl(alignment);
- header->cow_format = COW_BITMAP;
-
- err = os_write_file(fd, header, sizeof(*header));
- if(err != sizeof(*header)){
- cow_printf("Write of header to new COW file '%s' failed, "
- "err = %d\n", cow_file, -err);
- goto out_free;
- }
- err = 0;
- out_free:
- cow_free(header);
- out:
- return(err);
-}
-
-int file_reader(__u64 offset, char *buf, int len, void *arg)
-{
- int fd = *((int *) arg);
-
- return(pread(fd, buf, len, offset));
-}
-
-/* XXX Need to sanity-check the values read from the header */
-
-int read_cow_header(int (*reader)(__u64, char *, int, void *), void *arg,
- __u32 *version_out, char **backing_file_out,
- time_t *mtime_out, __u64 *size_out,
- int *sectorsize_out, __u32 *align_out,
- int *bitmap_offset_out)
-{
- union cow_header *header;
- char *file;
- int err, n;
- unsigned long version, magic;
-
- header = cow_malloc(sizeof(*header));
- if(header == NULL){
- cow_printf("read_cow_header - Failed to allocate header\n");
- return(-ENOMEM);
- }
- err = -EINVAL;
- n = (*reader)(0, (char *) header, sizeof(*header), arg);
- if(n < offsetof(typeof(header->v1), backing_file)){
- cow_printf("read_cow_header - short header\n");
- goto out;
- }
-
- magic = header->v1.magic;
- if(magic == COW_MAGIC) {
- version = header->v1.version;
- }
- else if(magic == ntohl(COW_MAGIC)){
- version = ntohl(header->v1.version);
- }
- /* No error printed because the non-COW case comes through here */
- else goto out;
-
- *version_out = version;
-
- if(version == 1){
- if(n < sizeof(header->v1)){
- cow_printf("read_cow_header - failed to read V1 "
- "header\n");
- goto out;
- }
- *mtime_out = header->v1.mtime;
- *size_out = header->v1.size;
- *sectorsize_out = header->v1.sectorsize;
- *bitmap_offset_out = sizeof(header->v1);
- *align_out = *sectorsize_out;
- file = header->v1.backing_file;
- }
- else if(version == 2){
- if(n < sizeof(header->v2)){
- cow_printf("read_cow_header - failed to read V2 "
- "header\n");
- goto out;
- }
- *mtime_out = ntohl(header->v2.mtime);
- *size_out = ntohll(header->v2.size);
- *sectorsize_out = ntohl(header->v2.sectorsize);
- *bitmap_offset_out = sizeof(header->v2);
- *align_out = *sectorsize_out;
- file = header->v2.backing_file;
- }
- else if(version == 3){
- if(n < sizeof(header->v3)){
- cow_printf("read_cow_header - failed to read V2 "
- "header\n");
- goto out;
- }
- *mtime_out = ntohl(header->v3.mtime);
- *size_out = ntohll(header->v3.size);
- *sectorsize_out = ntohl(header->v3.sectorsize);
- *align_out = ntohl(header->v3.alignment);
- *bitmap_offset_out = ROUND_UP(sizeof(header->v3), *align_out);
- file = header->v3.backing_file;
- }
- else {
- cow_printf("read_cow_header - invalid COW version\n");
- goto out;
- }
- err = -ENOMEM;
- *backing_file_out = cow_strdup(file);
- if(*backing_file_out == NULL){
- cow_printf("read_cow_header - failed to allocate backing "
- "file\n");
- goto out;
- }
- err = 0;
- out:
- cow_free(header);
- return(err);
-}
-
-int init_cow_file(int fd, char *cow_file, char *backing_file, int sectorsize,
- int alignment, int *bitmap_offset_out,
- unsigned long *bitmap_len_out, int *data_offset_out)
-{
- __u64 size, offset;
- char zero = 0;
- int err;
-
- err = write_cow_header(cow_file, fd, backing_file, sectorsize,
- alignment, &size);
- if(err)
- goto out;
-
- *bitmap_offset_out = ROUND_UP(sizeof(struct cow_header_v3), alignment);
- cow_sizes(COW_VERSION, size, sectorsize, alignment, *bitmap_offset_out,
- bitmap_len_out, data_offset_out);
-
- offset = *data_offset_out + size - sizeof(zero);
- err = cow_seek_file(fd, offset);
- if(err < 0){
- cow_printf("cow bitmap lseek failed : err = %d\n", -err);
- goto out;
- }
-
- /* does not really matter how much we write it is just to set EOF
- * this also sets the entire COW bitmap
- * to zero without having to allocate it
- */
- err = cow_write_file(fd, &zero, sizeof(zero));
- if(err != sizeof(zero)){
- cow_printf("Write of bitmap to new COW file '%s' failed, "
- "err = %d\n", cow_file, -err);
- err = -EINVAL;
- goto out;
- }
-
- return(0);
-
- out:
- return(err);
-}
-
-/*
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
+++ /dev/null
-/*
- * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#ifndef __IRQ_KERN_H__
-#define __IRQ_KERN_H__
-
-#include "linux/interrupt.h"
-
-extern int um_request_irq(unsigned int irq, int fd, int type,
- irqreturn_t (*handler)(int, void *,
- struct pt_regs *),
- unsigned long irqflags, const char * devname,
- void *dev_id);
-
-#endif
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only. This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
+++ /dev/null
-/*
- * Copyright (C) 2003 Jeff Dike (jdike@addtoit.com)
- * Licensed under the GPL
- */
-
-#ifndef __MEM_KERN_H__
-#define __MEM_KERN_H__
-
-#include "linux/list.h"
-#include "linux/types.h"
-
-struct remapper {
- struct list_head list;
- int (*proc)(int, unsigned long, int, __u64);
-};
-
-extern void register_remapper(struct remapper *info);
-
-#endif
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only. This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
+++ /dev/null
-/*
- * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
- * Licensed under the GPL
- */
-
-#include "linux/mm.h"
-#include "linux/ghash.h"
-#include "linux/slab.h"
-#include "linux/vmalloc.h"
-#include "linux/bootmem.h"
-#include "asm/types.h"
-#include "asm/pgtable.h"
-#include "kern_util.h"
-#include "user_util.h"
-#include "mode_kern.h"
-#include "mem.h"
-#include "mem_user.h"
-#include "os.h"
-#include "kern.h"
-#include "init.h"
-
-#if 0
-static pgd_t physmem_pgd[PTRS_PER_PGD];
-
-static struct phys_desc *lookup_mapping(void *addr)
-{
- pgd = &physmem_pgd[pgd_index(addr)];
- if(pgd_none(pgd))
- return(NULL);
-
- pmd = pmd_offset(pgd, addr);
- if(pmd_none(pmd))
- return(NULL);
-
- pte = pte_offset_kernel(pmd, addr);
- return((struct phys_desc *) pte_val(pte));
-}
-
-static struct add_mapping(void *addr, struct phys_desc *new)
-{
-}
-#endif
-
-#define PHYS_HASHSIZE (8192)
-
-struct phys_desc;
-
-DEF_HASH_STRUCTS(virtmem, PHYS_HASHSIZE, struct phys_desc);
-
-struct phys_desc {
- struct virtmem_ptrs virt_ptrs;
- int fd;
- __u64 offset;
- void *virt;
- unsigned long phys;
- struct list_head list;
-};
-
-struct virtmem_table virtmem_hash;
-
-static int virt_cmp(void *virt1, void *virt2)
-{
- return(virt1 != virt2);
-}
-
-static int virt_hash(void *virt)
-{
- unsigned long addr = ((unsigned long) virt) >> PAGE_SHIFT;
- return(addr % PHYS_HASHSIZE);
-}
-
-DEF_HASH(static, virtmem, struct phys_desc, virt_ptrs, void *, virt, virt_cmp,
- virt_hash);
-
-LIST_HEAD(descriptor_mappings);
-
-struct desc_mapping {
- int fd;
- struct list_head list;
- struct list_head pages;
-};
-
-static struct desc_mapping *find_mapping(int fd)
-{
- struct desc_mapping *desc;
- struct list_head *ele;
-
- list_for_each(ele, &descriptor_mappings){
- desc = list_entry(ele, struct desc_mapping, list);
- if(desc->fd == fd)
- return(desc);
- }
-
- return(NULL);
-}
-
-static struct desc_mapping *descriptor_mapping(int fd)
-{
- struct desc_mapping *desc;
-
- desc = find_mapping(fd);
- if(desc != NULL)
- return(desc);
-
- desc = kmalloc(sizeof(*desc), GFP_ATOMIC);
- if(desc == NULL)
- return(NULL);
-
- *desc = ((struct desc_mapping)
- { .fd = fd,
- .list = LIST_HEAD_INIT(desc->list),
- .pages = LIST_HEAD_INIT(desc->pages) });
- list_add(&desc->list, &descriptor_mappings);
-
- return(desc);
-}
-
-int physmem_subst_mapping(void *virt, int fd, __u64 offset, int w)
-{
- struct desc_mapping *fd_maps;
- struct phys_desc *desc;
- unsigned long phys;
- int err;
-
- fd_maps = descriptor_mapping(fd);
- if(fd_maps == NULL)
- return(-ENOMEM);
-
- phys = __pa(virt);
- if(find_virtmem_hash(&virtmem_hash, virt) != NULL)
- panic("Address 0x%p is already substituted\n", virt);
-
- err = -ENOMEM;
- desc = kmalloc(sizeof(*desc), GFP_ATOMIC);
- if(desc == NULL)
- goto out;
-
- *desc = ((struct phys_desc)
- { .virt_ptrs = { NULL, NULL },
- .fd = fd,
- .offset = offset,
- .virt = virt,
- .phys = __pa(virt),
- .list = LIST_HEAD_INIT(desc->list) });
- insert_virtmem_hash(&virtmem_hash, desc);
-
- list_add(&desc->list, &fd_maps->pages);
-
- virt = (void *) ((unsigned long) virt & PAGE_MASK);
- err = os_map_memory(virt, fd, offset, PAGE_SIZE, 1, w, 0);
- if(!err)
- goto out;
-
- remove_virtmem_hash(&virtmem_hash, desc);
- kfree(desc);
- out:
- return(err);
-}
-
-static int physmem_fd = -1;
-
-static void remove_mapping(struct phys_desc *desc)
-{
- void *virt = desc->virt;
- int err;
-
- remove_virtmem_hash(&virtmem_hash, desc);
- list_del(&desc->list);
- kfree(desc);
-
- err = os_map_memory(virt, physmem_fd, __pa(virt), PAGE_SIZE, 1, 1, 0);
- if(err)
- panic("Failed to unmap block device page from physical memory, "
- "errno = %d", -err);
-}
-
-int physmem_remove_mapping(void *virt)
-{
- struct phys_desc *desc;
-
- virt = (void *) ((unsigned long) virt & PAGE_MASK);
- desc = find_virtmem_hash(&virtmem_hash, virt);
- if(desc == NULL)
- return(0);
-
- remove_mapping(desc);
- return(1);
-}
-
-void physmem_forget_descriptor(int fd)
-{
- struct desc_mapping *desc;
- struct phys_desc *page;
- struct list_head *ele, *next;
- __u64 offset;
- void *addr;
- int err;
-
- desc = find_mapping(fd);
- if(desc == NULL)
- return;
-
- list_for_each_safe(ele, next, &desc->pages){
- page = list_entry(ele, struct phys_desc, list);
- offset = page->offset;
- addr = page->virt;
- remove_mapping(page);
- err = os_seek_file(fd, offset);
- if(err)
- panic("physmem_forget_descriptor - failed to seek "
- "to %lld in fd %d, error = %d\n",
- offset, fd, -err);
- err = os_read_file(fd, addr, PAGE_SIZE);
- if(err < 0)
- panic("physmem_forget_descriptor - failed to read "
- "from fd %d to 0x%p, error = %d\n",
- fd, addr, -err);
- }
-
- list_del(&desc->list);
- kfree(desc);
-}
-
-void arch_free_page(struct page *page, int order)
-{
- void *virt;
- int i;
-
- for(i = 0; i < (1 << order); i++){
- virt = __va(page_to_phys(page + i));
- physmem_remove_mapping(virt);
- }
-}
-
-int is_remapped(void *virt)
-{
- return(find_virtmem_hash(&virtmem_hash, virt) != NULL);
-}
-
-/* Changed during early boot */
-unsigned long high_physmem;
-
-extern unsigned long physmem_size;
-
-void *to_virt(unsigned long phys)
-{
- return((void *) uml_physmem + phys);
-}
-
-unsigned long to_phys(void *virt)
-{
- return(((unsigned long) virt) - uml_physmem);
-}
-
-int init_maps(unsigned long physmem, unsigned long iomem, unsigned long highmem)
-{
- struct page *p, *map;
- unsigned long phys_len, phys_pages, highmem_len, highmem_pages;
- unsigned long iomem_len, iomem_pages, total_len, total_pages;
- int i;
-
- phys_pages = physmem >> PAGE_SHIFT;
- phys_len = phys_pages * sizeof(struct page);
-
- iomem_pages = iomem >> PAGE_SHIFT;
- iomem_len = iomem_pages * sizeof(struct page);
-
- highmem_pages = highmem >> PAGE_SHIFT;
- highmem_len = highmem_pages * sizeof(struct page);
-
- total_pages = phys_pages + iomem_pages + highmem_pages;
- total_len = phys_len + iomem_pages + highmem_len;
-
- if(kmalloc_ok){
- map = kmalloc(total_len, GFP_KERNEL);
- if(map == NULL)
- map = vmalloc(total_len);
- }
- else map = alloc_bootmem_low_pages(total_len);
-
- if(map == NULL)
- return(-ENOMEM);
-
- for(i = 0; i < total_pages; i++){
- p = &map[i];
- set_page_count(p, 0);
- SetPageReserved(p);
- INIT_LIST_HEAD(&p->lru);
- }
-
- mem_map = map;
- max_mapnr = total_pages;
- return(0);
-}
-
-struct page *phys_to_page(const unsigned long phys)
-{
- return(&mem_map[phys >> PAGE_SHIFT]);
-}
-
-struct page *__virt_to_page(const unsigned long virt)
-{
- return(&mem_map[__pa(virt) >> PAGE_SHIFT]);
-}
-
-unsigned long page_to_phys(struct page *page)
-{
- return((page - mem_map) << PAGE_SHIFT);
-}
-
-pte_t mk_pte(struct page *page, pgprot_t pgprot)
-{
- pte_t pte;
-
- pte_val(pte) = page_to_phys(page) + pgprot_val(pgprot);
- if(pte_present(pte)) pte_mknewprot(pte_mknewpage(pte));
- return(pte);
-}
-
-/* Changed during early boot */
-static unsigned long kmem_top = 0;
-
-unsigned long get_kmem_end(void)
-{
- if(kmem_top == 0)
- kmem_top = CHOOSE_MODE(kmem_end_tt, kmem_end_skas);
- return(kmem_top);
-}
-
-void map_memory(unsigned long virt, unsigned long phys, unsigned long len,
- int r, int w, int x)
-{
- __u64 offset;
- int fd, err;
-
- fd = phys_mapping(phys, &offset);
- err = os_map_memory((void *) virt, fd, offset, len, r, w, x);
- if(err)
- panic("map_memory(0x%lx, %d, 0x%llx, %ld, %d, %d, %d) failed, "
- "err = %d\n", virt, fd, offset, len, r, w, x, err);
-}
-
-#define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
-
-void setup_physmem(unsigned long start, unsigned long reserve_end,
- unsigned long len, unsigned long highmem)
-{
- unsigned long reserve = reserve_end - start;
- int pfn = PFN_UP(__pa(reserve_end));
- int delta = (len - reserve) >> PAGE_SHIFT;
- int err, offset, bootmap_size;
-
- physmem_fd = create_mem_file(len + highmem);
-
- offset = uml_reserved - uml_physmem;
- err = os_map_memory((void *) uml_reserved, physmem_fd, offset,
- len - offset, 1, 1, 0);
- if(err < 0){
- os_print_error(err, "Mapping memory");
- exit(1);
- }
-
- bootmap_size = init_bootmem(pfn, pfn + delta);
- free_bootmem(__pa(reserve_end) + bootmap_size,
- len - bootmap_size - reserve);
-}
-
-int phys_mapping(unsigned long phys, __u64 *offset_out)
-{
- struct phys_desc *desc = find_virtmem_hash(&virtmem_hash,
- __va(phys & PAGE_MASK));
- int fd = -1;
-
- if(desc != NULL){
- fd = desc->fd;
- *offset_out = desc->offset;
- }
- else if(phys < physmem_size){
- fd = physmem_fd;
- *offset_out = phys;
- }
- else if(phys < __pa(end_iomem)){
- struct iomem_region *region = iomem_regions;
-
- while(region != NULL){
- if((phys >= region->phys) &&
- (phys < region->phys + region->size)){
- fd = region->fd;
- *offset_out = phys - region->phys;
- break;
- }
- region = region->next;
- }
- }
- else if(phys < __pa(end_iomem) + highmem){
- fd = physmem_fd;
- *offset_out = phys - iomem_size;
- }
-
- return(fd);
-}
-
-static int __init uml_mem_setup(char *line, int *add)
-{
- char *retptr;
- physmem_size = memparse(line,&retptr);
- return 0;
-}
-__uml_setup("mem=", uml_mem_setup,
-"mem=<Amount of desired ram>\n"
-" This controls how much \"physical\" memory the kernel allocates\n"
-" for the system. The size is specified as a number followed by\n"
-" one of 'k', 'K', 'm', 'M', which have the obvious meanings.\n"
-" This is not related to the amount of memory in the host. It can\n"
-" be more, and the excess, if it's ever used, will just be swapped out.\n"
-" Example: mem=64M\n\n"
-);
-
-unsigned long find_iomem(char *driver, unsigned long *len_out)
-{
- struct iomem_region *region = iomem_regions;
-
- while(region != NULL){
- if(!strcmp(region->driver, driver)){
- *len_out = region->size;
- return(region->virt);
- }
- }
-
- return(0);
-}
-
-int setup_iomem(void)
-{
- struct iomem_region *region = iomem_regions;
- unsigned long iomem_start = high_physmem + PAGE_SIZE;
- int err;
-
- while(region != NULL){
- err = os_map_memory((void *) iomem_start, region->fd, 0,
- region->size, 1, 1, 0);
- if(err)
- printk("Mapping iomem region for driver '%s' failed, "
- "errno = %d\n", region->driver, -err);
- else {
- region->virt = iomem_start;
- region->phys = __pa(region->virt);
- }
-
- iomem_start += region->size + PAGE_SIZE;
- region = region->next;
- }
-
- return(0);
-}
-
-__initcall(setup_iomem);
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only. This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
+++ /dev/null
-/*
- * Copyright (C) 2002 - 2003 Jeff Dike (jdike@addtoit.com)
- * Licensed under the GPL
- */
-
-#include "linux/stddef.h"
-#include "linux/kernel.h"
-#include "linux/string.h"
-#include "linux/fs.h"
-#include "linux/highmem.h"
-#include "asm/page.h"
-#include "asm/pgtable.h"
-#include "asm/uaccess.h"
-#include "kern_util.h"
-
-extern void *um_virt_to_phys(struct task_struct *task, unsigned long addr,
- pte_t *pte_out);
-
-static unsigned long maybe_map(unsigned long virt, int is_write)
-{
- pte_t pte;
- int err;
-
- void *phys = um_virt_to_phys(current, virt, &pte);
- int dummy_code;
-
- if(IS_ERR(phys) || (is_write && !pte_write(pte))){
- err = handle_page_fault(virt, 0, is_write, 0, &dummy_code);
- if(err)
- return(0);
- phys = um_virt_to_phys(current, virt, NULL);
- }
- return((unsigned long) phys);
-}
-
-static int do_op(unsigned long addr, int len, int is_write,
- int (*op)(unsigned long addr, int len, void *arg), void *arg)
-{
- struct page *page;
- int n;
-
- addr = maybe_map(addr, is_write);
- if(addr == -1)
- return(-1);
-
- page = phys_to_page(addr);
- addr = (unsigned long) kmap(page) + (addr & ~PAGE_MASK);
- n = (*op)(addr, len, arg);
- kunmap(page);
-
- return(n);
-}
-
-static int buffer_op(unsigned long addr, int len, int is_write,
- int (*op)(unsigned long addr, int len, void *arg),
- void *arg)
-{
- int size = min(PAGE_ALIGN(addr) - addr, (unsigned long) len);
- int remain = len, n;
-
- n = do_op(addr, size, is_write, op, arg);
- if(n != 0)
- return(n < 0 ? remain : 0);
-
- addr += size;
- remain -= size;
- if(remain == 0)
- return(0);
-
- while(addr < ((addr + remain) & PAGE_MASK)){
- n = do_op(addr, PAGE_SIZE, is_write, op, arg);
- if(n != 0)
- return(n < 0 ? remain : 0);
-
- addr += PAGE_SIZE;
- remain -= PAGE_SIZE;
- }
- if(remain == 0)
- return(0);
-
- n = do_op(addr, remain, is_write, op, arg);
- if(n != 0)
- return(n < 0 ? remain : 0);
- return(0);
-}
-
-static int copy_chunk_from_user(unsigned long from, int len, void *arg)
-{
- unsigned long *to_ptr = arg, to = *to_ptr;
-
- memcpy((void *) to, (void *) from, len);
- *to_ptr += len;
- return(0);
-}
-
-int copy_from_user_skas(void *to, const void *from, int n)
-{
- if(segment_eq(get_fs(), KERNEL_DS)){
- memcpy(to, from, n);
- return(0);
- }
-
- return(access_ok_skas(VERIFY_READ, from, n) ?
- buffer_op((unsigned long) from, n, 0, copy_chunk_from_user, &to):
- n);
-}
-
-static int copy_chunk_to_user(unsigned long to, int len, void *arg)
-{
- unsigned long *from_ptr = arg, from = *from_ptr;
-
- memcpy((void *) to, (void *) from, len);
- *from_ptr += len;
- return(0);
-}
-
-int copy_to_user_skas(void *to, const void *from, int n)
-{
- if(segment_eq(get_fs(), KERNEL_DS)){
- memcpy(to, from, n);
- return(0);
- }
-
- return(access_ok_skas(VERIFY_WRITE, to, n) ?
- buffer_op((unsigned long) to, n, 1, copy_chunk_to_user, &from) :
- n);
-}
-
-static int strncpy_chunk_from_user(unsigned long from, int len, void *arg)
-{
- char **to_ptr = arg, *to = *to_ptr;
- int n;
-
- strncpy(to, (void *) from, len);
- n = strnlen(to, len);
- *to_ptr += n;
-
- if(n < len)
- return(1);
- return(0);
-}
-
-int strncpy_from_user_skas(char *dst, const char *src, int count)
-{
- int n;
- char *ptr = dst;
-
- if(segment_eq(get_fs(), KERNEL_DS)){
- strncpy(dst, src, count);
- return(strnlen(dst, count));
- }
-
- if(!access_ok_skas(VERIFY_READ, src, 1))
- return(-EFAULT);
-
- n = buffer_op((unsigned long) src, count, 0, strncpy_chunk_from_user,
- &ptr);
- if(n != 0)
- return(-EFAULT);
- return(strnlen(dst, count));
-}
-
-static int clear_chunk(unsigned long addr, int len, void *unused)
-{
- memset((void *) addr, 0, len);
- return(0);
-}
-
-int __clear_user_skas(void *mem, int len)
-{
- return(buffer_op((unsigned long) mem, len, 1, clear_chunk, NULL));
-}
-
-int clear_user_skas(void *mem, int len)
-{
- if(segment_eq(get_fs(), KERNEL_DS)){
- memset(mem, 0, len);
- return(0);
- }
-
- return(access_ok_skas(VERIFY_WRITE, mem, len) ?
- buffer_op((unsigned long) mem, len, 1, clear_chunk, NULL) : len);
-}
-
-static int strnlen_chunk(unsigned long str, int len, void *arg)
-{
- int *len_ptr = arg, n;
-
- n = strnlen((void *) str, len);
- *len_ptr += n;
-
- if(n < len)
- return(1);
- return(0);
-}
-
-int strnlen_user_skas(const void *str, int len)
-{
- int count = 0, n;
-
- if(segment_eq(get_fs(), KERNEL_DS))
- return(strnlen(str, len) + 1);
-
- n = buffer_op((unsigned long) str, len, 0, strnlen_chunk, &count);
- if(n == 0)
- return(count + 1);
- return(-EFAULT);
-}
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only. This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
+++ /dev/null
-/*
- * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
- * Licensed under the GPL
- */
-
-#include "linux/sched.h"
-#include "asm/uaccess.h"
-
-int copy_from_user_tt(void *to, const void *from, int n)
-{
- if(!access_ok_tt(VERIFY_READ, from, n))
- return(n);
-
- return(__do_copy_from_user(to, from, n, ¤t->thread.fault_addr,
- ¤t->thread.fault_catcher));
-}
-
-int copy_to_user_tt(void *to, const void *from, int n)
-{
- if(!access_ok_tt(VERIFY_WRITE, to, n))
- return(n);
-
- return(__do_copy_to_user(to, from, n, ¤t->thread.fault_addr,
- ¤t->thread.fault_catcher));
-}
-
-int strncpy_from_user_tt(char *dst, const char *src, int count)
-{
- int n;
-
- if(!access_ok_tt(VERIFY_READ, src, 1))
- return(-EFAULT);
-
- n = __do_strncpy_from_user(dst, src, count,
- ¤t->thread.fault_addr,
- ¤t->thread.fault_catcher);
- if(n < 0) return(-EFAULT);
- return(n);
-}
-
-int __clear_user_tt(void *mem, int len)
-{
- return(__do_clear_user(mem, len,
- ¤t->thread.fault_addr,
- ¤t->thread.fault_catcher));
-}
-
-int clear_user_tt(void *mem, int len)
-{
- if(!access_ok_tt(VERIFY_WRITE, mem, len))
- return(len);
-
- return(__do_clear_user(mem, len, ¤t->thread.fault_addr,
- ¤t->thread.fault_catcher));
-}
-
-int strnlen_user_tt(const void *str, int len)
-{
- return(__do_strnlen_user(str, len,
- ¤t->thread.fault_addr,
- ¤t->thread.fault_catcher));
-}
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only. This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
+++ /dev/null
-#include "linux/types.h"
-#include "linux/module.h"
-
-/* Some of this are builtin function (some are not but could in the future),
- * so I *must* declare good prototypes for them and then EXPORT them.
- * The kernel code uses the macro defined by include/linux/string.h,
- * so I undef macros; the userspace code does not include that and I
- * add an EXPORT for the glibc one.*/
-
-#undef strlen
-#undef strstr
-#undef memcpy
-#undef memset
-
-extern size_t strlen(const char *);
-extern void *memcpy(void *, const void *, size_t);
-extern void *memset(void *, int, size_t);
-extern int printf(const char *, ...);
-
-EXPORT_SYMBOL(strlen);
-EXPORT_SYMBOL(memcpy);
-EXPORT_SYMBOL(memset);
-EXPORT_SYMBOL(printf);
-
-EXPORT_SYMBOL(strstr);
-
-/* Here, instead, I can provide a fake prototype. Yes, someone cares: genksyms.
- * However, the modules will use the CRC defined *here*, no matter if it is
- * good; so the versions of these symbols will always match
- */
-#define EXPORT_SYMBOL_PROTO(sym) \
- int sym(void); \
- EXPORT_SYMBOL(sym);
-
-EXPORT_SYMBOL_PROTO(__errno_location);
-
-EXPORT_SYMBOL_PROTO(access);
-EXPORT_SYMBOL_PROTO(open);
-EXPORT_SYMBOL_PROTO(open64);
-EXPORT_SYMBOL_PROTO(close);
-EXPORT_SYMBOL_PROTO(read);
-EXPORT_SYMBOL_PROTO(write);
-EXPORT_SYMBOL_PROTO(dup2);
-EXPORT_SYMBOL_PROTO(__xstat);
-EXPORT_SYMBOL_PROTO(__lxstat);
-EXPORT_SYMBOL_PROTO(__lxstat64);
-EXPORT_SYMBOL_PROTO(lseek);
-EXPORT_SYMBOL_PROTO(lseek64);
-EXPORT_SYMBOL_PROTO(chown);
-EXPORT_SYMBOL_PROTO(truncate);
-EXPORT_SYMBOL_PROTO(utime);
-EXPORT_SYMBOL_PROTO(chmod);
-EXPORT_SYMBOL_PROTO(rename);
-EXPORT_SYMBOL_PROTO(__xmknod);
-
-EXPORT_SYMBOL_PROTO(symlink);
-EXPORT_SYMBOL_PROTO(link);
-EXPORT_SYMBOL_PROTO(unlink);
-EXPORT_SYMBOL_PROTO(readlink);
-
-EXPORT_SYMBOL_PROTO(mkdir);
-EXPORT_SYMBOL_PROTO(rmdir);
-EXPORT_SYMBOL_PROTO(opendir);
-EXPORT_SYMBOL_PROTO(readdir);
-EXPORT_SYMBOL_PROTO(closedir);
-EXPORT_SYMBOL_PROTO(seekdir);
-EXPORT_SYMBOL_PROTO(telldir);
-
-EXPORT_SYMBOL_PROTO(ioctl);
-
-EXPORT_SYMBOL_PROTO(pread64);
-EXPORT_SYMBOL_PROTO(pwrite64);
-
-EXPORT_SYMBOL_PROTO(statfs);
-EXPORT_SYMBOL_PROTO(statfs64);
-
-EXPORT_SYMBOL_PROTO(getuid);
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only. This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
+++ /dev/null
-/*
- * $Id: wr_sbc82xx_flash.c,v 1.1 2004/06/07 10:21:32 dwmw2 Exp $
- *
- * Map for flash chips on Wind River PowerQUICC II SBC82xx board.
- *
- * Copyright (C) 2004 Red Hat, Inc.
- *
- * Author: David Woodhouse <dwmw2@infradead.org>
- *
- */
-
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/slab.h>
-#include <asm/io.h>
-#include <linux/mtd/mtd.h>
-#include <linux/mtd/map.h>
-#include <linux/config.h>
-#include <linux/mtd/partitions.h>
-
-#include <asm/immap_8260.h>
-
-static struct mtd_info *sbcmtd[3];
-static struct mtd_partition *sbcmtd_parts[3];
-
-struct map_info sbc82xx_flash_map[3] = {
- {.name = "Boot flash"},
- {.name = "Alternate boot flash"},
- {.name = "User flash"}
-};
-
-static struct mtd_partition smallflash_parts[] = {
- {
- .name = "space",
- .size = 0x100000,
- .offset = 0,
- }, {
- .name = "bootloader",
- .size = MTDPART_SIZ_FULL,
- .offset = MTDPART_OFS_APPEND,
- }
-};
-
-static struct mtd_partition bigflash_parts[] = {
- {
- .name = "bootloader",
- .size = 0x80000,
- .offset = 0,
- }, {
- .name = "file system",
- .size = MTDPART_SIZ_FULL,
- .offset = MTDPART_OFS_APPEND,
- }
-};
-
-static const char *part_probes[] __initdata = {"cmdlinepart", "RedBoot", NULL};
-
-int __init init_sbc82xx_flash(void)
-{
- volatile memctl8260_t *mc = &immr->im_memctl;
- int bigflash;
- int i;
-
- /* First, register the boot flash, whichever we're booting from */
- if ((mc->memc_br0 & 0x00001800) == 0x00001800) {
- bigflash = 0;
- } else if ((mc->memc_br0 & 0x00001800) == 0x00000800) {
- bigflash = 1;
- } else {
- printk(KERN_WARNING "Bus Controller register BR0 is %08x. Cannot determine flash configuration\n", mc->memc_br0);
- return 1;
- }
-
- /* Set parameters for the big flash chip (CS6 or CS0) */
- sbc82xx_flash_map[bigflash].buswidth = 4;
- sbc82xx_flash_map[bigflash].size = 0x4000000;
-
- /* Set parameters for the small flash chip (CS0 or CS6) */
- sbc82xx_flash_map[!bigflash].buswidth = 1;
- sbc82xx_flash_map[!bigflash].size = 0x200000;
-
- /* Set parameters for the user flash chip (CS1) */
- sbc82xx_flash_map[2].buswidth = 4;
- sbc82xx_flash_map[2].size = 0x4000000;
-
- sbc82xx_flash_map[0].phys = mc->memc_br0 & 0xffff8000;
- sbc82xx_flash_map[1].phys = mc->memc_br6 & 0xffff8000;
- sbc82xx_flash_map[2].phys = mc->memc_br1 & 0xffff8000;
-
- for (i=0; i<3; i++) {
- int8_t flashcs[3] = { 0, 6, 1 };
- int nr_parts;
-
- printk(KERN_NOTICE "PowerQUICC II %s (%ld MiB on CS%d",
- sbc82xx_flash_map[i].name, sbc82xx_flash_map[i].size >> 20, flashcs[i]);
- if (!sbc82xx_flash_map[i].phys) {
- /* We know it can't be at zero. */
- printk("): disabled by bootloader.\n");
- continue;
- }
- printk(" at %08lx)\n", sbc82xx_flash_map[i].phys);
-
- sbc82xx_flash_map[i].virt = (unsigned long)ioremap(sbc82xx_flash_map[i].phys, sbc82xx_flash_map[i].size);
-
- if (!sbc82xx_flash_map[i].virt) {
- printk("Failed to ioremap\n");
- continue;
- }
-
- simple_map_init(&sbc82xx_flash_map[i]);
-
- sbcmtd[i] = do_map_probe("cfi_probe", &sbc82xx_flash_map[i]);
-
- if (!sbcmtd[i])
- continue;
-
- sbcmtd[i]->owner = THIS_MODULE;
-
- nr_parts = parse_mtd_partitions(sbcmtd[i], part_probes,
- &sbcmtd_parts[i], 0);
- if (nr_parts > 0) {
- add_mtd_partitions (sbcmtd[i], sbcmtd_parts[i], nr_parts);
- continue;
- }
-
- /* No partitioning detected. Use default */
- if (i == 2) {
- add_mtd_device(sbcmtd[i]);
- } else if (i == bigflash) {
- add_mtd_partitions (sbcmtd[i], bigflash_parts, ARRAY_SIZE(bigflash_parts));
- } else {
- add_mtd_partitions (sbcmtd[i], smallflash_parts, ARRAY_SIZE(smallflash_parts));
- }
- }
- return 0;
-}
-
-static void __exit cleanup_sbc82xx_flash(void)
-{
- int i;
-
- for (i=0; i<3; i++) {
- if (!sbcmtd[i])
- continue;
-
- if (i<2 || sbcmtd_parts[i])
- del_mtd_partitions(sbcmtd[i]);
- else
- del_mtd_device(sbcmtd[i]);
-
- kfree(sbcmtd_parts[i]);
- map_destroy(sbcmtd[i]);
-
- iounmap((void *)sbc82xx_flash_map[i].virt);
- sbc82xx_flash_map[i].virt = 0;
- }
-}
-
-module_init(init_sbc82xx_flash);
-module_exit(cleanup_sbc82xx_flash);
-
-
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>");
-MODULE_DESCRIPTION("Flash map driver for WindRiver PowerQUICC II");
+++ /dev/null
-static u8 firmware[]={
-0x60,0x00,0x00,0x16,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0xB9,0x40,0x00,0x00,0x00,0x00,0x00,
-0x10,0x14,0x42,0x80,0x4A,0xB0,0x09,0xB0,0x00,0x00,0x10,0x04,0x67,0x00,0x00,0x0E,
-0x06,0xB0,0x40,0x00,0x00,0x00,0x09,0xB0,0x00,0x00,0x10,0x04,0x58,0x80,0x0C,0x80,
-0x00,0x00,0x00,0x10,0x66,0x00,0xFF,0xDE,0x21,0xFC,0x00,0x00,0x16,0xBC,0x00,0x6C,
-0x21,0xFC,0x00,0x00,0x17,0x5E,0x01,0x00,0x21,0xFC,0x00,0x00,0x16,0xDE,0x01,0x78,
-0x21,0xFC,0x00,0x00,0x16,0xFE,0x01,0x74,0x21,0xFC,0x00,0x00,0x17,0x1E,0x01,0x70,
-0x21,0xFC,0x00,0x00,0x17,0x3E,0x01,0x6C,0x21,0xFC,0x00,0x00,0x18,0x4C,0x02,0x00,
-0x23,0xFC,0x78,0x00,0x00,0x00,0xFF,0xFC,0x15,0x48,0x33,0xFC,0x04,0x80,0xFF,0xFC,
-0x10,0x26,0x33,0xFC,0x01,0x10,0xFF,0xFC,0x10,0x2A,0x23,0xFC,0x00,0xD4,0x9F,0x40,
-0xFF,0xFC,0x15,0x40,0x23,0xFC,0x00,0x00,0x05,0x43,0xFF,0xF9,0x01,0x00,0x23,0xFC,
-0x00,0x00,0x05,0x43,0xFF,0xF9,0x01,0x14,0x23,0xFC,0x00,0x00,0x00,0x00,0xFF,0xF9,
-0x01,0x10,0x23,0xFC,0x00,0x00,0x00,0x08,0xFF,0xF9,0x01,0x24,0x23,0xFC,0x00,0x00,
-0x01,0x01,0xFF,0xF9,0x01,0x28,0x00,0xB9,0x00,0x0F,0x03,0x00,0xFF,0xF9,0x00,0xE8,
-0x23,0xFC,0x00,0x00,0x00,0x01,0xFF,0xF9,0x00,0xD4,0x61,0x00,0x06,0x74,0x33,0xFC,
-0xFF,0xFF,0xFF,0xFC,0x15,0x52,0x42,0x79,0xFF,0xFC,0x15,0x50,0x42,0x79,0xFF,0xFC,
-0x15,0x64,0x2E,0x3A,0x08,0x50,0x42,0xB9,0x00,0x00,0x19,0x54,0x4A,0x87,0x66,0x00,
-0x00,0x0E,0x4E,0x72,0x22,0x00,0x46,0xFC,0x27,0x00,0x60,0x00,0xFF,0xE6,0x42,0x80,
-0x42,0x86,0x08,0x07,0x00,0x04,0x67,0x00,0x00,0x0A,0x08,0x87,0x00,0x00,0x61,0x00,
-0x02,0xA0,0x08,0x07,0x00,0x00,0x67,0x00,0x00,0x06,0x61,0x00,0x00,0x36,0x08,0x07,
-0x00,0x08,0x67,0x00,0x00,0x06,0x61,0x00,0x02,0xB8,0x08,0x07,0x00,0x0C,0x67,0x00,
-0x00,0x0A,0x61,0x00,0x04,0x94,0x61,0x00,0x03,0x60,0xE2,0x8F,0x58,0x80,0x0C,0x80,
-0x00,0x00,0x00,0x10,0x66,0x00,0xFF,0xBC,0x23,0xC6,0xFF,0xF9,0x00,0xE4,0x60,0x00,
-0xFF,0x92,0x20,0x70,0x09,0xB0,0x00,0x00,0x10,0x04,0x4A,0xA8,0x00,0x00,0x66,0x00,
-0x02,0x4E,0x21,0x7C,0x00,0x00,0x00,0x01,0x00,0x00,0x42,0xB0,0x09,0xB0,0x00,0x00,
-0x19,0x58,0x42,0xB0,0x09,0xB0,0x00,0x00,0x19,0x68,0x42,0xB0,0x09,0xB0,0x00,0x00,
-0x19,0x78,0x42,0xB0,0x09,0xB0,0x00,0x00,0x19,0x88,0x22,0x39,0xFF,0xFC,0x16,0xEC,
-0xC2,0xB0,0x09,0xB0,0x00,0x00,0x18,0xF2,0x0C,0xA8,0x00,0x00,0x00,0x04,0x00,0x18,
-0x66,0x00,0x00,0x0E,0x82,0xB0,0x09,0xB0,0x00,0x00,0x18,0xE2,0x60,0x00,0x00,0x0A,
-0x82,0xB0,0x09,0xB0,0x00,0x00,0x18,0xD2,0x23,0xC1,0xFF,0xFC,0x16,0xEC,0x00,0x70,
-0x10,0x00,0x09,0xB0,0x00,0x00,0x19,0xAA,0x61,0x00,0x05,0x76,0x22,0x30,0x09,0xB0,
-0x00,0x00,0x18,0x92,0x22,0x70,0x09,0xB0,0x00,0x00,0x18,0x72,0x74,0x08,0x26,0x3C,
-0x18,0x00,0x00,0x00,0x0C,0xA8,0x00,0x00,0x00,0x01,0x00,0x10,0x67,0x00,0x00,0x06,
-0x08,0xC3,0x00,0x1A,0x22,0xC3,0x22,0xC1,0x06,0x81,0x00,0x00,0x05,0xFC,0x51,0xCA,
-0xFF,0xF4,0x08,0xC3,0x00,0x1D,0x22,0xC3,0x22,0xC1,0x74,0x1C,0x22,0xFC,0x90,0x00,
-0x00,0x00,0x22,0xC1,0x06,0x81,0x00,0x00,0x05,0xFC,0x51,0xCA,0xFF,0xF0,0x22,0xFC,
-0xB0,0x00,0x00,0x00,0x22,0xC1,0x22,0x70,0x09,0xB0,0x00,0x00,0x18,0x62,0x24,0x70,
-0x09,0xB0,0x00,0x00,0x18,0x52,0x25,0x7C,0x00,0x00,0xFF,0xFF,0x00,0x10,0x25,0x7C,
-0x00,0x00,0x00,0x00,0x00,0x14,0x22,0x30,0x09,0xB0,0x00,0x00,0x18,0x72,0x33,0x41,
-0x00,0x02,0x06,0x81,0x00,0x00,0x00,0x50,0x33,0x41,0x00,0x00,0x13,0x7C,0x00,0x08,
-0x00,0x04,0x13,0x7C,0x00,0x08,0x00,0x05,0x0C,0xA8,0x00,0x00,0x00,0x05,0x00,0x10,
-0x66,0x00,0x00,0x2A,0x42,0x6A,0x00,0x08,0x23,0x7C,0x00,0x00,0xF0,0xB8,0x00,0x34,
-0x23,0x7C,0x00,0x00,0xFF,0xFF,0x00,0x38,0x33,0x7C,0x05,0xFA,0x00,0x46,0x31,0xBC,
-0x00,0x02,0x09,0xB0,0x00,0x00,0x19,0x9C,0x60,0x00,0x00,0xBC,0x0C,0xA8,0x00,0x00,
-0x00,0x07,0x00,0x10,0x66,0x00,0x00,0x2C,0x35,0x7C,0x08,0x00,0x00,0x08,0x23,0x7C,
-0xDE,0xBB,0x20,0xE3,0x00,0x34,0x23,0x7C,0xFF,0xFF,0xFF,0xFF,0x00,0x38,0x33,0x7C,
-0x05,0xFC,0x00,0x46,0x31,0xBC,0x00,0x04,0x09,0xB0,0x00,0x00,0x19,0x9C,0x60,0x00,
-0x00,0x86,0x0C,0xA8,0x00,0x00,0x00,0x04,0x00,0x10,0x66,0x00,0x00,0x26,0x42,0x6A,
-0x00,0x08,0x23,0x7C,0x00,0x00,0xF0,0xB8,0x00,0x34,0x42,0xA9,0x00,0x38,0x33,0x7C,
-0x05,0xFA,0x00,0x46,0x31,0xBC,0x00,0x02,0x09,0xB0,0x00,0x00,0x19,0x9C,0x60,0x00,
-0x00,0x56,0x0C,0xA8,0x00,0x00,0x00,0x06,0x00,0x10,0x66,0x00,0x00,0x28,0x35,0x7C,
-0x08,0x00,0x00,0x08,0x23,0x7C,0xDE,0xBB,0x20,0xE3,0x00,0x34,0x42,0xA9,0x00,0x38,
-0x33,0x7C,0x05,0xFC,0x00,0x46,0x31,0xBC,0x00,0x04,0x09,0xB0,0x00,0x00,0x19,0x9C,
-0x60,0x00,0x00,0x24,0x42,0x6A,0x00,0x08,0x23,0x7C,0x00,0x00,0xF0,0xB8,0x00,0x34,
-0x23,0x7C,0x00,0x00,0xFF,0xFF,0x00,0x38,0x33,0x7C,0x05,0xF8,0x00,0x46,0x42,0x70,
-0x09,0xB0,0x00,0x00,0x19,0x9C,0x25,0x7C,0x00,0x00,0x00,0x03,0x00,0x04,0x0C,0xA8,
-0x00,0x00,0x00,0x02,0x00,0x14,0x66,0x00,0x00,0x0E,0x25,0x7C,0x10,0x04,0x09,0x00,
-0x00,0x00,0x60,0x00,0x00,0x0A,0x25,0x7C,0x10,0x04,0x00,0x00,0x00,0x00,0x33,0x7C,
-0x05,0xFC,0x00,0x06,0x22,0x00,0xE9,0x89,0x00,0x81,0x00,0x00,0x00,0x01,0x33,0xC1,
-0xFF,0xFC,0x15,0xC0,0x08,0x39,0x00,0x00,0xFF,0xFC,0x15,0xC0,0x66,0x00,0xFF,0xF6,
-0x35,0x7C,0x00,0x1F,0x00,0x14,0x00,0xAA,0x00,0x00,0x00,0x30,0x00,0x00,0x4E,0x75,
-0x20,0x70,0x09,0xB0,0x00,0x00,0x18,0x52,0x42,0x68,0x00,0x14,0x02,0xA8,0xFF,0xFF,
-0xFF,0xCF,0x00,0x00,0x02,0x70,0xEF,0xFF,0x09,0xB0,0x00,0x00,0x19,0xAA,0x61,0x00,
-0x03,0x70,0x22,0x30,0x09,0xB0,0x00,0x00,0x10,0x04,0x42,0xB0,0x19,0x90,0x4E,0x75,
-0x0C,0xB0,0x00,0x00,0x00,0x0A,0x09,0xB0,0x00,0x00,0x19,0x78,0x67,0x00,0x00,0xA8,
-0x22,0x30,0x09,0xB0,0x00,0x00,0x19,0x68,0x24,0x01,0x4C,0x3C,0x20,0x00,0x00,0x00,
-0x00,0x0C,0xD4,0xB0,0x09,0xB0,0x00,0x00,0x10,0x04,0x06,0x82,0x00,0x00,0x00,0x1C,
-0x0C,0xB0,0x00,0x00,0x00,0x10,0x29,0x90,0x66,0x00,0x00,0x7C,0x20,0x70,0x29,0xA0,
-0x00,0x04,0xE7,0x89,0xD2,0xB0,0x09,0xB0,0x00,0x00,0x18,0x72,0x22,0x70,0x19,0xA0,
-0x00,0x04,0x24,0x30,0x29,0xA0,0x00,0x08,0x31,0x82,0x19,0xA0,0x00,0x02,0x56,0x82,
-0x02,0x82,0xFF,0xFF,0xFF,0xFC,0x23,0xC8,0xFF,0xF9,0x01,0x04,0x23,0xC9,0xFF,0xF9,
-0x01,0x08,0x23,0xC2,0xFF,0xF9,0x01,0x0C,0x23,0xFC,0x00,0x00,0x01,0x03,0xFF,0xF9,
-0x01,0x28,0x61,0x00,0x01,0xF6,0x08,0xF0,0x00,0x1F,0x19,0x90,0x22,0x30,0x09,0xB0,
-0x00,0x00,0x19,0x68,0x52,0x81,0x0C,0x81,0x00,0x00,0x00,0x0A,0x66,0x00,0x00,0x04,
-0x42,0x81,0x21,0x81,0x09,0xB0,0x00,0x00,0x19,0x68,0x52,0xB0,0x09,0xB0,0x00,0x00,
-0x19,0x78,0x60,0x00,0xFF,0x4C,0x4E,0x75,0x22,0x30,0x09,0xB0,0x00,0x00,0x19,0x88,
-0xE7,0x89,0xD2,0xB0,0x09,0xB0,0x00,0x00,0x18,0x82,0x34,0x30,0x19,0x90,0x08,0x02,
-0x00,0x0F,0x66,0x00,0x01,0x12,0x08,0x02,0x00,0x01,0x66,0x00,0x00,0xE6,0x4A,0x70,
-0x09,0xB0,0x00,0x00,0x19,0x9C,0x66,0x00,0x00,0x06,0x08,0x82,0x00,0x02,0x02,0x42,
-0x0C,0xBC,0x0C,0x42,0x0C,0x00,0x66,0x00,0x00,0xDC,0x42,0x83,0x36,0x30,0x19,0xA0,
-0x00,0x02,0x96,0x70,0x09,0xB0,0x00,0x00,0x19,0x9C,0x0C,0x43,0x05,0xF8,0x6E,0x00,
-0x00,0xC4,0x24,0x3A,0x04,0x84,0x4C,0x3C,0x20,0x00,0x00,0x00,0x00,0x0C,0xD4,0xBA,
-0xFA,0xF4,0x0C,0xB0,0x00,0x00,0x00,0x00,0x29,0x90,0x66,0x00,0x00,0x96,0x21,0x83,
-0x29,0xA0,0x00,0x08,0x20,0x70,0x19,0xA0,0x00,0x04,0x22,0x70,0x29,0xA0,0x00,0x04,
-0x4A,0x89,0x67,0x00,0x00,0x2A,0x56,0x83,0x02,0x83,0xFF,0xFF,0xFF,0xFC,0x23,0xC8,
-0xFF,0xF9,0x01,0x1C,0x23,0xC9,0xFF,0xF9,0x01,0x18,0x23,0xC3,0xFF,0xF9,0x01,0x20,
-0x23,0xFC,0x00,0x00,0x03,0x01,0xFF,0xF9,0x01,0x28,0x61,0x00,0x01,0x2C,0x21,0xB0,
-0x09,0xB0,0x00,0x00,0x18,0xC2,0x29,0x90,0x08,0xC6,0x00,0x04,0x24,0x3A,0x04,0x1A,
-0x52,0x82,0x0C,0x82,0x00,0x00,0x00,0x28,0x66,0x00,0x00,0x04,0x42,0x82,0x23,0xC2,
-0x00,0x00,0x19,0x98,0x02,0x70,0xF0,0x00,0x19,0x90,0x08,0xF0,0x00,0x1F,0x19,0x90,
-0x22,0x30,0x09,0xB0,0x00,0x00,0x19,0x88,0x52,0x81,0x0C,0x81,0x00,0x00,0x00,0x1E,
-0x66,0x00,0x00,0x04,0x42,0x81,0x21,0x81,0x09,0xB0,0x00,0x00,0x19,0x88,0x60,0x00,
-0xFE,0xF8,0x24,0x30,0x09,0xB0,0x00,0x00,0x10,0x04,0x52,0xB0,0x29,0xA0,0x00,0x08,
-0x60,0x00,0xFF,0xC2,0x24,0x30,0x09,0xB0,0x00,0x00,0x10,0x04,0x52,0xB0,0x29,0xA0,
-0x00,0x0C,0x60,0x00,0xFF,0xB0,0x4E,0x75,0x4A,0xB0,0x09,0xB0,0x00,0x00,0x19,0x78,
-0x67,0x00,0x00,0x86,0x22,0x30,0x09,0xB0,0x00,0x00,0x19,0x58,0x24,0x01,0xE7,0x89,
-0xD2,0xB0,0x09,0xB0,0x00,0x00,0x18,0x72,0x36,0x30,0x19,0x90,0x08,0x03,0x00,0x0F,
-0x66,0x00,0x00,0x66,0x8C,0xB0,0x09,0xB0,0x00,0x00,0x18,0xA2,0x53,0xB0,0x09,0xB0,
-0x00,0x00,0x19,0x78,0x22,0x30,0x09,0xB0,0x00,0x00,0x19,0x58,0x52,0x81,0x0C,0x81,
-0x00,0x00,0x00,0x0A,0x66,0x00,0x00,0x04,0x42,0x81,0x21,0x81,0x09,0xB0,0x00,0x00,
-0x19,0x58,0x4C,0x3C,0x20,0x00,0x00,0x00,0x00,0x0C,0xD4,0xB0,0x09,0xB0,0x00,0x00,
-0x10,0x04,0x06,0x82,0x00,0x00,0x00,0x1C,0x08,0x03,0x00,0x01,0x66,0x00,0x00,0x0E,
-0x21,0xBC,0x00,0x00,0x00,0x20,0x29,0x90,0x60,0x00,0xFF,0x7E,0x21,0xBC,0x00,0x00,
-0x00,0x30,0x29,0x90,0x60,0x00,0xFF,0x72,0x4E,0x75,0x2F,0x00,0x40,0xE7,0x20,0x39,
-0xFF,0xF9,0x01,0x28,0x08,0x00,0x00,0x04,0x66,0x00,0x00,0x2C,0x4E,0x72,0x22,0x00,
-0x46,0xFC,0x27,0x00,0x60,0x00,0xFF,0xE8,0x2F,0x00,0x40,0xE7,0x20,0x39,0xFF,0xF9,
-0x01,0x28,0x08,0x00,0x00,0x0C,0x66,0x00,0x00,0x0E,0x4E,0x72,0x22,0x00,0x46,0xFC,
-0x27,0x00,0x60,0x00,0xFF,0xE8,0x46,0xDF,0x20,0x1F,0x4E,0x75,0x2F,0x00,0x20,0x39,
-0xFF,0xF9,0x00,0xE0,0x23,0xC0,0xFF,0xF9,0x00,0xE0,0x81,0xB9,0x00,0x00,0x19,0x54,
-0x23,0xFC,0x00,0x00,0x09,0x09,0xFF,0xF9,0x01,0x28,0x20,0x1F,0x4E,0x73,0x00,0xB9,
-0x00,0x00,0x00,0x00,0xFF,0xFC,0x16,0x10,0x00,0xB9,0x00,0x00,0x10,0x00,0x00,0x00,
-0x19,0x54,0x23,0xFC,0x40,0x00,0x00,0x00,0xFF,0xFC,0x15,0x4C,0x4E,0x73,0x00,0xB9,
-0x00,0x00,0x00,0x00,0xFF,0xFC,0x16,0x30,0x00,0xB9,0x00,0x00,0x20,0x00,0x00,0x00,
-0x19,0x54,0x23,0xFC,0x20,0x00,0x00,0x00,0xFF,0xFC,0x15,0x4C,0x4E,0x73,0x00,0xB9,
-0x00,0x00,0x00,0x00,0xFF,0xFC,0x16,0x50,0x00,0xB9,0x00,0x00,0x40,0x00,0x00,0x00,
-0x19,0x54,0x23,0xFC,0x10,0x00,0x00,0x00,0xFF,0xFC,0x15,0x4C,0x4E,0x73,0x00,0xB9,
-0x00,0x00,0x00,0x00,0xFF,0xFC,0x16,0x70,0x00,0xB9,0x00,0x00,0x80,0x00,0x00,0x00,
-0x19,0x54,0x23,0xFC,0x08,0x00,0x00,0x00,0xFF,0xFC,0x15,0x4C,0x4E,0x73,0x4E,0x73,
-0x2F,0x00,0x2F,0x01,0x2F,0x02,0x2F,0x08,0x2F,0x09,0x42,0x80,0x20,0x7C,0xFF,0xFB,
-0x00,0x00,0x32,0x10,0x02,0x81,0x00,0x00,0x00,0xE7,0x0C,0x41,0x00,0x42,0x66,0x00,
-0x00,0x0A,0x32,0x3C,0x0E,0x08,0x60,0x00,0x00,0x3E,0x0C,0x41,0x00,0x63,0x66,0x00,
-0x00,0x0A,0x32,0x3C,0x04,0x08,0x60,0x00,0x00,0x2E,0x0C,0x41,0x00,0x84,0x66,0x00,
-0x00,0x0A,0x32,0x3C,0x02,0x08,0x60,0x00,0x00,0x1E,0x0C,0x41,0x00,0xA5,0x66,0x00,
-0x00,0x0A,0x32,0x3C,0x0D,0x08,0x60,0x00,0x00,0x0E,0x32,0x3C,0x00,0x08,0x34,0x3C,
-0x80,0xE7,0x60,0x00,0x00,0x14,0x34,0x30,0x09,0xB0,0x00,0x00,0x19,0xAA,0x02,0x42,
-0x30,0x00,0x82,0x42,0x34,0x3C,0x80,0xFF,0xB2,0x70,0x09,0xB0,0x00,0x00,0x19,0xAC,
-0x67,0x00,0x00,0x0C,0x31,0x81,0x09,0xB0,0x00,0x00,0x19,0xAC,0x30,0x81,0x32,0x39,
-0xFF,0xFC,0x15,0x66,0xC2,0x70,0x09,0xB0,0x00,0x00,0x19,0x02,0x67,0x00,0x00,0x0C,
-0x32,0x10,0x02,0x41,0xFF,0xF7,0x60,0x00,0x00,0x08,0x32,0x10,0x00,0x41,0x00,0x08,
-0xC2,0x42,0x22,0x70,0x09,0xB0,0x00,0x00,0x10,0x04,0xB2,0xA9,0x00,0x04,0x67,0x00,
-0x00,0x12,0x23,0x41,0x00,0x04,0x23,0xF0,0x09,0xB0,0x00,0x00,0x18,0xB2,0xFF,0xF9,
-0x00,0xE4,0x54,0x88,0x58,0x80,0x0C,0x80,0x00,0x00,0x00,0x10,0x66,0x00,0xFF,0x34,
-0x22,0x5F,0x20,0x5F,0x24,0x1F,0x22,0x1F,0x20,0x1F,0x4E,0x75,0x61,0x00,0xFF,0x12,
-0x4E,0x73,0xFF,0xFC,0x16,0x00,0xFF,0xFC,0x16,0x20,0xFF,0xFC,0x16,0x40,0xFF,0xFC,
-0x16,0x60,0xFF,0xFC,0x0C,0x00,0xFF,0xFC,0x0D,0x00,0xFF,0xFC,0x0E,0x00,0xFF,0xFC,
-0x0F,0x00,0xFF,0xFC,0x00,0x00,0xFF,0xFC,0x01,0x40,0xFF,0xFC,0x02,0x80,0xFF,0xFC,
-0x03,0xC0,0xFF,0xFC,0x00,0x50,0xFF,0xFC,0x01,0x90,0xFF,0xFC,0x02,0xD0,0xFF,0xFC,
-0x04,0x10,0x00,0x00,0x40,0x00,0x00,0x01,0x2F,0x60,0x00,0x02,0x1E,0xC0,0x00,0x03,
-0x0E,0x20,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x04,0x00,0x00,
-0x00,0x08,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x80,0x00,0x00,
-0x01,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x11,0x00,0x00,0x00,0x12,0x00,0x00,
-0x00,0x13,0x00,0x00,0x00,0x2C,0x00,0x00,0x3E,0x00,0x00,0x2C,0x00,0x00,0x3E,0x00,
-0x00,0x00,0x00,0x00,0x00,0x2D,0x00,0x00,0x3F,0x00,0x00,0x2D,0x00,0x00,0x3F,0x00,
-0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,
-0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x80,0x00,0x00,0x02,0x00,0x00,0x00,0x08,0x00,
-0x77,0x61,0x6E,0x58,0x4C,0x20,0x66,0x69,0x72,0x6D,0x77,0x61,0x72,0x65,0x0A,0x43,
-0x6F,0x70,0x79,0x72,0x69,0x67,0x68,0x74,0x20,0x28,0x43,0x29,0x20,0x32,0x30,0x30,
-0x33,0x20,0x4B,0x72,0x7A,0x79,0x73,0x7A,0x74,0x6F,0x66,0x20,0x48,0x61,0x6C,0x61,
-0x73,0x61,0x20,0x3C,0x6B,0x68,0x63,0x40,0x70,0x6D,0x2E,0x77,0x61,0x77,0x2E,0x70,
-0x6C,0x3E,0x0A,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
-};
+++ /dev/null
-#
-# Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
-# Licensed under the GPL
-#
-
-# struct stat64 changed the inode field name between 2.2 and 2.4 from st_ino
-# to __st_ino. It stayed in the same place, so as long as the correct name
-# is used, hostfs compiled on 2.2 should work on 2.4 and vice versa.
-
-STAT64_INO_FIELD := $(shell grep -q __st_ino /usr/include/bits/stat.h && \
- echo __)st_ino
-
-hostfs-objs := hostfs_kern.o hostfs_user.o
-
-obj-y =
-obj-$(CONFIG_HOSTFS) += hostfs.o
-
-SINGLE_OBJS = $(foreach f,$(patsubst %.o,%,$(obj-y) $(obj-m)),$($(f)-objs))
-
-USER_OBJS := $(filter %_user.o,$(obj-y) $(obj-m) $(SINGLE_OBJS))
-USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file))
-
-USER_CFLAGS += -DSTAT64_INO_FIELD=$(STAT64_INO_FIELD)
-
-$(USER_OBJS) : %.o: %.c
- $(CC) $(CFLAGS_$(notdir $@)) $(USER_CFLAGS) -c -o $@ $<
+++ /dev/null
-#ifndef __UM_FS_HOSTFS
-#define __UM_FS_HOSTFS
-
-#include "os.h"
-
-/* These are exactly the same definitions as in fs.h, but the names are
- * changed so that this file can be included in both kernel and user files.
- */
-
-#define HOSTFS_ATTR_MODE 1
-#define HOSTFS_ATTR_UID 2
-#define HOSTFS_ATTR_GID 4
-#define HOSTFS_ATTR_SIZE 8
-#define HOSTFS_ATTR_ATIME 16
-#define HOSTFS_ATTR_MTIME 32
-#define HOSTFS_ATTR_CTIME 64
-#define HOSTFS_ATTR_ATIME_SET 128
-#define HOSTFS_ATTR_MTIME_SET 256
-#define HOSTFS_ATTR_FORCE 512 /* Not a change, but a change it */
-#define HOSTFS_ATTR_ATTR_FLAG 1024
-
-struct hostfs_iattr {
- unsigned int ia_valid;
- mode_t ia_mode;
- uid_t ia_uid;
- gid_t ia_gid;
- loff_t ia_size;
- struct timespec ia_atime;
- struct timespec ia_mtime;
- struct timespec ia_ctime;
- unsigned int ia_attr_flags;
-};
-
-extern int stat_file(const char *path, unsigned long long *inode_out,
- int *mode_out, int *nlink_out, int *uid_out, int *gid_out,
- unsigned long long *size_out, struct timespec *atime_out,
- struct timespec *mtime_out, struct timespec *ctime_out,
- int *blksize_out, unsigned long long *blocks_out);
-extern int access_file(char *path, int r, int w, int x);
-extern int open_file(char *path, int r, int w, int append);
-extern int file_type(const char *path, int *rdev);
-extern void *open_dir(char *path, int *err_out);
-extern char *read_dir(void *stream, unsigned long long *pos,
- unsigned long long *ino_out, int *len_out);
-extern void close_file(void *stream);
-extern void close_dir(void *stream);
-extern int read_file(int fd, unsigned long long *offset, char *buf, int len);
-extern int write_file(int fd, unsigned long long *offset, const char *buf,
- int len);
-extern int lseek_file(int fd, long long offset, int whence);
-extern int file_create(char *name, int ur, int uw, int ux, int gr,
- int gw, int gx, int or, int ow, int ox);
-extern int set_attr(const char *file, struct hostfs_iattr *attrs);
-extern int make_symlink(const char *from, const char *to);
-extern int unlink_file(const char *file);
-extern int do_mkdir(const char *file, int mode);
-extern int do_rmdir(const char *file);
-extern int do_mknod(const char *file, int mode, int dev);
-extern int link_file(const char *from, const char *to);
-extern int do_readlink(char *file, char *buf, int size);
-extern int rename_file(char *from, char *to);
-extern int do_statfs(char *root, long *bsize_out, long long *blocks_out,
- long long *bfree_out, long long *bavail_out,
- long long *files_out, long long *ffree_out,
- void *fsid_out, int fsid_size, long *namelen_out,
- long *spare_out);
-
-#endif
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only. This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
+++ /dev/null
-/*
- * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- *
- * Ported the filesystem routines to 2.5.
- * 2003-02-10 Petr Baudis <pasky@ucw.cz>
- */
-
-#include <linux/stddef.h>
-#include <linux/fs.h>
-#include <linux/version.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/slab.h>
-#include <linux/pagemap.h>
-#include <linux/blkdev.h>
-#include <linux/list.h>
-#include <linux/buffer_head.h>
-#include <linux/root_dev.h>
-#include <linux/statfs.h>
-#include <asm/uaccess.h>
-#include "hostfs.h"
-#include "kern_util.h"
-#include "kern.h"
-#include "user_util.h"
-#include "2_5compat.h"
-#include "init.h"
-
-struct hostfs_inode_info {
- char *host_filename;
- int fd;
- int mode;
- struct inode vfs_inode;
-};
-
-static inline struct hostfs_inode_info *HOSTFS_I(struct inode *inode)
-{
- return(list_entry(inode, struct hostfs_inode_info, vfs_inode));
-}
-
-#define FILE_HOSTFS_I(file) HOSTFS_I((file)->f_dentry->d_inode)
-
-int hostfs_d_delete(struct dentry *dentry)
-{
- return(1);
-}
-
-struct dentry_operations hostfs_dentry_ops = {
- .d_delete = hostfs_d_delete,
-};
-
-/* Changed in hostfs_args before the kernel starts running */
-static char *root_ino = "/";
-static int append = 0;
-
-#define HOSTFS_SUPER_MAGIC 0x00c0ffee
-
-static struct inode_operations hostfs_iops;
-static struct inode_operations hostfs_dir_iops;
-static struct address_space_operations hostfs_link_aops;
-
-static int __init hostfs_args(char *options, int *add)
-{
- char *ptr;
-
- ptr = strchr(options, ',');
- if(ptr != NULL)
- *ptr++ = '\0';
- if(*options != '\0')
- root_ino = options;
-
- options = ptr;
- while(options){
- ptr = strchr(options, ',');
- if(ptr != NULL)
- *ptr++ = '\0';
- if(*options != '\0'){
- if(!strcmp(options, "append"))
- append = 1;
- else printf("hostfs_args - unsupported option - %s\n",
- options);
- }
- options = ptr;
- }
- return(0);
-}
-
-__uml_setup("hostfs=", hostfs_args,
-"hostfs=<root dir>,<flags>,...\n"
-" This is used to set hostfs parameters. The root directory argument\n"
-" is used to confine all hostfs mounts to within the specified directory\n"
-" tree on the host. If this isn't specified, then a user inside UML can\n"
-" mount anything on the host that's accessible to the user that's running\n"
-" it.\n"
-" The only flag currently supported is 'append', which specifies that all\n"
-" files opened by hostfs will be opened in append mode.\n\n"
-);
-
-static char *dentry_name(struct dentry *dentry, int extra)
-{
- struct dentry *parent;
- char *root, *name;
- int len;
-
- len = 0;
- parent = dentry;
- while(parent->d_parent != parent){
- len += parent->d_name.len + 1;
- parent = parent->d_parent;
- }
-
- root = HOSTFS_I(parent->d_inode)->host_filename;
- len += strlen(root);
- name = kmalloc(len + extra + 1, GFP_KERNEL);
- if(name == NULL) return(NULL);
-
- name[len] = '\0';
- parent = dentry;
- while(parent->d_parent != parent){
- len -= parent->d_name.len + 1;
- name[len] = '/';
- strncpy(&name[len + 1], parent->d_name.name,
- parent->d_name.len);
- parent = parent->d_parent;
- }
- strncpy(name, root, strlen(root));
- return(name);
-}
-
-static char *inode_name(struct inode *ino, int extra)
-{
- struct dentry *dentry;
-
- dentry = list_entry(ino->i_dentry.next, struct dentry, d_alias);
- return(dentry_name(dentry, extra));
-}
-
-static int read_name(struct inode *ino, char *name)
-{
- /* The non-int inode fields are copied into ints by stat_file and
- * then copied into the inode because passing the actual pointers
- * in and having them treated as int * breaks on big-endian machines
- */
- int err;
- int i_mode, i_nlink, i_blksize;
- unsigned long long i_size;
- unsigned long long i_ino;
- unsigned long long i_blocks;
-
- err = stat_file(name, &i_ino, &i_mode, &i_nlink, &ino->i_uid,
- &ino->i_gid, &i_size, &ino->i_atime, &ino->i_mtime,
- &ino->i_ctime, &i_blksize, &i_blocks);
- if(err)
- return(err);
-
- ino->i_ino = i_ino;
- ino->i_mode = i_mode;
- ino->i_nlink = i_nlink;
- ino->i_size = i_size;
- ino->i_blksize = i_blksize;
- ino->i_blocks = i_blocks;
- if((ino->i_sb->s_dev == ROOT_DEV) && (ino->i_uid == getuid()))
- ino->i_uid = 0;
- return(0);
-}
-
-static char *follow_link(char *link)
-{
- int len, n;
- char *name, *resolved, *end;
-
- len = 64;
- while(1){
- n = -ENOMEM;
- name = kmalloc(len, GFP_KERNEL);
- if(name == NULL)
- goto out;
-
- n = do_readlink(link, name, len);
- if(n < len)
- break;
- len *= 2;
- kfree(name);
- }
- if(n < 0)
- goto out_free;
-
- if(*name == '/')
- return(name);
-
- end = strrchr(link, '/');
- if(end == NULL)
- return(name);
-
- *(end + 1) = '\0';
- len = strlen(link) + strlen(name) + 1;
-
- resolved = kmalloc(len, GFP_KERNEL);
- if(resolved == NULL){
- n = -ENOMEM;
- goto out_free;
- }
-
- sprintf(resolved, "%s%s", link, name);
- kfree(name);
- kfree(link);
- return(resolved);
-
- out_free:
- kfree(name);
- out:
- return(ERR_PTR(n));
-}
-
-static int read_inode(struct inode *ino)
-{
- char *name;
- int err = 0;
-
- /* Unfortunately, we are called from iget() when we don't have a dentry
- * allocated yet.
- */
- if(list_empty(&ino->i_dentry))
- goto out;
-
- err = -ENOMEM;
- name = inode_name(ino, 0);
- if(name == NULL)
- goto out;
-
- if(file_type(name, NULL) == OS_TYPE_SYMLINK){
- name = follow_link(name);
- if(IS_ERR(name)){
- err = PTR_ERR(name);
- goto out;
- }
- }
-
- err = read_name(ino, name);
- kfree(name);
- out:
- return(err);
-}
-
-int hostfs_statfs(struct super_block *sb, struct kstatfs *sf)
-{
- /* do_statfs uses struct statfs64 internally, but the linux kernel
- * struct statfs still has 32-bit versions for most of these fields,
- * so we convert them here
- */
- int err;
- long long f_blocks;
- long long f_bfree;
- long long f_bavail;
- long long f_files;
- long long f_ffree;
-
- err = do_statfs(HOSTFS_I(sb->s_root->d_inode)->host_filename,
- &sf->f_bsize, &f_blocks, &f_bfree, &f_bavail, &f_files,
- &f_ffree, &sf->f_fsid, sizeof(sf->f_fsid),
- &sf->f_namelen, sf->f_spare);
- if(err) return(err);
- sf->f_blocks = f_blocks;
- sf->f_bfree = f_bfree;
- sf->f_bavail = f_bavail;
- sf->f_files = f_files;
- sf->f_ffree = f_ffree;
- sf->f_type = HOSTFS_SUPER_MAGIC;
- return(0);
-}
-
-static struct inode *hostfs_alloc_inode(struct super_block *sb)
-{
- struct hostfs_inode_info *hi;
-
- hi = kmalloc(sizeof(*hi), GFP_KERNEL);
- if(hi == NULL)
- return(NULL);
-
- *hi = ((struct hostfs_inode_info) { .host_filename = NULL,
- .fd = -1,
- .mode = 0 });
- inode_init_once(&hi->vfs_inode);
- return(&hi->vfs_inode);
-}
-
-static void hostfs_destroy_inode(struct inode *inode)
-{
- if(HOSTFS_I(inode)->host_filename)
- kfree(HOSTFS_I(inode)->host_filename);
-
- if(HOSTFS_I(inode)->fd != -1)
- close_file(&HOSTFS_I(inode)->fd);
-
- kfree(HOSTFS_I(inode));
-}
-
-static void hostfs_read_inode(struct inode *inode)
-{
- read_inode(inode);
-}
-
-static struct super_operations hostfs_sbops = {
- .alloc_inode = hostfs_alloc_inode,
- .destroy_inode = hostfs_destroy_inode,
- .read_inode = hostfs_read_inode,
- .statfs = hostfs_statfs,
-};
-
-int hostfs_readdir(struct file *file, void *ent, filldir_t filldir)
-{
- void *dir;
- char *name;
- unsigned long long next, ino;
- int error, len;
-
- name = dentry_name(file->f_dentry, 0);
- if(name == NULL) return(-ENOMEM);
- dir = open_dir(name, &error);
- kfree(name);
- if(dir == NULL) return(-error);
- next = file->f_pos;
- while((name = read_dir(dir, &next, &ino, &len)) != NULL){
- error = (*filldir)(ent, name, len, file->f_pos,
- ino, DT_UNKNOWN);
- if(error) break;
- file->f_pos = next;
- }
- close_dir(dir);
- return(0);
-}
-
-int hostfs_file_open(struct inode *ino, struct file *file)
-{
- char *name;
- int mode = 0, r = 0, w = 0, fd;
-
- mode = file->f_mode & (FMODE_READ | FMODE_WRITE);
- if((mode & HOSTFS_I(ino)->mode) == mode)
- return(0);
-
- /* The file may already have been opened, but with the wrong access,
- * so this resets things and reopens the file with the new access.
- */
- if(HOSTFS_I(ino)->fd != -1){
- close_file(&HOSTFS_I(ino)->fd);
- HOSTFS_I(ino)->fd = -1;
- }
-
- HOSTFS_I(ino)->mode |= mode;
- if(HOSTFS_I(ino)->mode & FMODE_READ)
- r = 1;
- if(HOSTFS_I(ino)->mode & FMODE_WRITE)
- w = 1;
- if(w)
- r = 1;
-
- name = dentry_name(file->f_dentry, 0);
- if(name == NULL)
- return(-ENOMEM);
-
- fd = open_file(name, r, w, append);
- kfree(name);
- if(fd < 0) return(fd);
- FILE_HOSTFS_I(file)->fd = fd;
-
- return(0);
-}
-
-int hostfs_fsync(struct file *file, struct dentry *dentry, int datasync)
-{
- return(0);
-}
-
-static struct file_operations hostfs_file_fops = {
- .llseek = generic_file_llseek,
- .read = generic_file_read,
- .write = generic_file_write,
- .mmap = generic_file_mmap,
- .open = hostfs_file_open,
- .release = NULL,
- .fsync = hostfs_fsync,
-};
-
-static struct file_operations hostfs_dir_fops = {
- .readdir = hostfs_readdir,
- .read = generic_read_dir,
-};
-
-int hostfs_writepage(struct page *page, struct writeback_control *wbc)
-{
- struct address_space *mapping = page->mapping;
- struct inode *inode = mapping->host;
- char *buffer;
- unsigned long long base;
- int count = PAGE_CACHE_SIZE;
- int end_index = inode->i_size >> PAGE_CACHE_SHIFT;
- int err;
-
- if (page->index >= end_index)
- count = inode->i_size & (PAGE_CACHE_SIZE-1);
-
- buffer = kmap(page);
- base = ((unsigned long long) page->index) << PAGE_CACHE_SHIFT;
-
- err = write_file(HOSTFS_I(inode)->fd, &base, buffer, count);
- if(err != count){
- ClearPageUptodate(page);
- goto out;
- }
-
- if (base > inode->i_size)
- inode->i_size = base;
-
- if (PageError(page))
- ClearPageError(page);
- err = 0;
-
- out:
- kunmap(page);
-
- unlock_page(page);
- return err;
-}
-
-int hostfs_readpage(struct file *file, struct page *page)
-{
- char *buffer;
- long long start;
- int err = 0;
-
- start = (long long) page->index << PAGE_CACHE_SHIFT;
- buffer = kmap(page);
- err = read_file(FILE_HOSTFS_I(file)->fd, &start, buffer,
- PAGE_CACHE_SIZE);
- if(err < 0) goto out;
-
- memset(&buffer[err], 0, PAGE_CACHE_SIZE - err);
-
- flush_dcache_page(page);
- SetPageUptodate(page);
- if (PageError(page)) ClearPageError(page);
- err = 0;
- out:
- kunmap(page);
- unlock_page(page);
- return(err);
-}
-
-int hostfs_prepare_write(struct file *file, struct page *page,
- unsigned int from, unsigned int to)
-{
- char *buffer;
- long long start, tmp;
- int err;
-
- start = (long long) page->index << PAGE_CACHE_SHIFT;
- buffer = kmap(page);
- if(from != 0){
- tmp = start;
- err = read_file(FILE_HOSTFS_I(file)->fd, &tmp, buffer,
- from);
- if(err < 0) goto out;
- }
- if(to != PAGE_CACHE_SIZE){
- start += to;
- err = read_file(FILE_HOSTFS_I(file)->fd, &start, buffer + to,
- PAGE_CACHE_SIZE - to);
- if(err < 0) goto out;
- }
- err = 0;
- out:
- kunmap(page);
- return(err);
-}
-
-int hostfs_commit_write(struct file *file, struct page *page, unsigned from,
- unsigned to)
-{
- struct address_space *mapping = page->mapping;
- struct inode *inode = mapping->host;
- char *buffer;
- long long start;
- int err = 0;
-
- start = (long long) (page->index << PAGE_CACHE_SHIFT) + from;
- buffer = kmap(page);
- err = write_file(FILE_HOSTFS_I(file)->fd, &start, buffer + from,
- to - from);
- if(err > 0) err = 0;
- if(!err && (start > inode->i_size))
- inode->i_size = start;
-
- kunmap(page);
- return(err);
-}
-
-static struct address_space_operations hostfs_aops = {
- .writepage = hostfs_writepage,
- .readpage = hostfs_readpage,
-/* .set_page_dirty = __set_page_dirty_nobuffers, */
- .prepare_write = hostfs_prepare_write,
- .commit_write = hostfs_commit_write
-};
-
-static int init_inode(struct inode *inode, struct dentry *dentry)
-{
- char *name;
- int type, err = -ENOMEM, rdev;
-
- if(dentry){
- name = dentry_name(dentry, 0);
- if(name == NULL)
- goto out;
- type = file_type(name, &rdev);
- kfree(name);
- }
- else type = OS_TYPE_DIR;
-
- err = 0;
- if(type == OS_TYPE_SYMLINK)
- inode->i_op = &page_symlink_inode_operations;
- else if(type == OS_TYPE_DIR)
- inode->i_op = &hostfs_dir_iops;
- else inode->i_op = &hostfs_iops;
-
- if(type == OS_TYPE_DIR) inode->i_fop = &hostfs_dir_fops;
- else inode->i_fop = &hostfs_file_fops;
-
- if(type == OS_TYPE_SYMLINK)
- inode->i_mapping->a_ops = &hostfs_link_aops;
- else inode->i_mapping->a_ops = &hostfs_aops;
-
- switch (type) {
- case OS_TYPE_CHARDEV:
- init_special_inode(inode, S_IFCHR, rdev);
- break;
- case OS_TYPE_BLOCKDEV:
- init_special_inode(inode, S_IFBLK, rdev);
- break;
- case OS_TYPE_FIFO:
- init_special_inode(inode, S_IFIFO, 0);
- break;
- case OS_TYPE_SOCK:
- init_special_inode(inode, S_IFSOCK, 0);
- break;
- }
- out:
- return(err);
-}
-
-int hostfs_create(struct inode *dir, struct dentry *dentry, int mode,
- struct nameidata *nd)
-{
- struct inode *inode;
- char *name;
- int error, fd;
-
- error = -ENOMEM;
- inode = iget(dir->i_sb, 0);
- if(inode == NULL) goto out;
-
- error = init_inode(inode, dentry);
- if(error)
- goto out_put;
-
- error = -ENOMEM;
- name = dentry_name(dentry, 0);
- if(name == NULL)
- goto out_put;
-
- fd = file_create(name,
- mode & S_IRUSR, mode & S_IWUSR, mode & S_IXUSR,
- mode & S_IRGRP, mode & S_IWGRP, mode & S_IXGRP,
- mode & S_IROTH, mode & S_IWOTH, mode & S_IXOTH);
- if(fd < 0)
- error = fd;
- else error = read_name(inode, name);
-
- kfree(name);
- if(error)
- goto out_put;
-
- HOSTFS_I(inode)->fd = fd;
- HOSTFS_I(inode)->mode = FMODE_READ | FMODE_WRITE;
- d_instantiate(dentry, inode);
- return(0);
-
- out_put:
- iput(inode);
- out:
- return(error);
-}
-
-struct dentry *hostfs_lookup(struct inode *ino, struct dentry *dentry,
- struct nameidata *nd)
-{
- struct inode *inode;
- char *name;
- int err;
-
- err = -ENOMEM;
- inode = iget(ino->i_sb, 0);
- if(inode == NULL)
- goto out;
-
- err = init_inode(inode, dentry);
- if(err)
- goto out_put;
-
- err = -ENOMEM;
- name = dentry_name(dentry, 0);
- if(name == NULL)
- goto out_put;
-
- err = read_name(inode, name);
- kfree(name);
- if(err == -ENOENT){
- iput(inode);
- inode = NULL;
- }
- else if(err)
- goto out_put;
-
- d_add(dentry, inode);
- dentry->d_op = &hostfs_dentry_ops;
- return(NULL);
-
- out_put:
- iput(inode);
- out:
- return(ERR_PTR(err));
-}
-
-static char *inode_dentry_name(struct inode *ino, struct dentry *dentry)
-{
- char *file;
- int len;
-
- file = inode_name(ino, dentry->d_name.len + 1);
- if(file == NULL) return(NULL);
- strcat(file, "/");
- len = strlen(file);
- strncat(file, dentry->d_name.name, dentry->d_name.len);
- file[len + dentry->d_name.len] = '\0';
- return(file);
-}
-
-int hostfs_link(struct dentry *to, struct inode *ino, struct dentry *from)
-{
- char *from_name, *to_name;
- int err;
-
- if((from_name = inode_dentry_name(ino, from)) == NULL)
- return(-ENOMEM);
- to_name = dentry_name(to, 0);
- if(to_name == NULL){
- kfree(from_name);
- return(-ENOMEM);
- }
- err = link_file(to_name, from_name);
- kfree(from_name);
- kfree(to_name);
- return(err);
-}
-
-int hostfs_unlink(struct inode *ino, struct dentry *dentry)
-{
- char *file;
- int err;
-
- if((file = inode_dentry_name(ino, dentry)) == NULL) return(-ENOMEM);
- if(append)
- return(-EPERM);
-
- err = unlink_file(file);
- kfree(file);
- return(err);
-}
-
-int hostfs_symlink(struct inode *ino, struct dentry *dentry, const char *to)
-{
- char *file;
- int err;
-
- if((file = inode_dentry_name(ino, dentry)) == NULL) return(-ENOMEM);
- err = make_symlink(file, to);
- kfree(file);
- return(err);
-}
-
-int hostfs_mkdir(struct inode *ino, struct dentry *dentry, int mode)
-{
- char *file;
- int err;
-
- if((file = inode_dentry_name(ino, dentry)) == NULL) return(-ENOMEM);
- err = do_mkdir(file, mode);
- kfree(file);
- return(err);
-}
-
-int hostfs_rmdir(struct inode *ino, struct dentry *dentry)
-{
- char *file;
- int err;
-
- if((file = inode_dentry_name(ino, dentry)) == NULL) return(-ENOMEM);
- err = do_rmdir(file);
- kfree(file);
- return(err);
-}
-
-int hostfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
-{
- struct inode *inode;
- char *name;
- int err = -ENOMEM;
-
- inode = iget(dir->i_sb, 0);
- if(inode == NULL)
- goto out;
-
- err = init_inode(inode, dentry);
- if(err)
- goto out_put;
-
- err = -ENOMEM;
- name = dentry_name(dentry, 0);
- if(name == NULL)
- goto out_put;
-
- init_special_inode(inode, mode, dev);
- err = do_mknod(name, mode, dev);
- if(err)
- goto out_free;
-
- err = read_name(inode, name);
- kfree(name);
- if(err)
- goto out_put;
-
- d_instantiate(dentry, inode);
- return(0);
-
- out_free:
- kfree(name);
- out_put:
- iput(inode);
- out:
- return(err);
-}
-
-int hostfs_rename(struct inode *from_ino, struct dentry *from,
- struct inode *to_ino, struct dentry *to)
-{
- char *from_name, *to_name;
- int err;
-
- if((from_name = inode_dentry_name(from_ino, from)) == NULL)
- return(-ENOMEM);
- if((to_name = inode_dentry_name(to_ino, to)) == NULL){
- kfree(from_name);
- return(-ENOMEM);
- }
- err = rename_file(from_name, to_name);
- kfree(from_name);
- kfree(to_name);
- return(err);
-}
-
-void hostfs_truncate(struct inode *ino)
-{
- not_implemented();
-}
-
-int hostfs_permission(struct inode *ino, int desired, struct nameidata *nd)
-{
- char *name;
- int r = 0, w = 0, x = 0, err;
-
- if(desired & MAY_READ) r = 1;
- if(desired & MAY_WRITE) w = 1;
- if(desired & MAY_EXEC) x = 1;
- name = inode_name(ino, 0);
- if(name == NULL) return(-ENOMEM);
- err = access_file(name, r, w, x);
- kfree(name);
- if(!err) err = vfs_permission(ino, desired);
- return(err);
-}
-
-int hostfs_setattr(struct dentry *dentry, struct iattr *attr)
-{
- struct hostfs_iattr attrs;
- char *name;
- int err;
-
- if(append)
- attr->ia_valid &= ~ATTR_SIZE;
-
- attrs.ia_valid = 0;
- if(attr->ia_valid & ATTR_MODE){
- attrs.ia_valid |= HOSTFS_ATTR_MODE;
- attrs.ia_mode = attr->ia_mode;
- }
- if(attr->ia_valid & ATTR_UID){
- if((dentry->d_inode->i_sb->s_dev == ROOT_DEV) &&
- (attr->ia_uid == 0))
- attr->ia_uid = getuid();
- attrs.ia_valid |= HOSTFS_ATTR_UID;
- attrs.ia_uid = attr->ia_uid;
- }
- if(attr->ia_valid & ATTR_GID){
- if((dentry->d_inode->i_sb->s_dev == ROOT_DEV) &&
- (attr->ia_gid == 0))
- attr->ia_gid = getuid();
- attrs.ia_valid |= HOSTFS_ATTR_GID;
- attrs.ia_gid = attr->ia_gid;
- }
- if(attr->ia_valid & ATTR_SIZE){
- attrs.ia_valid |= HOSTFS_ATTR_SIZE;
- attrs.ia_size = attr->ia_size;
- }
- if(attr->ia_valid & ATTR_ATIME){
- attrs.ia_valid |= HOSTFS_ATTR_ATIME;
- attrs.ia_atime = attr->ia_atime;
- }
- if(attr->ia_valid & ATTR_MTIME){
- attrs.ia_valid |= HOSTFS_ATTR_MTIME;
- attrs.ia_mtime = attr->ia_mtime;
- }
- if(attr->ia_valid & ATTR_CTIME){
- attrs.ia_valid |= HOSTFS_ATTR_CTIME;
- attrs.ia_ctime = attr->ia_ctime;
- }
- if(attr->ia_valid & ATTR_ATIME_SET){
- attrs.ia_valid |= HOSTFS_ATTR_ATIME_SET;
- }
- if(attr->ia_valid & ATTR_MTIME_SET){
- attrs.ia_valid |= HOSTFS_ATTR_MTIME_SET;
- }
- name = dentry_name(dentry, 0);
- if(name == NULL) return(-ENOMEM);
- err = set_attr(name, &attrs);
- kfree(name);
- if(err)
- return(err);
-
- return(inode_setattr(dentry->d_inode, attr));
-}
-
-int hostfs_getattr(struct vfsmount *mnt, struct dentry *dentry,
- struct kstat *stat)
-{
- generic_fillattr(dentry->d_inode, stat);
- return(0);
-}
-
-static struct inode_operations hostfs_iops = {
- .create = hostfs_create,
- .link = hostfs_link,
- .unlink = hostfs_unlink,
- .symlink = hostfs_symlink,
- .mkdir = hostfs_mkdir,
- .rmdir = hostfs_rmdir,
- .mknod = hostfs_mknod,
- .rename = hostfs_rename,
- .truncate = hostfs_truncate,
- .permission = hostfs_permission,
- .setattr = hostfs_setattr,
- .getattr = hostfs_getattr,
-};
-
-static struct inode_operations hostfs_dir_iops = {
- .create = hostfs_create,
- .lookup = hostfs_lookup,
- .link = hostfs_link,
- .unlink = hostfs_unlink,
- .symlink = hostfs_symlink,
- .mkdir = hostfs_mkdir,
- .rmdir = hostfs_rmdir,
- .mknod = hostfs_mknod,
- .rename = hostfs_rename,
- .truncate = hostfs_truncate,
- .permission = hostfs_permission,
- .setattr = hostfs_setattr,
- .getattr = hostfs_getattr,
-};
-
-int hostfs_link_readpage(struct file *file, struct page *page)
-{
- char *buffer, *name;
- long long start;
- int err;
-
- start = page->index << PAGE_CACHE_SHIFT;
- buffer = kmap(page);
- name = inode_name(page->mapping->host, 0);
- if(name == NULL) return(-ENOMEM);
- err = do_readlink(name, buffer, PAGE_CACHE_SIZE);
- kfree(name);
- if(err == PAGE_CACHE_SIZE)
- err = -E2BIG;
- else if(err > 0){
- flush_dcache_page(page);
- SetPageUptodate(page);
- if (PageError(page)) ClearPageError(page);
- err = 0;
- }
- kunmap(page);
- unlock_page(page);
- return(err);
-}
-
-static struct address_space_operations hostfs_link_aops = {
- .readpage = hostfs_link_readpage,
-};
-
-static int hostfs_fill_sb_common(struct super_block *sb, void *d, int silent)
-{
- struct inode *root_inode;
- char *name, *data = d;
- int err;
-
- sb->s_blocksize = 1024;
- sb->s_blocksize_bits = 10;
- sb->s_magic = HOSTFS_SUPER_MAGIC;
- sb->s_op = &hostfs_sbops;
-
- if((data == NULL) || (*data == '\0'))
- data = root_ino;
-
- err = -ENOMEM;
- name = kmalloc(strlen(data) + 1, GFP_KERNEL);
- if(name == NULL)
- goto out;
-
- strcpy(name, data);
-
- root_inode = iget(sb, 0);
- if(root_inode == NULL)
- goto out_free;
-
- err = init_inode(root_inode, NULL);
- if(err)
- goto out_put;
-
- HOSTFS_I(root_inode)->host_filename = name;
-
- err = -ENOMEM;
- sb->s_root = d_alloc_root(root_inode);
- if(sb->s_root == NULL)
- goto out_put;
-
- err = read_inode(root_inode);
- if(err)
- goto out_put;
-
- return(0);
-
- out_put:
- iput(root_inode);
- out_free:
- kfree(name);
- out:
- return(err);
-}
-
-static struct super_block *hostfs_read_sb(struct file_system_type *type,
- int flags, const char *dev_name,
- void *data)
-{
- return(get_sb_nodev(type, flags, data, hostfs_fill_sb_common));
-}
-
-static struct file_system_type hostfs_type = {
- .owner = THIS_MODULE,
- .name = "hostfs",
- .get_sb = hostfs_read_sb,
- .kill_sb = kill_anon_super,
- .fs_flags = 0,
-};
-
-static int __init init_hostfs(void)
-{
- return(register_filesystem(&hostfs_type));
-}
-
-static void __exit exit_hostfs(void)
-{
- unregister_filesystem(&hostfs_type);
-}
-
-module_init(init_hostfs)
-module_exit(exit_hostfs)
-MODULE_LICENSE("GPL");
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only. This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
+++ /dev/null
-/*
- * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#include <unistd.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <dirent.h>
-#include <errno.h>
-#include <utime.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/vfs.h>
-#include "hostfs.h"
-#include "kern_util.h"
-#include "user.h"
-
-int stat_file(const char *path, unsigned long long *inode_out, int *mode_out,
- int *nlink_out, int *uid_out, int *gid_out,
- unsigned long long *size_out, struct timespec *atime_out,
- struct timespec *mtime_out, struct timespec *ctime_out,
- int *blksize_out, unsigned long long *blocks_out)
-{
- struct stat64 buf;
-
- if(lstat64(path, &buf) < 0)
- return(-errno);
-
- /* See the Makefile for why STAT64_INO_FIELD is passed in
- * by the build
- */
- if(inode_out != NULL) *inode_out = buf.STAT64_INO_FIELD;
- if(mode_out != NULL) *mode_out = buf.st_mode;
- if(nlink_out != NULL) *nlink_out = buf.st_nlink;
- if(uid_out != NULL) *uid_out = buf.st_uid;
- if(gid_out != NULL) *gid_out = buf.st_gid;
- if(size_out != NULL) *size_out = buf.st_size;
- if(atime_out != NULL) {
- atime_out->tv_sec = buf.st_atime;
- atime_out->tv_nsec = 0;
- }
- if(mtime_out != NULL) {
- mtime_out->tv_sec = buf.st_mtime;
- mtime_out->tv_nsec = 0;
- }
- if(ctime_out != NULL) {
- ctime_out->tv_sec = buf.st_ctime;
- ctime_out->tv_nsec = 0;
- }
- if(blksize_out != NULL) *blksize_out = buf.st_blksize;
- if(blocks_out != NULL) *blocks_out = buf.st_blocks;
- return(0);
-}
-
-int file_type(const char *path, int *rdev)
-{
- struct stat64 buf;
-
- if(lstat64(path, &buf) < 0)
- return(-errno);
- if(rdev != NULL)
- *rdev = buf.st_rdev;
-
- if(S_ISDIR(buf.st_mode)) return(OS_TYPE_DIR);
- else if(S_ISLNK(buf.st_mode)) return(OS_TYPE_SYMLINK);
- else if(S_ISCHR(buf.st_mode)) return(OS_TYPE_CHARDEV);
- else if(S_ISBLK(buf.st_mode)) return(OS_TYPE_BLOCKDEV);
- else if(S_ISFIFO(buf.st_mode))return(OS_TYPE_FIFO);
- else if(S_ISSOCK(buf.st_mode))return(OS_TYPE_SOCK);
- else return(OS_TYPE_FILE);
-}
-
-int access_file(char *path, int r, int w, int x)
-{
- int mode = 0;
-
- if(r) mode = R_OK;
- if(w) mode |= W_OK;
- if(x) mode |= X_OK;
- if(access(path, mode) != 0) return(-errno);
- else return(0);
-}
-
-int open_file(char *path, int r, int w, int append)
-{
- int mode = 0, fd;
-
- if(r && !w)
- mode = O_RDONLY;
- else if(!r && w)
- mode = O_WRONLY;
- else if(r && w)
- mode = O_RDWR;
- else panic("Impossible mode in open_file");
-
- if(append)
- mode |= O_APPEND;
- fd = open64(path, mode);
- if(fd < 0) return(-errno);
- else return(fd);
-}
-
-void *open_dir(char *path, int *err_out)
-{
- DIR *dir;
-
- dir = opendir(path);
- *err_out = errno;
- if(dir == NULL) return(NULL);
- return(dir);
-}
-
-char *read_dir(void *stream, unsigned long long *pos,
- unsigned long long *ino_out, int *len_out)
-{
- DIR *dir = stream;
- struct dirent *ent;
-
- seekdir(dir, *pos);
- ent = readdir(dir);
- if(ent == NULL) return(NULL);
- *len_out = strlen(ent->d_name);
- *ino_out = ent->d_ino;
- *pos = telldir(dir);
- return(ent->d_name);
-}
-
-int read_file(int fd, unsigned long long *offset, char *buf, int len)
-{
- int n;
-
- n = pread64(fd, buf, len, *offset);
- if(n < 0) return(-errno);
- *offset += n;
- return(n);
-}
-
-int write_file(int fd, unsigned long long *offset, const char *buf, int len)
-{
- int n;
-
- n = pwrite64(fd, buf, len, *offset);
- if(n < 0) return(-errno);
- *offset += n;
- return(n);
-}
-
-int lseek_file(int fd, long long offset, int whence)
-{
- int ret;
-
- ret = lseek64(fd, offset, whence);
- if(ret < 0) return(-errno);
- return(0);
-}
-
-void close_file(void *stream)
-{
- close(*((int *) stream));
-}
-
-void close_dir(void *stream)
-{
- closedir(stream);
-}
-
-int file_create(char *name, int ur, int uw, int ux, int gr,
- int gw, int gx, int or, int ow, int ox)
-{
- int mode, fd;
-
- mode = 0;
- mode |= ur ? S_IRUSR : 0;
- mode |= uw ? S_IWUSR : 0;
- mode |= ux ? S_IXUSR : 0;
- mode |= gr ? S_IRGRP : 0;
- mode |= gw ? S_IWGRP : 0;
- mode |= gx ? S_IXGRP : 0;
- mode |= or ? S_IROTH : 0;
- mode |= ow ? S_IWOTH : 0;
- mode |= ox ? S_IXOTH : 0;
- fd = open64(name, O_CREAT | O_RDWR, mode);
- if(fd < 0)
- return(-errno);
- return(fd);
-}
-
-int set_attr(const char *file, struct hostfs_iattr *attrs)
-{
- struct utimbuf buf;
- int err, ma;
-
- if(attrs->ia_valid & HOSTFS_ATTR_MODE){
- if(chmod(file, attrs->ia_mode) != 0) return(-errno);
- }
- if(attrs->ia_valid & HOSTFS_ATTR_UID){
- if(chown(file, attrs->ia_uid, -1)) return(-errno);
- }
- if(attrs->ia_valid & HOSTFS_ATTR_GID){
- if(chown(file, -1, attrs->ia_gid)) return(-errno);
- }
- if(attrs->ia_valid & HOSTFS_ATTR_SIZE){
- if(truncate(file, attrs->ia_size)) return(-errno);
- }
- ma = HOSTFS_ATTR_ATIME_SET | HOSTFS_ATTR_MTIME_SET;
- if((attrs->ia_valid & ma) == ma){
- buf.actime = attrs->ia_atime.tv_sec;
- buf.modtime = attrs->ia_mtime.tv_sec;
- if(utime(file, &buf) != 0) return(-errno);
- }
- else {
- struct timespec ts;
-
- if(attrs->ia_valid & HOSTFS_ATTR_ATIME_SET){
- err = stat_file(file, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, &ts, NULL, NULL, NULL);
- if(err != 0)
- return(err);
- buf.actime = attrs->ia_atime.tv_sec;
- buf.modtime = ts.tv_sec;
- if(utime(file, &buf) != 0)
- return(-errno);
- }
- if(attrs->ia_valid & HOSTFS_ATTR_MTIME_SET){
- err = stat_file(file, NULL, NULL, NULL, NULL, NULL,
- NULL, &ts, NULL, NULL, NULL, NULL);
- if(err != 0)
- return(err);
- buf.actime = ts.tv_sec;
- buf.modtime = attrs->ia_mtime.tv_sec;
- if(utime(file, &buf) != 0)
- return(-errno);
- }
- }
- if(attrs->ia_valid & HOSTFS_ATTR_CTIME) ;
- if(attrs->ia_valid & (HOSTFS_ATTR_ATIME | HOSTFS_ATTR_MTIME)){
- err = stat_file(file, NULL, NULL, NULL, NULL, NULL, NULL,
- &attrs->ia_atime, &attrs->ia_mtime, NULL,
- NULL, NULL);
- if(err != 0) return(err);
- }
- return(0);
-}
-
-int make_symlink(const char *from, const char *to)
-{
- int err;
-
- err = symlink(to, from);
- if(err) return(-errno);
- return(0);
-}
-
-int unlink_file(const char *file)
-{
- int err;
-
- err = unlink(file);
- if(err) return(-errno);
- return(0);
-}
-
-int do_mkdir(const char *file, int mode)
-{
- int err;
-
- err = mkdir(file, mode);
- if(err) return(-errno);
- return(0);
-}
-
-int do_rmdir(const char *file)
-{
- int err;
-
- err = rmdir(file);
- if(err) return(-errno);
- return(0);
-}
-
-int do_mknod(const char *file, int mode, int dev)
-{
- int err;
-
- err = mknod(file, mode, dev);
- if(err) return(-errno);
- return(0);
-}
-
-int link_file(const char *to, const char *from)
-{
- int err;
-
- err = link(to, from);
- if(err) return(-errno);
- return(0);
-}
-
-int do_readlink(char *file, char *buf, int size)
-{
- int n;
-
- n = readlink(file, buf, size);
- if(n < 0)
- return(-errno);
- if(n < size)
- buf[n] = '\0';
- return(n);
-}
-
-int rename_file(char *from, char *to)
-{
- int err;
-
- err = rename(from, to);
- if(err < 0) return(-errno);
- return(0);
-}
-
-int do_statfs(char *root, long *bsize_out, long long *blocks_out,
- long long *bfree_out, long long *bavail_out,
- long long *files_out, long long *ffree_out,
- void *fsid_out, int fsid_size, long *namelen_out,
- long *spare_out)
-{
- struct statfs64 buf;
- int err;
-
- err = statfs64(root, &buf);
- if(err < 0) return(-errno);
- *bsize_out = buf.f_bsize;
- *blocks_out = buf.f_blocks;
- *bfree_out = buf.f_bfree;
- *bavail_out = buf.f_bavail;
- *files_out = buf.f_files;
- *ffree_out = buf.f_ffree;
- memcpy(fsid_out, &buf.f_fsid,
- sizeof(buf.f_fsid) > fsid_size ? fsid_size :
- sizeof(buf.f_fsid));
- *namelen_out = buf.f_namelen;
- spare_out[0] = buf.f_spare[0];
- spare_out[1] = buf.f_spare[1];
- spare_out[2] = buf.f_spare[2];
- spare_out[3] = buf.f_spare[3];
- spare_out[4] = buf.f_spare[4];
- spare_out[5] = buf.f_spare[5];
- return(0);
-}
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only. This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
+++ /dev/null
-#
-# Copyright (C) 2002, 2003 Jeff Dike (jdike@karaya.com)
-# Licensed under the GPL
-#
-
-hppfs-objs := hppfs_kern.o
-
-obj-y =
-obj-$(CONFIG_HPPFS) += hppfs.o
-
-clean:
-
-modules:
-
-fastdep:
-
-dep:
-
-archmrproper: clean
+++ /dev/null
-/*
- * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#include <linux/fs.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/slab.h>
-#include <linux/list.h>
-#include <linux/kernel.h>
-#include <linux/ctype.h>
-#include <linux/dcache.h>
-#include <linux/statfs.h>
-#include <asm/uaccess.h>
-#include <asm/fcntl.h>
-#include "os.h"
-
-static int init_inode(struct inode *inode, struct dentry *dentry);
-
-struct hppfs_data {
- struct list_head list;
- char contents[PAGE_SIZE - sizeof(struct list_head)];
-};
-
-struct hppfs_private {
- struct file proc_file;
- int host_fd;
- loff_t len;
- struct hppfs_data *contents;
-};
-
-struct hppfs_inode_info {
- struct dentry *proc_dentry;
- struct inode vfs_inode;
-};
-
-static inline struct hppfs_inode_info *HPPFS_I(struct inode *inode)
-{
- return(list_entry(inode, struct hppfs_inode_info, vfs_inode));
-}
-
-#define HPPFS_SUPER_MAGIC 0xb00000ee
-
-static struct super_operations hppfs_sbops;
-
-static int is_pid(struct dentry *dentry)
-{
- struct super_block *sb;
- int i;
-
- sb = dentry->d_sb;
- if((sb->s_op != &hppfs_sbops) || (dentry->d_parent != sb->s_root))
- return(0);
-
- for(i = 0; i < dentry->d_name.len; i++){
- if(!isdigit(dentry->d_name.name[i]))
- return(0);
- }
- return(1);
-}
-
-static char *dentry_name(struct dentry *dentry, int extra)
-{
- struct dentry *parent;
- char *root, *name;
- const char *seg_name;
- int len, seg_len;
-
- len = 0;
- parent = dentry;
- while(parent->d_parent != parent){
- if(is_pid(parent))
- len += strlen("pid") + 1;
- else len += parent->d_name.len + 1;
- parent = parent->d_parent;
- }
-
- root = "proc";
- len += strlen(root);
- name = kmalloc(len + extra + 1, GFP_KERNEL);
- if(name == NULL) return(NULL);
-
- name[len] = '\0';
- parent = dentry;
- while(parent->d_parent != parent){
- if(is_pid(parent)){
- seg_name = "pid";
- seg_len = strlen("pid");
- }
- else {
- seg_name = parent->d_name.name;
- seg_len = parent->d_name.len;
- }
-
- len -= seg_len + 1;
- name[len] = '/';
- strncpy(&name[len + 1], seg_name, seg_len);
- parent = parent->d_parent;
- }
- strncpy(name, root, strlen(root));
- return(name);
-}
-
-struct dentry_operations hppfs_dentry_ops = {
-};
-
-static int file_removed(struct dentry *dentry, const char *file)
-{
- char *host_file;
- int extra, fd;
-
- extra = 0;
- if(file != NULL) extra += strlen(file) + 1;
-
- host_file = dentry_name(dentry, extra + strlen("/remove"));
- if(host_file == NULL){
- printk("file_removed : allocation failed\n");
- return(-ENOMEM);
- }
-
- if(file != NULL){
- strcat(host_file, "/");
- strcat(host_file, file);
- }
- strcat(host_file, "/remove");
-
- fd = os_open_file(host_file, of_read(OPENFLAGS()), 0);
- kfree(host_file);
- if(fd > 0){
- os_close_file(fd);
- return(1);
- }
- return(0);
-}
-
-static void hppfs_read_inode(struct inode *ino)
-{
- struct inode *proc_ino;
-
- if(HPPFS_I(ino)->proc_dentry == NULL)
- return;
-
- proc_ino = HPPFS_I(ino)->proc_dentry->d_inode;
- ino->i_uid = proc_ino->i_uid;
- ino->i_gid = proc_ino->i_gid;
- ino->i_atime = proc_ino->i_atime;
- ino->i_mtime = proc_ino->i_mtime;
- ino->i_ctime = proc_ino->i_ctime;
- ino->i_ino = proc_ino->i_ino;
- ino->i_mode = proc_ino->i_mode;
- ino->i_nlink = proc_ino->i_nlink;
- ino->i_size = proc_ino->i_size;
- ino->i_blksize = proc_ino->i_blksize;
- ino->i_blocks = proc_ino->i_blocks;
-}
-
-static struct dentry *hppfs_lookup(struct inode *ino, struct dentry *dentry,
- struct nameidata *nd)
-{
- struct dentry *proc_dentry, *new, *parent;
- struct inode *inode;
- int err, deleted;
-
- deleted = file_removed(dentry, NULL);
- if(deleted < 0)
- return(ERR_PTR(deleted));
- else if(deleted)
- return(ERR_PTR(-ENOENT));
-
- err = -ENOMEM;
- parent = HPPFS_I(ino)->proc_dentry;
- down(&parent->d_inode->i_sem);
- proc_dentry = d_lookup(parent, &dentry->d_name);
- if(proc_dentry == NULL){
- proc_dentry = d_alloc(parent, &dentry->d_name);
- if(proc_dentry == NULL){
- up(&parent->d_inode->i_sem);
- goto out;
- }
- new = (*parent->d_inode->i_op->lookup)(parent->d_inode,
- proc_dentry, NULL);
- if(new){
- dput(proc_dentry);
- proc_dentry = new;
- }
- }
- up(&parent->d_inode->i_sem);
-
- if(IS_ERR(proc_dentry))
- return(proc_dentry);
-
- inode = iget(ino->i_sb, 0);
- if(inode == NULL)
- goto out_dput;
-
- err = init_inode(inode, proc_dentry);
- if(err)
- goto out_put;
-
- hppfs_read_inode(inode);
-
- d_add(dentry, inode);
- dentry->d_op = &hppfs_dentry_ops;
- return(NULL);
-
- out_put:
- iput(inode);
- out_dput:
- dput(proc_dentry);
- out:
- return(ERR_PTR(err));
-}
-
-static struct inode_operations hppfs_file_iops = {
-};
-
-static ssize_t read_proc(struct file *file, char *buf, ssize_t count,
- loff_t *ppos, int is_user)
-{
- ssize_t (*read)(struct file *, char *, size_t, loff_t *);
- ssize_t n;
-
- read = file->f_dentry->d_inode->i_fop->read;
-
- if(!is_user)
- set_fs(KERNEL_DS);
-
- n = (*read)(file, buf, count, &file->f_pos);
-
- if(!is_user)
- set_fs(USER_DS);
-
- if(ppos) *ppos = file->f_pos;
- return(n);
-}
-
-static ssize_t hppfs_read_file(int fd, char *buf, ssize_t count)
-{
- ssize_t n;
- int cur, err;
- char *new_buf;
-
- n = -ENOMEM;
- new_buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
- if(new_buf == NULL){
- printk("hppfs_read_file : kmalloc failed\n");
- goto out;
- }
- n = 0;
- while(count > 0){
- cur = min_t(ssize_t, count, PAGE_SIZE);
- err = os_read_file(fd, new_buf, cur);
- if(err < 0){
- printk("hppfs_read : read failed, errno = %d\n",
- count);
- n = err;
- goto out_free;
- }
- else if(err == 0)
- break;
-
- if(copy_to_user(buf, new_buf, err)){
- n = -EFAULT;
- goto out_free;
- }
- n += err;
- count -= err;
- }
- out_free:
- kfree(new_buf);
- out:
- return(n);
-}
-
-static ssize_t hppfs_read(struct file *file, char *buf, size_t count,
- loff_t *ppos)
-{
- struct hppfs_private *hppfs = file->private_data;
- struct hppfs_data *data;
- loff_t off;
- int err;
-
- if(hppfs->contents != NULL){
- if(*ppos >= hppfs->len) return(0);
-
- data = hppfs->contents;
- off = *ppos;
- while(off >= sizeof(data->contents)){
- data = list_entry(data->list.next, struct hppfs_data,
- list);
- off -= sizeof(data->contents);
- }
-
- if(off + count > hppfs->len)
- count = hppfs->len - off;
- copy_to_user(buf, &data->contents[off], count);
- *ppos += count;
- }
- else if(hppfs->host_fd != -1){
- err = os_seek_file(hppfs->host_fd, *ppos);
- if(err){
- printk("hppfs_read : seek failed, errno = %d\n", err);
- return(err);
- }
- count = hppfs_read_file(hppfs->host_fd, buf, count);
- if(count > 0)
- *ppos += count;
- }
- else count = read_proc(&hppfs->proc_file, buf, count, ppos, 1);
-
- return(count);
-}
-
-static ssize_t hppfs_write(struct file *file, const char *buf, size_t len,
- loff_t *ppos)
-{
- struct hppfs_private *data = file->private_data;
- struct file *proc_file = &data->proc_file;
- ssize_t (*write)(struct file *, const char *, size_t, loff_t *);
- int err;
-
- write = proc_file->f_dentry->d_inode->i_fop->write;
-
- proc_file->f_pos = file->f_pos;
- err = (*write)(proc_file, buf, len, &proc_file->f_pos);
- file->f_pos = proc_file->f_pos;
-
- return(err);
-}
-
-static int open_host_sock(char *host_file, int *filter_out)
-{
- char *end;
- int fd;
-
- end = &host_file[strlen(host_file)];
- strcpy(end, "/rw");
- *filter_out = 1;
- fd = os_connect_socket(host_file);
- if(fd > 0)
- return(fd);
-
- strcpy(end, "/r");
- *filter_out = 0;
- fd = os_connect_socket(host_file);
- return(fd);
-}
-
-static void free_contents(struct hppfs_data *head)
-{
- struct hppfs_data *data;
- struct list_head *ele, *next;
-
- if(head == NULL) return;
-
- list_for_each_safe(ele, next, &head->list){
- data = list_entry(ele, struct hppfs_data, list);
- kfree(data);
- }
- kfree(head);
-}
-
-static struct hppfs_data *hppfs_get_data(int fd, int filter,
- struct file *proc_file,
- struct file *hppfs_file,
- loff_t *size_out)
-{
- struct hppfs_data *data, *new, *head;
- int n, err;
-
- err = -ENOMEM;
- data = kmalloc(sizeof(*data), GFP_KERNEL);
- if(data == NULL){
- printk("hppfs_get_data : head allocation failed\n");
- goto failed;
- }
-
- INIT_LIST_HEAD(&data->list);
-
- head = data;
- *size_out = 0;
-
- if(filter){
- while((n = read_proc(proc_file, data->contents,
- sizeof(data->contents), NULL, 0)) > 0)
- os_write_file(fd, data->contents, n);
- err = os_shutdown_socket(fd, 0, 1);
- if(err){
- printk("hppfs_get_data : failed to shut down "
- "socket\n");
- goto failed_free;
- }
- }
- while(1){
- n = os_read_file(fd, data->contents, sizeof(data->contents));
- if(n < 0){
- err = n;
- printk("hppfs_get_data : read failed, errno = %d\n",
- err);
- goto failed_free;
- }
- else if(n == 0)
- break;
-
- *size_out += n;
-
- if(n < sizeof(data->contents))
- break;
-
- new = kmalloc(sizeof(*data), GFP_KERNEL);
- if(new == 0){
- printk("hppfs_get_data : data allocation failed\n");
- err = -ENOMEM;
- goto failed_free;
- }
-
- INIT_LIST_HEAD(&new->list);
- list_add(&new->list, &data->list);
- data = new;
- }
- return(head);
-
- failed_free:
- free_contents(head);
- failed:
- return(ERR_PTR(err));
-}
-
-static struct hppfs_private *hppfs_data(void)
-{
- struct hppfs_private *data;
-
- data = kmalloc(sizeof(*data), GFP_KERNEL);
- if(data == NULL)
- return(data);
-
- *data = ((struct hppfs_private ) { .host_fd = -1,
- .len = -1,
- .contents = NULL } );
- return(data);
-}
-
-static int file_mode(int fmode)
-{
- if(fmode == (FMODE_READ | FMODE_WRITE))
- return(O_RDWR);
- if(fmode == FMODE_READ)
- return(O_RDONLY);
- if(fmode == FMODE_WRITE)
- return(O_WRONLY);
- return(0);
-}
-
-static int hppfs_open(struct inode *inode, struct file *file)
-{
- struct hppfs_private *data;
- struct dentry *proc_dentry;
- char *host_file;
- int err, fd, type, filter;
-
- err = -ENOMEM;
- data = hppfs_data();
- if(data == NULL)
- goto out;
-
- host_file = dentry_name(file->f_dentry, strlen("/rw"));
- if(host_file == NULL)
- goto out_free2;
-
- proc_dentry = HPPFS_I(inode)->proc_dentry;
-
- /* XXX This isn't closed anywhere */
- err = open_private_file(&data->proc_file, proc_dentry,
- file_mode(file->f_mode));
- if(err)
- goto out_free1;
-
- type = os_file_type(host_file);
- if(type == OS_TYPE_FILE){
- fd = os_open_file(host_file, of_read(OPENFLAGS()), 0);
- if(fd >= 0)
- data->host_fd = fd;
- else printk("hppfs_open : failed to open '%s', errno = %d\n",
- host_file, -fd);
-
- data->contents = NULL;
- }
- else if(type == OS_TYPE_DIR){
- fd = open_host_sock(host_file, &filter);
- if(fd > 0){
- data->contents = hppfs_get_data(fd, filter,
- &data->proc_file,
- file, &data->len);
- if(!IS_ERR(data->contents))
- data->host_fd = fd;
- }
- else printk("hppfs_open : failed to open a socket in "
- "'%s', errno = %d\n", host_file, -fd);
- }
- kfree(host_file);
-
- file->private_data = data;
- return(0);
-
- out_free1:
- kfree(host_file);
- out_free2:
- free_contents(data->contents);
- kfree(data);
- out:
- return(err);
-}
-
-static int hppfs_dir_open(struct inode *inode, struct file *file)
-{
- struct hppfs_private *data;
- struct dentry *proc_dentry;
- int err;
-
- err = -ENOMEM;
- data = hppfs_data();
- if(data == NULL)
- goto out;
-
- proc_dentry = HPPFS_I(inode)->proc_dentry;
- err = open_private_file(&data->proc_file, proc_dentry,
- file_mode(file->f_mode));
- if(err)
- goto out_free;
-
- file->private_data = data;
- return(0);
-
- out_free:
- kfree(data);
- out:
- return(err);
-}
-
-static loff_t hppfs_llseek(struct file *file, loff_t off, int where)
-{
- struct hppfs_private *data = file->private_data;
- struct file *proc_file = &data->proc_file;
- loff_t (*llseek)(struct file *, loff_t, int);
- loff_t ret;
-
- llseek = proc_file->f_dentry->d_inode->i_fop->llseek;
- if(llseek != NULL){
- ret = (*llseek)(proc_file, off, where);
- if(ret < 0)
- return(ret);
- }
-
- return(default_llseek(file, off, where));
-}
-
-static struct file_operations hppfs_file_fops = {
- .owner = NULL,
- .llseek = hppfs_llseek,
- .read = hppfs_read,
- .write = hppfs_write,
- .open = hppfs_open,
-};
-
-struct hppfs_dirent {
- void *vfs_dirent;
- filldir_t filldir;
- struct dentry *dentry;
-};
-
-static int hppfs_filldir(void *d, const char *name, int size,
- loff_t offset, ino_t inode, unsigned int type)
-{
- struct hppfs_dirent *dirent = d;
-
- if(file_removed(dirent->dentry, name))
- return(0);
-
- return((*dirent->filldir)(dirent->vfs_dirent, name, size, offset,
- inode, type));
-}
-
-static int hppfs_readdir(struct file *file, void *ent, filldir_t filldir)
-{
- struct hppfs_private *data = file->private_data;
- struct file *proc_file = &data->proc_file;
- int (*readdir)(struct file *, void *, filldir_t);
- struct hppfs_dirent dirent = ((struct hppfs_dirent)
- { .vfs_dirent = ent,
- .filldir = filldir,
- .dentry = file->f_dentry } );
- int err;
-
- readdir = proc_file->f_dentry->d_inode->i_fop->readdir;
-
- proc_file->f_pos = file->f_pos;
- err = (*readdir)(proc_file, &dirent, hppfs_filldir);
- file->f_pos = proc_file->f_pos;
-
- return(err);
-}
-
-static int hppfs_fsync(struct file *file, struct dentry *dentry, int datasync)
-{
- return(0);
-}
-
-static struct file_operations hppfs_dir_fops = {
- .owner = NULL,
- .readdir = hppfs_readdir,
- .open = hppfs_dir_open,
- .fsync = hppfs_fsync,
-};
-
-static int hppfs_statfs(struct super_block *sb, struct kstatfs *sf)
-{
- sf->f_blocks = 0;
- sf->f_bfree = 0;
- sf->f_bavail = 0;
- sf->f_files = 0;
- sf->f_ffree = 0;
- sf->f_type = HPPFS_SUPER_MAGIC;
- return(0);
-}
-
-static struct inode *hppfs_alloc_inode(struct super_block *sb)
-{
- struct hppfs_inode_info *hi;
-
- hi = kmalloc(sizeof(*hi), GFP_KERNEL);
- if(hi == NULL)
- return(NULL);
-
- *hi = ((struct hppfs_inode_info) { .proc_dentry = NULL });
- inode_init_once(&hi->vfs_inode);
- return(&hi->vfs_inode);
-}
-
-void hppfs_delete_inode(struct inode *ino)
-{
- clear_inode(ino);
-}
-
-static void hppfs_destroy_inode(struct inode *inode)
-{
- kfree(HPPFS_I(inode));
-}
-
-static struct super_operations hppfs_sbops = {
- .alloc_inode = hppfs_alloc_inode,
- .destroy_inode = hppfs_destroy_inode,
- .read_inode = hppfs_read_inode,
- .delete_inode = hppfs_delete_inode,
- .statfs = hppfs_statfs,
-};
-
-static int hppfs_readlink(struct dentry *dentry, char *buffer, int buflen)
-{
- struct file proc_file;
- struct dentry *proc_dentry;
- int (*readlink)(struct dentry *, char *, int);
- int err, n;
-
- proc_dentry = HPPFS_I(dentry->d_inode)->proc_dentry;
- err = open_private_file(&proc_file, proc_dentry, O_RDONLY);
- if(err)
- return(err);
-
- readlink = proc_dentry->d_inode->i_op->readlink;
- n = (*readlink)(proc_dentry, buffer, buflen);
-
- close_private_file(&proc_file);
-
- return(n);
-}
-
-static int hppfs_follow_link(struct dentry *dentry, struct nameidata *nd)
-{
- struct file proc_file;
- struct dentry *proc_dentry;
- int (*follow_link)(struct dentry *, struct nameidata *);
- int err, n;
-
- proc_dentry = HPPFS_I(dentry->d_inode)->proc_dentry;
- err = open_private_file(&proc_file, proc_dentry, O_RDONLY);
- if(err)
- return(err);
-
- follow_link = proc_dentry->d_inode->i_op->follow_link;
- n = (*follow_link)(proc_dentry, nd);
-
- close_private_file(&proc_file);
-
- return(n);
-}
-
-static struct inode_operations hppfs_dir_iops = {
- .lookup = hppfs_lookup,
-};
-
-static struct inode_operations hppfs_link_iops = {
- .readlink = hppfs_readlink,
- .follow_link = hppfs_follow_link,
-};
-
-static int init_inode(struct inode *inode, struct dentry *dentry)
-{
- if(S_ISDIR(dentry->d_inode->i_mode)){
- inode->i_op = &hppfs_dir_iops;
- inode->i_fop = &hppfs_dir_fops;
- }
- else if(S_ISLNK(dentry->d_inode->i_mode)){
- inode->i_op = &hppfs_link_iops;
- inode->i_fop = &hppfs_file_fops;
- }
- else {
- inode->i_op = &hppfs_file_iops;
- inode->i_fop = &hppfs_file_fops;
- }
-
- HPPFS_I(inode)->proc_dentry = dentry;
-
- return(0);
-}
-
-static int hppfs_fill_super(struct super_block *sb, void *d, int silent)
-{
- struct inode *root_inode;
- struct file_system_type *procfs;
- struct super_block *proc_sb;
- int err;
-
- err = -ENOENT;
- procfs = get_fs_type("proc");
- if(procfs == NULL)
- goto out;
-
- if(list_empty(&procfs->fs_supers))
- goto out;
-
- proc_sb = list_entry(procfs->fs_supers.next, struct super_block,
- s_instances);
-
- sb->s_blocksize = 1024;
- sb->s_blocksize_bits = 10;
- sb->s_magic = HPPFS_SUPER_MAGIC;
- sb->s_op = &hppfs_sbops;
-
- root_inode = iget(sb, 0);
- if(root_inode == NULL)
- goto out;
-
- err = init_inode(root_inode, proc_sb->s_root);
- if(err)
- goto out_put;
-
- err = -ENOMEM;
- sb->s_root = d_alloc_root(root_inode);
- if(sb->s_root == NULL)
- goto out_put;
-
- hppfs_read_inode(root_inode);
-
- return(0);
-
- out_put:
- iput(root_inode);
- out:
- return(err);
-}
-
-static struct super_block *hppfs_read_super(struct file_system_type *type,
- int flags, const char *dev_name,
- void *data)
-{
- return(get_sb_nodev(type, flags, data, hppfs_fill_super));
-}
-
-static struct file_system_type hppfs_type = {
- .owner = THIS_MODULE,
- .name = "hppfs",
- .get_sb = hppfs_read_super,
- .kill_sb = kill_anon_super,
- .fs_flags = 0,
-};
-
-static int __init init_hppfs(void)
-{
- return(register_filesystem(&hppfs_type));
-}
-
-static void __exit exit_hppfs(void)
-{
- unregister_filesystem(&hppfs_type);
-}
-
-module_init(init_hppfs)
-module_exit(exit_hppfs)
-MODULE_LICENSE("GPL");
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only. This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
+++ /dev/null
-#include <asm-generic/local.h>
+++ /dev/null
-#ifndef _CRIS_SECTIONS_H
-#define _CRIS_SECTIONS_H
-
-/* nothing to see, move along */
-#include <asm-generic/sections.h>
-
-#endif
+++ /dev/null
-#ifndef __UM_CPUFEATURE_H
-#define __UM_CPUFEATURE_H
-
-#include "asm/arch/cpufeature.h"
-
-#endif
+++ /dev/null
-#ifndef __UM_LOCAL_H
-#define __UM_LOCAL_H
-
-#include "asm/arch/local.h"
-
-#endif
+++ /dev/null
-#ifndef __UM_MODULE_GENERIC_H
-#define __UM_MODULE_GENERIC_H
-
-#include "asm/arch/module.h"
-
-#endif
+++ /dev/null
-#ifndef _UM_SECTIONS_H
-#define _UM_SECTIONS_H
-
-/* nothing to see, move along */
-#include <asm-generic/sections.h>
-
-#endif
+++ /dev/null
-#!/usr/bin/perl -w
-#
-# reference_init.pl (C) Keith Owens 2002 <kaos@ocs.com.au>
-#
-# List references to vmlinux init sections from non-init sections.
-
-# Unfortunately I had to exclude references from read only data to .init
-# sections, almost all of these are false positives, they are created by
-# gcc. The downside of excluding rodata is that there really are some
-# user references from rodata to init code, e.g. drivers/video/vgacon.c
-#
-# const struct consw vga_con = {
-# con_startup: vgacon_startup,
-#
-# where vgacon_startup is __init. If you want to wade through the false
-# positives, take out the check for rodata.
-
-use strict;
-die($0 . " takes no arguments\n") if($#ARGV >= 0);
-
-my %object;
-my $object;
-my $line;
-my $ignore;
-
-$| = 1;
-
-printf("Finding objects, ");
-open(OBJDUMP_LIST, "find . -name '*.o' | xargs objdump -h |") || die "getting objdump list failed";
-while (defined($line = <OBJDUMP_LIST>)) {
- chomp($line);
- if ($line =~ /:\s+file format/) {
- ($object = $line) =~ s/:.*//;
- $object{$object}->{'module'} = 0;
- $object{$object}->{'size'} = 0;
- $object{$object}->{'off'} = 0;
- }
- if ($line =~ /^\s*\d+\s+\.modinfo\s+/) {
- $object{$object}->{'module'} = 1;
- }
- if ($line =~ /^\s*\d+\s+\.comment\s+/) {
- ($object{$object}->{'size'}, $object{$object}->{'off'}) = (split(' ', $line))[2,5];
- }
-}
-close(OBJDUMP_LIST);
-printf("%d objects, ", scalar keys(%object));
-$ignore = 0;
-foreach $object (keys(%object)) {
- if ($object{$object}->{'module'}) {
- ++$ignore;
- delete($object{$object});
- }
-}
-printf("ignoring %d module(s)\n", $ignore);
-
-# Ignore conglomerate objects, they have been built from multiple objects and we
-# only care about the individual objects. If an object has more than one GCC:
-# string in the comment section then it is conglomerate. This does not filter
-# out conglomerates that consist of exactly one object, can't be helped.
-
-printf("Finding conglomerates, ");
-$ignore = 0;
-foreach $object (keys(%object)) {
- if (exists($object{$object}->{'off'})) {
- my ($off, $size, $comment, $l);
- $off = hex($object{$object}->{'off'});
- $size = hex($object{$object}->{'size'});
- open(OBJECT, "<$object") || die "cannot read $object";
- seek(OBJECT, $off, 0) || die "seek to $off in $object failed";
- $l = read(OBJECT, $comment, $size);
- die "read $size bytes from $object .comment failed" if ($l != $size);
- close(OBJECT);
- if ($comment =~ /GCC\:.*GCC\:/m) {
- ++$ignore;
- delete($object{$object});
- }
- }
-}
-printf("ignoring %d conglomerate(s)\n", $ignore);
-
-printf("Scanning objects\n");
-foreach $object (sort(keys(%object))) {
- my $from;
- open(OBJDUMP, "objdump -r $object|") || die "cannot objdump -r $object";
- while (defined($line = <OBJDUMP>)) {
- chomp($line);
- if ($line =~ /RELOCATION RECORDS FOR /) {
- ($from = $line) =~ s/.*\[([^]]*).*/$1/;
- }
- if (($line =~ /\.init$/ || $line =~ /\.init\./) &&
- ($from !~ /\.init$/ &&
- $from !~ /\.init\./ &&
- $from !~ /\.stab$/ &&
- $from !~ /\.rodata$/ &&
- $from !~ /\.text\.lock$/ &&
- $from !~ /\.debug_/)) {
- printf("Error: %s %s refers to %s\n", $object, $from, $line);
- }
- }
- close(OBJDUMP);
-}
-printf("Done\n");